Fri, 21 May 2004 14:33:32 +0000
[gaim-migrate @ 9774]
" This patch renames the existing received-*-msg signals
to receiving-*msg to fit the naming of other signals
where a pointer to the message is passed (writing,
sending, displaying)
It adds new received-*-msg signals which are emitted
after the receiving signals, in line with the other
conversation signals (wrote, sent, displayed)
This is necessary to allow plugins which depend on the
final received message to work alongside plugins which
may modify the message.
One known example of this is festival-gaim alongside
gaim-encryption - festival-gaim would try to "speak"
the encrypted text:
http://sf.net/tracker/?func=detail&aid=943216&group_id=89763&atid=591320
I've tested this with gaim-encryption and festival-gaim
(locally modified so gaim-encryption uses the receiving
signal and festival uses the received signal)
All in-tree users of received-*-msg are updated to use
receiving-*-msg if they do modify the message, the
conversation-signals documentation is updated, the
signals-test.c & signal-test.tcl plugins are also updated." --Stu Tomlinson
committer: Luke Schierer <lschiere@pidgin.im>
| 5370 | 1 | /** |
| 2 | * @file page.c Paging functions | |
| 3 | * | |
| 4 | * gaim | |
| 5 | * | |
|
8475
3b5687726055
[gaim-migrate @ 9208]
Christian Hammond <chipx86@chipx86.com>
parents:
7468
diff
changeset
|
6 | * Copyright (C) 2003-2004 Christian Hammond <chipx86@gnupdate.org> |
|
6701
7e2db9273748
[gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents:
5370
diff
changeset
|
7 | * |
| 5370 | 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 | #include "msn.h" | |
| 23 | #include "page.h" | |
| 24 | ||
| 25 | #define GET_NEXT(tmp) \ | |
| 26 | while (*(tmp) && *(tmp) != ' ' && *(tmp) != '\r') \ | |
| 27 | (tmp)++; \ | |
| 28 | if (*(tmp) != '\0') *(tmp)++ = '\0'; \ | |
| 29 | if (*(tmp) == '\n') *(tmp)++; \ | |
| 30 | while (*(tmp) && *(tmp) == ' ') \ | |
| 31 | (tmp)++ | |
| 32 | ||
| 33 | #define GET_NEXT_LINE(tmp) \ | |
| 34 | while (*(tmp) && *(tmp) != '\r') \ | |
| 35 | (tmp)++; \ | |
| 36 | if (*(tmp) != '\0') *(tmp)++ = '\0'; \ | |
| 37 | if (*(tmp) == '\n') *(tmp)++ | |
| 38 | ||
| 39 | /* | |
|
7468
42a4a41cd137
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
40 | * <TEXT xml:space="preserve" enc="utf-8"> == 39 |
|
42a4a41cd137
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
41 | * </TEXT> == 7 |
|
42a4a41cd137
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
42 | * ---- |
|
42a4a41cd137
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
43 | * 46 |
| 5370 | 44 | */ |
|
7468
42a4a41cd137
[gaim-migrate @ 8081]
Christian Hammond <chipx86@chipx86.com>
parents:
7386
diff
changeset
|
45 | #define MSN_PAGE_BASE_SIZE 46 |
| 5370 | 46 | |
| 47 | MsnPage * | |
| 48 | msn_page_new(void) | |
| 49 | { | |
| 50 | MsnPage *page; | |
| 51 | ||
| 52 | page = g_new0(MsnPage, 1); | |
| 53 | ||
| 54 | page->size = MSN_PAGE_BASE_SIZE; | |
| 55 | ||
| 56 | return page; | |
| 57 | } | |
| 58 | ||
| 59 | void | |
| 60 | msn_page_destroy(MsnPage *page) | |
| 61 | { | |
| 62 | g_return_if_fail(page != NULL); | |
| 63 | ||
| 64 | if (page->body != NULL) | |
| 65 | g_free(page->body); | |
| 66 | ||
| 67 | if (page->from_location != NULL) | |
| 68 | g_free(page->from_location); | |
| 69 | ||
| 70 | if (page->from_phone != NULL) | |
| 71 | g_free(page->from_phone); | |
| 72 | ||
| 73 | g_free(page); | |
| 74 | } | |
| 75 | ||
| 76 | char * | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
77 | msn_page_gen_payload(const MsnPage *page, size_t *ret_size) |
| 5370 | 78 | { |
| 79 | char *str; | |
| 80 | ||
| 81 | g_return_val_if_fail(page != NULL, NULL); | |
| 82 | ||
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
83 | str = |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
84 | g_strdup_printf("<TEXT xml:space=\"preserve\" enc=\"utf-8\">%s</TEXT>", |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
85 | msn_page_get_body(page)); |
| 5370 | 86 | |
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
87 | if (page->size != strlen(str)) |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
88 | { |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
89 | gaim_debug(GAIM_DEBUG_ERROR, "msn", |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
90 | "Outgoing page size (%d) and string length (%d) " |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
91 | "do not match!\n", page->size, strlen(str)); |
| 5370 | 92 | } |
| 93 | ||
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
94 | if (ret_size != NULL) |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
95 | *ret_size = page->size - 1; |
| 5370 | 96 | |
| 97 | return str; | |
| 98 | } | |
| 99 | ||
| 100 | void | |
| 101 | msn_page_set_body(MsnPage *page, const char *body) | |
| 102 | { | |
| 103 | g_return_if_fail(page != NULL); | |
| 104 | g_return_if_fail(body != NULL); | |
| 105 | ||
|
8646
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
106 | if (page->body != NULL) |
|
74d0e7406e3b
[gaim-migrate @ 9398]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
8475
diff
changeset
|
107 | { |
| 5370 | 108 | page->size -= strlen(page->body); |
| 109 | g_free(page->body); | |
| 110 | } | |
| 111 | ||
| 112 | page->body = g_strdup(body); | |
| 113 | ||
| 114 | page->size += strlen(body); | |
| 115 | } | |
| 116 | ||
| 117 | const char * | |
| 118 | msn_page_get_body(const MsnPage *page) | |
| 119 | { | |
| 120 | g_return_val_if_fail(page != NULL, NULL); | |
| 121 | ||
| 122 | return page->body; | |
| 123 | } | |
| 124 |