Fri, 23 Dec 2005 19:26:04 +0000
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Richard Laager <rlaager@pidgin.im>
| 8675 | 1 | /* |
| 2 | * nmconn.h | |
| 3 | * | |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
4 | * Copyright (c) 2004 Novell, Inc. All Rights Reserved. |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
5 | * |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
6 | * This program is free software; you can redistribute it and/or modify |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
7 | * it under the terms of the GNU General Public License as published by |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
8 | * the Free Software Foundation; version 2 of the License. |
| 8675 | 9 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
13 | * GNU General Public License for more details. |
|
8684
7ec649752daa
[gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents:
8675
diff
changeset
|
14 | * |
|
8933
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
16 | * along with this program; if not, write to the Free Software |
|
0f1e8160581d
[gaim-migrate @ 9703]
Mike Stoddard <mistoddard@novell.com>
parents:
8874
diff
changeset
|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 8675 | 18 | * |
| 19 | */ | |
| 20 | ||
| 21 | #ifndef __NM_CONN_H__ | |
| 22 | #define __NM_CONN_H__ | |
| 23 | ||
| 24 | typedef struct _NMConn NMConn; | |
| 25 | typedef struct _NMSSLConn NMSSLConn; | |
| 26 | ||
| 27 | #include "nmfield.h" | |
| 28 | #include "nmuser.h" | |
| 29 | ||
| 30 | typedef int (*nm_ssl_read_cb) (gpointer ssl_data, void *buff, int len); | |
| 31 | typedef int (*nm_ssl_write_cb) (gpointer ssl_data, const void *buff, int len); | |
| 32 | ||
| 33 | struct _NMConn | |
| 34 | { | |
| 35 | ||
| 36 | /* The address of the server that we are connecting to. */ | |
| 37 | char *addr; | |
| 38 | ||
| 39 | /* The port that we are connecting to. */ | |
| 40 | int port; | |
| 41 | ||
| 42 | /* The file descriptor of the socket for the connection. */ | |
| 43 | int fd; | |
| 44 | ||
| 45 | /* The transaction counter. */ | |
| 46 | int trans_id; | |
| 47 | ||
| 48 | /* A list of requests currently awaiting a response. */ | |
| 49 | GSList *requests; | |
| 50 | ||
| 51 | /* Are we connected? TRUE if so, FALSE if not. */ | |
| 52 | gboolean connected; | |
| 53 | ||
| 54 | /* Are we running in secure mode? */ | |
| 55 | gboolean use_ssl; | |
| 56 | ||
| 57 | /* Have we been redirected? */ | |
| 58 | gboolean redirect; | |
| 59 | ||
| 60 | /* SSL connection */ | |
| 61 | NMSSLConn *ssl_conn; | |
| 62 | ||
| 63 | }; | |
| 64 | ||
| 65 | struct _NMSSLConn | |
| 66 | { | |
| 67 | ||
| 68 | /* Data to pass to the callbacks */ | |
| 69 | gpointer data; | |
| 70 | ||
| 71 | /* Callbacks for reading/writing */ | |
| 72 | nm_ssl_read_cb read; | |
| 73 | nm_ssl_write_cb write; | |
| 74 | ||
| 75 | }; | |
| 76 | ||
| 77 | /** | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
78 | * Allocate a new NMConn struct |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
79 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
80 | * @param The address of the server that we are connecting to. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
81 | * @param The port that we are connecting to. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
82 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
83 | * @return A pointer to a newly allocated NMConn struct, should |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
84 | * be freed by calling nm_release_conn() |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
85 | */ |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
86 | NMConn *nm_create_conn(const char *addr, int port); |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
87 | |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
88 | /** |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
89 | * Release an NMConn |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
90 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
91 | * @param Pointer to the NMConn to release. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
92 | * |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
93 | */ |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
94 | void nm_release_conn(NMConn *conn); |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
95 | |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
96 | /** |
| 8675 | 97 | * Write len bytes from the given buffer. |
| 98 | * | |
| 99 | * @param conn The connection to write to. | |
| 100 | * @param buff The buffer to write from. | |
| 101 | * @param len The number of bytes to write. | |
| 102 | * | |
| 103 | * @return The number of bytes written. | |
| 104 | */ | |
| 105 | int nm_tcp_write(NMConn * conn, const void *buff, int len); | |
| 106 | ||
| 107 | /** | |
| 108 | * Read at most len bytes into the given buffer. | |
| 109 | * | |
| 110 | * @param conn The connection to read from. | |
| 111 | * @param buff The buffer to write to. | |
| 112 | * @param len The maximum number of bytes to read. | |
| 113 | * | |
| 114 | * @return The number of bytes read. | |
| 115 | */ | |
| 116 | int nm_tcp_read(NMConn * conn, void *buff, int len); | |
| 117 | ||
| 118 | /** | |
| 119 | * Read exactly len bytes into the given buffer. | |
| 120 | * | |
| 121 | * @param conn The connection to read from. | |
| 122 | * @param buff The buffer to write to. | |
| 123 | * @param len The number of bytes to read. | |
| 124 | * | |
| 125 | * @return NM_OK on success, NMERR_TCP_READ if read fails. | |
| 126 | */ | |
| 127 | NMERR_T nm_read_all(NMConn * conn, char *buf, int len); | |
| 128 | ||
| 129 | /** | |
|
8874
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
130 | * Read a 32 bit value and convert it to the host byte order. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
131 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
132 | * @param conn The connection to read from. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
133 | * @param val A pointer to unsigned 32 bit integer |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
134 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
135 | * @return NM_OK on success, NMERR_TCP_READ if read fails. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
136 | */ |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
137 | NMERR_T |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
138 | nm_read_uint32(NMConn *conn, guint32 *val); |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
139 | |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
140 | /** |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
141 | * Read a 16 bit value and convert it to the host byte order. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
142 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
143 | * @param conn The connection to read from. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
144 | * @param val A pointer to unsigned 16 bit integer |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
145 | * |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
146 | * @return NM_OK on success, NMERR_TCP_READ if read fails. |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
147 | */ |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
148 | NMERR_T |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
149 | nm_read_uint16(NMConn *conn, guint16 *val); |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
150 | |
|
6dda85680808
[gaim-migrate @ 9643]
Mike Stoddard <mistoddard@novell.com>
parents:
8684
diff
changeset
|
151 | /** |
| 8675 | 152 | * Dispatch a request to the server. |
| 153 | * | |
| 154 | * @param conn The connection. | |
| 155 | * @param cmd The request to dispatch. | |
| 156 | * @param fields The field list for the request. | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
157 | * @param cb The response callback for the new request object. |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
158 | * @param data The user defined data for the request (to be passed to the resp cb). |
| 8675 | 159 | * @param req The request. Should be freed with nm_release_request. |
| 160 | * | |
| 161 | * @return NM_OK on success. | |
| 162 | */ | |
|
9360
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
163 | NMERR_T |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
164 | nm_send_request(NMConn *conn, char *cmd, NMField *fields, |
|
c40bc951573a
[gaim-migrate @ 10168]
Mike Stoddard <mistoddard@novell.com>
parents:
8933
diff
changeset
|
165 | nm_response_cb cb, gpointer data, NMRequest **request); |
| 8675 | 166 | |
| 167 | /** | |
| 168 | * Write out the given field list. | |
| 169 | * | |
| 170 | * @param conn The connection to write to. | |
| 171 | * @param fields The field list to write. | |
| 172 | * | |
| 173 | * @return NM_OK on success. | |
| 174 | */ | |
| 175 | NMERR_T nm_write_fields(NMConn * conn, NMField * fields); | |
| 176 | ||
| 177 | /** | |
| 178 | * Read the headers for a response. | |
| 179 | * | |
| 180 | * @param conn The connection to read from. | |
| 181 | * | |
| 182 | * @return NM_OK on success. | |
| 183 | */ | |
| 184 | NMERR_T nm_read_header(NMConn * conn); | |
| 185 | ||
| 186 | /** | |
| 187 | * Read a field list from the connection. | |
| 188 | * | |
| 189 | * @param conn The connection to read from. | |
| 190 | * @param count The maximum number of fields to read (or -1 for no max). | |
| 191 | * @param fields The field list. This is an out param. It | |
| 192 | * should be freed by calling nm_free_fields | |
| 193 | * when finished. | |
| 194 | * | |
| 195 | * @return NM_OK on success. | |
| 196 | */ | |
| 197 | NMERR_T nm_read_fields(NMConn * conn, int count, NMField ** fields); | |
| 198 | ||
| 199 | /** | |
| 200 | * Add a request to the connections request list. | |
| 201 | * | |
| 202 | * @param conn The connection. | |
| 203 | * @param request The request to add to the list. | |
| 204 | */ | |
| 205 | void nm_conn_add_request_item(NMConn * conn, NMRequest * request); | |
| 206 | ||
| 207 | /** | |
| 208 | * Remove a request from the connections list. | |
| 209 | * | |
| 210 | * @param conn The connection. | |
| 211 | * @param request The request to remove from the list. | |
| 212 | */ | |
| 213 | void nm_conn_remove_request_item(NMConn * conn, NMRequest * request); | |
| 214 | ||
| 215 | /** | |
| 216 | * Find the request with the given transaction id in the connections | |
| 217 | * request list. | |
| 218 | * | |
| 219 | * @param conn The connection. | |
| 220 | * @param trans_id The transaction id of the request to return. | |
| 221 | * | |
| 222 | * @return The request, or NULL if a matching request is not | |
| 223 | * found. | |
| 224 | */ | |
| 225 | NMRequest *nm_conn_find_request(NMConn * conn, int trans_id); | |
| 226 | ||
| 227 | /** | |
| 228 | * Get the server address for the connection. | |
| 229 | * | |
| 230 | * @param conn The connection. | |
| 231 | * | |
| 232 | * @return The server address for the connection. | |
| 233 | * | |
| 234 | */ | |
| 235 | const char *nm_conn_get_addr(NMConn * conn); | |
| 236 | ||
| 237 | /** | |
| 238 | * Get the port for the connection. | |
| 239 | * | |
| 240 | * @param conn The connection. | |
| 241 | * | |
| 242 | * @return The port that we are connected to. | |
| 243 | */ | |
| 244 | int nm_conn_get_port(NMConn * conn); | |
| 245 | ||
| 246 | #endif |