Mercurial > pidgin
annotate src/protocols/msn/slpmsg.c @ 10108:f0100b414d98
[gaim-migrate @ 11141]
Two things:
a. Added Enter as a gtk_binding to GtkIMHtml. This fixes everything.
Input methods now work. The "Enter sends" and "Ctrl-Enter sends" preferences
were removed and defaulted to yes and no respectively, BUT, in a very super-cool
turn of events, you can now add your own bindings to .gtkrc to make WHATEVER
YOU WANT send. Awesome. Someone should use g_signal_accumulator_true_handled
or something to make profiles and away messages able to insert newlines.
b. Removed "Use multi-colored screennames in chats," defaulted to yes, and
wrote a nifty algorithm to automatically adjust the colors to accomodate the
background (see http://gaim.sf.net/sean/porn-chat.png). People should play
around and tweak it a bit. The algorithm takes into consideration the
luminosity of the current background and the base hue to use for the screenname
in generating the new colors. Note that it does this while maintaining the hues.
Someone should optimize this so it skips over the floating point arithmatic when
the background color is white.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Sun, 17 Oct 2004 23:55:49 +0000 |
| parents | 4c1a1be8ce33 |
| children | 1a91e814e9d8 |
| rev | line source |
|---|---|
| 9193 | 1 /** |
| 2 * @file slpmsg.h SLP Message functions | |
| 3 * | |
| 4 * gaim | |
| 5 * | |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
6 * Gaim is the legal property of its developers, whose names are too numerous |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
8 * source distribution. |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
9 * |
| 9193 | 10 * This program is free software; you can redistribute it and/or modify |
| 11 * it under the terms of the GNU General Public License as published by | |
| 12 * the Free Software Foundation; either version 2 of the License, or | |
| 13 * (at your option) any later version. | |
| 14 * | |
| 15 * This program is distributed in the hope that it will be useful, | |
| 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 * GNU General Public License for more details. | |
| 19 * | |
| 20 * You should have received a copy of the GNU General Public License | |
| 21 * along with this program; if not, write to the Free Software | |
| 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 23 */ | |
| 24 #include "msn.h" | |
| 25 #include "slpmsg.h" | |
| 26 #include "slplink.h" | |
| 27 | |
| 28 /************************************************************************** | |
| 29 * SLP Message | |
| 30 **************************************************************************/ | |
| 31 | |
| 32 MsnSlpMessage * | |
| 33 msn_slpmsg_new(MsnSlpLink *slplink) | |
| 34 { | |
| 35 MsnSlpMessage *slpmsg; | |
| 36 slpmsg = g_new0(MsnSlpMessage, 1); | |
| 37 | |
| 38 slpmsg->slplink = slplink; | |
| 39 | |
| 40 slplink->slp_msgs = | |
| 41 g_list_append(slplink->slp_msgs, slpmsg); | |
| 42 | |
| 43 return slpmsg; | |
| 44 } | |
| 45 | |
| 46 void | |
| 47 msn_slpmsg_destroy(MsnSlpMessage *slpmsg) | |
| 48 { | |
| 49 MsnSlpLink *slplink; | |
| 50 | |
| 51 slplink = slpmsg->slplink; | |
| 52 | |
| 53 if (slpmsg->fp != NULL) | |
| 54 fclose(slpmsg->fp); | |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
55 |
| 9193 | 56 if (slpmsg->buffer != NULL) |
| 57 g_free(slpmsg->buffer); | |
| 58 | |
| 59 #ifdef DEBUG_SLP | |
| 60 /* | |
| 61 if (slpmsg->info != NULL) | |
| 62 g_free(slpmsg->info); | |
| 63 */ | |
| 64 #endif | |
| 65 | |
| 66 if (slpmsg->msg != NULL) | |
| 67 { | |
| 68 if (slpmsg->msg->trans != NULL) | |
| 69 { | |
| 70 slpmsg->msg->trans->callbacks = NULL; | |
| 71 slpmsg->msg->trans->data = NULL; | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 slplink->slp_msgs = | |
| 76 g_list_remove(slplink->slp_msgs, slpmsg); | |
| 77 | |
| 78 g_free(slpmsg); | |
| 79 } | |
| 80 | |
| 81 void | |
| 82 msn_slpmsg_set_body(MsnSlpMessage *slpmsg, const char *body, | |
| 83 long long size) | |
| 84 { | |
| 85 if (body != NULL) | |
| 86 slpmsg->buffer = g_memdup(body, size); | |
| 87 else | |
| 88 slpmsg->buffer = g_new0(char, size); | |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
89 |
| 9193 | 90 slpmsg->size = size; |
| 91 } | |
| 92 | |
| 93 void | |
| 94 msn_slpmsg_open_file(MsnSlpMessage *slpmsg, const char *file_name) | |
| 95 { | |
| 96 struct stat st; | |
| 97 | |
| 9219 | 98 slpmsg->fp = fopen(file_name, "rb"); |
| 9193 | 99 |
| 100 if (stat(file_name, &st) == 0) | |
| 101 slpmsg->size = st.st_size; | |
| 102 } | |
| 103 | |
| 104 #ifdef DEBUG_SLP | |
| 105 const void | |
| 106 msn_slpmsg_show(MsnMessage *msg) | |
| 107 { | |
| 108 const char *info; | |
| 109 gboolean text; | |
| 110 guint32 flags; | |
| 111 | |
| 112 text = FALSE; | |
| 113 | |
| 9775 | 114 flags = GUINT32_TO_LE(msg->msnslp_header.flags); |
| 9193 | 115 |
| 116 switch (flags) | |
| 117 { | |
| 118 case 0x0: | |
| 119 info = "SLP CONTROL"; | |
| 120 text = TRUE; | |
| 121 break; | |
| 122 case 0x2: | |
| 123 info = "SLP ACK"; break; | |
| 124 case 0x20: | |
| 125 info = "SLP DATA"; break; | |
| 126 default: | |
| 127 info = "SLP UNKNOWN"; break; | |
| 128 } | |
| 129 | |
| 130 msn_message_show_readable(msg, info, text); | |
| 131 } | |
| 132 #endif | |
| 133 | |
| 134 MsnSlpMessage * | |
| 135 msn_slpmsg_sip_new(MsnSlpCall *slpcall, int cseq, | |
| 136 const char *header, const char *branch, | |
| 137 const char *content_type, const char *content) | |
| 138 { | |
| 139 MsnSlpLink *slplink; | |
| 140 MsnSlpMessage *slpmsg; | |
| 141 char *body; | |
| 142 gsize body_len; | |
| 143 gsize content_len; | |
| 144 | |
| 145 g_return_val_if_fail(slpcall != NULL, NULL); | |
| 146 g_return_val_if_fail(header != NULL, NULL); | |
| 147 | |
| 148 slplink = slpcall->slplink; | |
| 149 | |
| 150 /* Let's remember that "content" should end with a 0x00 */ | |
| 151 | |
| 152 content_len = (content != NULL) ? strlen(content) + 1 : 0; | |
| 153 | |
| 154 body = g_strdup_printf( | |
| 155 "%s\r\n" | |
| 156 "To: <msnmsgr:%s>\r\n" | |
| 157 "From: <msnmsgr:%s>\r\n" | |
| 158 "Via: MSNSLP/1.0/TLP ;branch={%s}\r\n" | |
| 159 "CSeq: %d\r\n" | |
| 160 "Call-ID: {%s}\r\n" | |
| 161 "Max-Forwards: 0\r\n" | |
| 162 "Content-Type: %s\r\n" | |
| 163 "Content-Length: %d\r\n" | |
| 164 "\r\n", | |
| 165 header, | |
| 166 slplink->remote_user, | |
| 167 slplink->local_user, | |
| 168 branch, | |
| 169 cseq, | |
| 170 slpcall->id, | |
| 171 content_type, | |
| 172 content_len); | |
| 173 | |
| 174 body_len = strlen(body); | |
| 175 | |
| 176 if (content_len > 0) | |
| 177 { | |
| 178 body_len += content_len; | |
| 179 body = g_realloc(body, body_len); | |
| 180 g_strlcat(body, content, body_len); | |
| 181 } | |
| 182 | |
| 183 slpmsg = msn_slpmsg_new(slplink); | |
| 184 msn_slpmsg_set_body(slpmsg, body, body_len); | |
| 185 | |
| 186 slpmsg->sip = TRUE; | |
| 187 | |
| 188 g_free(body); | |
| 189 | |
| 190 return slpmsg; | |
| 191 } |
