annotate src/conversation.c @ 4990:f514aa3c01db

[gaim-migrate @ 5325] Updates to the about box and AUTHORS file. Thanks Robert McQueen. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Fri, 04 Apr 2003 00:37:13 +0000
parents 9e50494f63a1
children bfcf72c5a930
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
4 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org>
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 344
diff changeset
22 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
23 #include <config.h>
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 344
diff changeset
24 #endif
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
25
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 #include <string.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
27 #include <stdlib.h>
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <sys/stat.h>
2123
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
29 #include <errno.h>
210
ec0686b3b03f [gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 209
diff changeset
30 #include <ctype.h>
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
31 #include "conversation.h"
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
32 #include "gaim.h"
1235
a9cf2f61a7b1 [gaim-migrate @ 1245]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1228
diff changeset
33 #include "prpl.h"
337
f5b199e20d12 [gaim-migrate @ 347]
Rob Flynn <gaim@robflynn.com>
parents: 315
diff changeset
34
4373
dcc6c130c6d9 [gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4369
diff changeset
35 #ifdef _WIN32
dcc6c130c6d9 [gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4369
diff changeset
36 #include "win32dep.h"
dcc6c130c6d9 [gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4369
diff changeset
37 #endif
dcc6c130c6d9 [gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4369
diff changeset
38
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
39 struct ConvPlacementData
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
40 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
41 char *name;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
42 gaim_conv_placement_fnc fnc;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
43 };
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
44
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
45 #define SEND_TYPED_TIMEOUT 5000
4241
cc14954cc399 [gaim-migrate @ 4491]
Luke Schierer <lschiere@pidgin.im>
parents: 4228
diff changeset
46
4481
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
47 static struct gaim_window_ui_ops *win_ui_ops = NULL;
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
48
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
49 static GList *conversations = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
50 static GList *ims = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
51 static GList *chats = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
52 static GList *windows = NULL;
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
53 static GList *conv_placement_fncs = NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
54 static gaim_conv_placement_fnc place_conv = NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
55 static int place_conv_index = -1;
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
56
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
57 static gint
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
58 insertname_compare(gconstpointer one, gconstpointer two)
3081
eb364675bbe4 [gaim-migrate @ 3095]
Rob Flynn <gaim@robflynn.com>
parents: 3060
diff changeset
59 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
60 const char *a = (const char *)one;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
61 const char *b = (const char *)two;
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
62
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
63 if (*a == '@') {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
64 if (*b != '@') return -1;
70
dead1eb6d654 [gaim-migrate @ 80]
Rob Flynn <gaim@robflynn.com>
parents: 68
diff changeset
65
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
66 return strcasecmp(a + 1, b + 1);
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
67
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
68 } else if (*a == '%') {
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
69 if (*b != '%') return -1;
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
70
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
71 return strcasecmp(a + 1, b + 1);
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
72
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
73 } else if (*a == '+') {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
74 if (*b == '@') return 1;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
75 if (*b != '+') return -1;
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
76
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
77 return strcasecmp(a + 1, b + 1);
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
78
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
79 } else if (*b == '@' || *b == '%' || *b == '+')
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
80 return 1;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
81
4621
69f028a6f357 [gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents: 4616
diff changeset
82 return strcasecmp(a, b);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
85 static gboolean
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
86 find_nick(struct gaim_connection *gc, const char *message)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
88 char *msg, *who, *p;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
89 int n;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
90
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
91 msg = g_utf8_strdown(message, -1);
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
92
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
93 who = g_utf8_strdown(gc->username, -1);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
94 n = strlen(who);
814
a636ac51d15b [gaim-migrate @ 824]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 808
diff changeset
95
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
96 if ((p = strstr(msg, who)) != NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
97 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
98 g_free(who);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
99 g_free(msg);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
100
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
101 return TRUE;
1692
a312d64a995d [gaim-migrate @ 1702]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1663
diff changeset
102 }
1573
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
103 }
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
104
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
105 g_free(who);
625
ea41ca1658b5 [gaim-migrate @ 635]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 624
diff changeset
106
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
107 if (!gaim_utf8_strcasecmp(gc->username, gc->displayname)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
108 g_free(msg);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
109
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
110 return FALSE;
511
3133ab511d92 [gaim-migrate @ 521]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 502
diff changeset
111 }
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
112
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
113 who = g_utf8_strdown(gc->displayname, -1);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
114 n = strlen(who);
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
115
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
116 if (n > 0 && (p = strstr(msg, who)) != NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
117 if ((p == msg || !isalnum(*(p - 1))) && !isalnum(*(p + n))) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
118 g_free(who);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
119 g_free(msg);
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
120
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
121 return TRUE;
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
122 }
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
123 }
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
124
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
125 g_free(who);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
126 g_free(msg);
3612
abb114442532 [gaim-migrate @ 3726]
Sean Egan <seanegan@gmail.com>
parents: 3597
diff changeset
127
3596
bb966d68f9e3 [gaim-migrate @ 3698]
Mark Doliner <mark@kingant.net>
parents: 3572
diff changeset
128 return FALSE;
bb966d68f9e3 [gaim-migrate @ 3698]
Mark Doliner <mark@kingant.net>
parents: 3572
diff changeset
129 }
bb966d68f9e3 [gaim-migrate @ 3698]
Mark Doliner <mark@kingant.net>
parents: 3572
diff changeset
130
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
131 static gboolean
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
132 reset_typing(gpointer data)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
133 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
134 char *name = (char *)data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
135 struct gaim_conversation *c = gaim_find_conversation(name);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
136 struct gaim_im *im;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
137
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
138 if (!c)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
139 return FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
140
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
141 im = GAIM_IM(c);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
142
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
143 gaim_im_set_typing_state(im, NOT_TYPING);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
144 gaim_im_update_typing(im);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
145 gaim_im_stop_typing_timeout(im);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
146
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
147 return FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
148 }
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3129
diff changeset
149
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
150 static gboolean
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
151 send_typed(gpointer data)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
152 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
153 struct gaim_conversation *conv = (struct gaim_conversation *)data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
154 struct gaim_connection *gc;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
155 const char *name;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
156
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
157 gc = gaim_conversation_get_gc(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
158 name = gaim_conversation_get_name(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
159
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
160 if (conv != NULL && gc != NULL && name != NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
161 gaim_im_set_type_again(GAIM_IM(conv), TRUE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
162
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
163 /* XXX Somebody add const stuff! */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
164 serv_send_typing(gc, (char *)name, TYPED);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
165
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
166 debug_printf("typed...\n");
573
9566a53cde23 [gaim-migrate @ 583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 570
diff changeset
167 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
168
2725
f3c094e78609 [gaim-migrate @ 2738]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2722
diff changeset
169 return FALSE;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
170 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
171
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
172 static void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
173 common_send(struct gaim_conversation *conv, const char *message)
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
174 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
175 GaimConversationType type;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
176 struct gaim_connection *gc;
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
177 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
178 char *buf, *buf2, *buffy;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
179 gulong length = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
180 gboolean binary = FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
181 int plugin_return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
182 int limit;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
183 int err = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
184 GList *first;
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
185
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
186 if ((gc = gaim_conversation_get_gc(conv)) == NULL)
3731
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
187 return;
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
188
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
189 type = gaim_conversation_get_type(conv);
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
190 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
191
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
192 limit = 32 * 1024; /* You shouldn't be sending more than 32K in your
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
193 messages. That's a book. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
194
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
195 buf = g_malloc(limit);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
196 strncpy(buf, message, limit);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
197
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
198 if (strlen(buf) == 0) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
199 g_free(buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
200
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
201 return;
3731
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
202 }
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
203
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
204 first = g_list_first(conv->send_history);
3731
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
205
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
206 if (first->data)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
207 g_free(first->data);
3731
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
208
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
209 first->data = g_strdup(buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
210
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
211 conv->send_history = g_list_prepend(first, NULL);
3731
d3592d407c9b [gaim-migrate @ 3869]
Sean Egan <seanegan@gmail.com>
parents: 3716
diff changeset
212
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
213 buf2 = g_malloc(limit);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
214
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
215 if (gc->flags & OPT_CONN_HTML) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
216 if (convo_options & OPT_CONVO_SEND_LINKS)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
217 linkify_text(buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
218 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
219
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
220 buffy = g_strdup(buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
221 plugin_return = plugin_event(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
222 (type == GAIM_CONV_IM ? event_im_send : event_chat_send),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
223 gc,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
224 (type == GAIM_CONV_IM
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
225 ? gaim_conversation_get_name(conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
226 : (void *)gaim_chat_get_id(GAIM_CHAT(conv))),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
227 &buffy);
1100
f168625b63fe [gaim-migrate @ 1110]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1078
diff changeset
228
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
229 if (buffy == NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
230 g_free(buf2);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
231 g_free(buf);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
232 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
233 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
234
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
235 if (plugin_return) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
236 g_free(buffy);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
237 g_free(buf2);
796
4783a3b6859d [gaim-migrate @ 806]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 795
diff changeset
238 g_free(buf);
4783a3b6859d [gaim-migrate @ 806]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 795
diff changeset
239 return;
4783a3b6859d [gaim-migrate @ 806]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 795
diff changeset
240 }
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
241
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
242 strncpy(buf, buffy, limit);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
243 g_free(buffy);
1441
5c67b8794991 [gaim-migrate @ 1451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1440
diff changeset
244
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
245 if (type == GAIM_CONV_IM) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
246 struct gaim_im *im = GAIM_IM(conv);
2102
899c22dcee42 [gaim-migrate @ 2112]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2094
diff changeset
247
899c22dcee42 [gaim-migrate @ 2112]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2094
diff changeset
248 buffy = g_strdup(buf);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
249 plugin_event(event_im_displayed_sent, gc,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
250 gaim_conversation_get_name(conv), &buffy);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
251
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
252 if (buffy != NULL) {
2231
8c4ff1a368bd [gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2227
diff changeset
253 int imflags = 0;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
254
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
255 if (conv->u.im->images != NULL) {
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4877
diff changeset
256 int id = 0, offset = 0;
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3129
diff changeset
257 char *bigbuf = NULL;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
258 GSList *tmplist;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
259
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
260 for (tmplist = conv->u.im->images;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
261 tmplist != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
262 tmplist = tmplist->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
263
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
264 char *img_filename = (char *)tmplist->data;
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
265 FILE *imgfile;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
266 char *filename, *c;
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
267 struct stat st;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
268 char imgtag[1024];
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
269
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4877
diff changeset
270 id++;
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4877
diff changeset
271
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
272 if (stat(img_filename, &st) != 0) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
273 debug_printf("Could not stat %s\n",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
274 (char *)img_filename);
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
275 continue;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
276 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
277
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
278 /*
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
279 * Here we check to make sure the user still wants to send
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
280 * the image. He may have deleted the <img> tag in which
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
281 * case we don't want to send the binary data.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
282 */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
283 filename = img_filename;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
284
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
285 while ((c = strchr(filename, '/')) != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
286 filename = c + 1;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
287
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
288 g_snprintf(imgtag, sizeof(imgtag),
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
289 "<IMG SRC=\"file://%s\" ID=\"%d\" "
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
290 "DATASIZE=\"%d\">",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
291 filename, id, (int)st.st_size);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
292
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
293 if (strstr(buffy, imgtag) == 0) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
294 debug_printf("Not sending image: %s\n", img_filename);
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
295 continue;
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
296 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
297
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
298 if (!binary) {
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
299 length = strlen(buffy) + strlen("<BINARY></BINARY>");
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
300 bigbuf = g_malloc(length + 1);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
301 g_snprintf(bigbuf,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
302 strlen(buffy) + strlen("<BINARY> ") + 1,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
303 "%s<BINARY>", buffy);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
304
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
305 offset = strlen(buffy) + strlen("<BINARY>");
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
306 binary = TRUE;
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
307 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
308
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
309 g_snprintf(imgtag, sizeof(imgtag),
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
310 "<DATA ID=\"%d\" SIZE=\"%d\">",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
311 id, (int)st.st_size);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
312
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
313 length += strlen(imgtag) + st.st_size + strlen("</DATA>");
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
314
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
315 bigbuf = g_realloc(bigbuf, length + 1);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
316
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
317 if ((imgfile = fopen(img_filename, "r")) == NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
318 debug_printf("Could not open %s\n", img_filename);
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
319 continue;
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
320 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
321
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
322 strncpy(bigbuf + offset, imgtag, strlen(imgtag) + 1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
323
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
324 offset += strlen(imgtag);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
325 offset += fread(bigbuf + offset, 1, st.st_size, imgfile);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
326
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
327 fclose(imgfile);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
328
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
329 strncpy(bigbuf + offset, "</DATA>",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
330 strlen("</DATA>") + 1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
331
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
332 offset += strlen("</DATA>");
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
333 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
334
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
335 if (binary) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
336 strncpy(bigbuf + offset, "</BINARY>",
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
337 strlen("<BINARY>") + 1);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
338
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
339 err = serv_send_im(gc,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
340 (char *)gaim_conversation_get_name(conv),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
341 bigbuf, length, imflags);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
342 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
343 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
344 err = serv_send_im(gc,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
345 (char *)gaim_conversation_get_name(conv),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
346 buffy, -1, imflags);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
347
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
348 if (err > 0) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
349 GSList *tempy;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
350
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
351 for (tempy = conv->u.im->images;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
352 tempy != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
353 tempy = tempy->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
354
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
355 g_free(tempy->data);
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
356 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
357
4895
9e50494f63a1 [gaim-migrate @ 5227]
Nathan Walp <nwalp@pidgin.im>
parents: 4877
diff changeset
358 g_slist_free(conv->u.im->images);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
359 conv->u.im->images = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
360
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
361 if (binary)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
362 gaim_im_write(im, NULL, bigbuf, length,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
363 WFLAG_SEND, time(NULL));
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
364 else
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
365 gaim_im_write(im, NULL, buffy, -1, WFLAG_SEND,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
366 time(NULL));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
367
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
368 if (im_options & OPT_IM_POPDOWN)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
369 gaim_window_hide(gaim_conversation_get_window(conv));
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
370 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
371
3048
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
372 if (binary)
e729c064bc1b [gaim-migrate @ 3061]
Sean Egan <seanegan@gmail.com>
parents: 3044
diff changeset
373 g_free(bigbuf);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
374 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
375 else {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
376 err = serv_send_im(gc, (char *)gaim_conversation_get_name(conv),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
377 buffy, -1, imflags);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
378
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
379 if (err > 0) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
380 gaim_im_write(im, NULL, buf, -1, WFLAG_SEND, time(NULL));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
381
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
382 if (im_options & OPT_IM_POPDOWN)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
383 gaim_window_hide(gaim_conversation_get_window(conv));
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
384 }
3033
1143524a2eaf [gaim-migrate @ 3046]
Sean Egan <seanegan@gmail.com>
parents: 3022
diff changeset
385 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
386
2102
899c22dcee42 [gaim-migrate @ 2112]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2094
diff changeset
387 g_free(buffy);
899c22dcee42 [gaim-migrate @ 2112]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2094
diff changeset
388 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
389 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
390 else {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
391 err = serv_chat_send(gc, gaim_chat_get_id(GAIM_CHAT(conv)), buf);
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
392 }
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
393
2123
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
394 g_free(buf2);
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
395 g_free(buf);
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
396
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
397 if (err < 0) {
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
398 if (err == -E2BIG)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
399 do_error_dialog(_("Unable to send message. "
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
400 "The message is too large."), NULL,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
401 GAIM_ERROR);
3044
e68e2ba82310 [gaim-migrate @ 3057]
Sean Egan <seanegan@gmail.com>
parents: 3035
diff changeset
402 else if (err == -ENOTCONN)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
403 debug_printf("Not yet connected.\n");
2123
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
404 else
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
405 do_error_dialog(_("Unable to send message."), NULL, GAIM_ERROR);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
406 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
407 else {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
408 if (err > 0 && (away_options & OPT_AWAY_BACK_ON_IM)) {
2123
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
409 if (awaymessage != NULL) {
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
410 do_im_back();
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
411 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
412 else if (gc->away) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
413 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL);
2123
56c4382f2909 [gaim-migrate @ 2133]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2111
diff changeset
414 }
1403
c0aa7fdc0a93 [gaim-migrate @ 1413]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1401
diff changeset
415 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
416 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
417
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
418 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
419
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
420 static void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
421 update_conv_indexes(struct gaim_window *win)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
422 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
423 GList *l;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
424 int i;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
425
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
426 for (l = gaim_window_get_conversations(win), i = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
427 l != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
428 l = l->next, i++) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
429
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
430 struct gaim_conversation *conv = (struct gaim_conversation *)l->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
431
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
432 conv->conversation_pos = i;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
433 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
434 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
435
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
436 struct gaim_window *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
437 gaim_window_new(void)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
438 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
439 struct gaim_window *win;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
440
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
441 win = g_malloc0(sizeof(struct gaim_window));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
442
4481
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
443 win->ui_ops = gaim_get_win_ui_ops();
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
444
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
445 if (win->ui_ops != NULL && win->ui_ops->new_window != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
446 win->ui_ops->new_window(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
447
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
448 windows = g_list_append(windows, win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
449
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
450 return win;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
451 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
452
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
453 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
454 gaim_window_destroy(struct gaim_window *win)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
455 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
456 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
457 GList *node;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
458
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
459 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
460 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
461
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
462 ops = gaim_window_get_ui_ops(win);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
463
4638
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
464 /*
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
465 * If there are any conversations in this, destroy them all. The last
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
466 * conversation will call gaim_window_destroy(), but this time, this
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
467 * check will fail and the window will actually be destroyed.
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
468 *
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
469 * This is needed because chats may not close right away. They may
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
470 * wait for notification first. When they get that, the window is
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
471 * already destroyed, and gaim either crashes or spits out gtk warnings.
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
472 * The problem is fixed with this check.
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
473 */
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
474 if (gaim_window_get_conversation_count(win) > 0) {
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
475
4647
ba87412b1a57 [gaim-migrate @ 4957]
Nathan Walp <nwalp@pidgin.im>
parents: 4638
diff changeset
476 node = g_list_first(gaim_window_get_conversations(win));
ba87412b1a57 [gaim-migrate @ 4957]
Nathan Walp <nwalp@pidgin.im>
parents: 4638
diff changeset
477 while(node != NULL)
4638
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
478 {
4647
ba87412b1a57 [gaim-migrate @ 4957]
Nathan Walp <nwalp@pidgin.im>
parents: 4638
diff changeset
479 struct gaim_conversation *conv = node->data;
ba87412b1a57 [gaim-migrate @ 4957]
Nathan Walp <nwalp@pidgin.im>
parents: 4638
diff changeset
480
ba87412b1a57 [gaim-migrate @ 4957]
Nathan Walp <nwalp@pidgin.im>
parents: 4638
diff changeset
481 node = g_list_next(node);
4638
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
482
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
483 gaim_conversation_destroy(conv);
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
484 }
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
485 }
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
486 else
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
487 {
4638
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
488 if (ops != NULL && ops->destroy_window != NULL)
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
489 ops->destroy_window(win);
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
490
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
491 g_list_free(gaim_window_get_conversations(win));
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
492
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
493 windows = g_list_remove(windows, win);
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
494
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
495 g_free(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
496 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
497 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
498
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
499 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
500 gaim_window_show(struct gaim_window *win)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
501 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
502 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
503
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
504 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
505 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
506
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
507 ops = gaim_window_get_ui_ops(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
508
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
509 if (ops == NULL || ops->show == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
510 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
511
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
512 ops->show(win);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
513 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
515 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
516 gaim_window_hide(struct gaim_window *win)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
517 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
518 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
519
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
520 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
521 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
522
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
523 ops = gaim_window_get_ui_ops(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
524
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
525 if (ops == NULL || ops->hide == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
526 return;
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
527
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
528 ops->hide(win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
529 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
530
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
531 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
532 gaim_window_raise(struct gaim_window *win)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
533 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
534 struct gaim_window_ui_ops *ops;
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
535
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
536 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
537 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
538
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
539 ops = gaim_window_get_ui_ops(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
540
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
541 if (ops == NULL || ops->raise == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
542 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
543
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
544 ops->raise(win);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
545 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
546
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
547 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
548 gaim_window_flash(struct gaim_window *win)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
549 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
550 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
551
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
552 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
553 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
554
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
555 ops = gaim_window_get_ui_ops(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
556
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
557 if (ops == NULL || ops->flash == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
558 return;
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
559
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
560 ops->flash(win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
561 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
562
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
563 void
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
564 gaim_window_set_ui_ops(struct gaim_window *win, struct gaim_window_ui_ops *ops)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
565 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
566 struct gaim_conversation_ui_ops *conv_ops = NULL;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
567 GList *l;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
568
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
569 if (win == NULL || win->ui_ops == ops)
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
570 return;
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
571
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
572 if (ops != NULL) {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
573 if (ops->get_conversation_ui_ops != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
574 conv_ops = ops->get_conversation_ui_ops();
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
575 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
576
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
577 if (win->ui_ops != NULL) {
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
578 if (win->ui_ops->destroy_window != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
579 win->ui_ops->destroy_window(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
580 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
581
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
582 win->ui_ops = ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
583
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
584 if (win->ui_ops != NULL) {
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
585 if (win->ui_ops->new_window != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
586 win->ui_ops->new_window(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
587 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
588
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
589 for (l = gaim_window_get_conversations(win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
590 l != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
591 l = l->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
592
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
593 struct gaim_conversation *conv = (struct gaim_conversation *)l;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
594
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
595 gaim_conversation_set_ui_ops(conv, conv_ops);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
596
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
597 if (win->ui_ops != NULL && win->ui_ops->add_conversation != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
598 win->ui_ops->add_conversation(win, conv);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
599 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
600 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
601
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
602 struct gaim_window_ui_ops *
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
603 gaim_window_get_ui_ops(const struct gaim_window *win)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
605 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
606 return NULL;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
608 return win->ui_ops;
858
3de6e98e8898 [gaim-migrate @ 868]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 856
diff changeset
609 }
3de6e98e8898 [gaim-migrate @ 868]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 856
diff changeset
610
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
611 int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
612 gaim_window_add_conversation(struct gaim_window *win,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
613 struct gaim_conversation *conv)
858
3de6e98e8898 [gaim-migrate @ 868]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 856
diff changeset
614 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
615 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
616
4369
7e1fb422e5fd [gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents: 4363
diff changeset
617 if (win == NULL || conv == NULL)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
618 return -1;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
619
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
620 if (gaim_conversation_get_window(conv) != NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
621 gaim_window_remove_conversation(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
622 gaim_conversation_get_window(conv),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
623 gaim_conversation_get_index(conv));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
624 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
625
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
626 ops = gaim_window_get_ui_ops(win);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
627
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
628 win->conversations = g_list_append(win->conversations, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
629 win->conversation_count++;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
630
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
631 conv->conversation_pos = win->conversation_count - 1;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
632
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
633 if (ops != NULL) {
4369
7e1fb422e5fd [gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents: 4363
diff changeset
634 conv->window = win;
7e1fb422e5fd [gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents: 4363
diff changeset
635
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
636 if (ops->get_conversation_ui_ops != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
637 gaim_conversation_set_ui_ops(conv, ops->get_conversation_ui_ops());
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
638
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
639 if (ops->add_conversation != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
640 ops->add_conversation(win, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
641 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
642
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
643 return win->conversation_count - 1;
234
985635758c33 [gaim-migrate @ 244]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 230
diff changeset
644 }
611
0f7e5ff95f71 [gaim-migrate @ 621]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 610
diff changeset
645
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
646 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
647 gaim_window_remove_conversation(struct gaim_window *win, unsigned int index)
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
648 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
649 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
650 struct gaim_conversation *conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
651 GList *node;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
652
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
653 if (win == NULL || index >= gaim_window_get_conversation_count(win))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
654 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
655
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
656 ops = gaim_window_get_ui_ops(win);
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
657
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
658 node = g_list_nth(gaim_window_get_conversations(win), index);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
659 conv = (struct gaim_conversation *)node->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
660
4360
c435a29370b8 [gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
661 if (ops != NULL && ops->remove_conversation != NULL)
c435a29370b8 [gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
662 ops->remove_conversation(win, conv);
c435a29370b8 [gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents: 4359
diff changeset
663
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
664 win->conversations = g_list_remove_link(win->conversations, node);
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
665
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
666 g_list_free_1(node);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
667
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
668 win->conversation_count--;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
669
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
670 conv->window = NULL;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
671
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
672 if (gaim_window_get_conversation_count(win) == 0)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
673 gaim_window_destroy(win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
674 else {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
675 /* Change all the indexes. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
676 update_conv_indexes(win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
677 }
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
678
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
679 return conv;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
680 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
681
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
682 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
683 gaim_window_move_conversation(struct gaim_window *win, unsigned int index,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
684 unsigned int new_index)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
685 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
686 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
687 struct gaim_conversation *conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
688 GList *l;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
689
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
690 if (win == NULL || index >= gaim_window_get_conversation_count(win) ||
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
691 index == new_index)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
692 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
693
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
694 /* We can't move this past the last index. */
4467
7d24d409d710 [gaim-migrate @ 4742]
Christian Hammond <chipx86@chipx86.com>
parents: 4465
diff changeset
695 if (new_index > gaim_window_get_conversation_count(win))
7d24d409d710 [gaim-migrate @ 4742]
Christian Hammond <chipx86@chipx86.com>
parents: 4465
diff changeset
696 new_index = gaim_window_get_conversation_count(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
697
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
698 /* Get the list item for this conversation at its current index. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
699 l = g_list_nth(gaim_window_get_conversations(win), index);
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
700
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
701 if (l == NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
702 /* Should never happen. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
703 debug_printf("Misordered conversations list in window %p\n", win);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
704
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
705 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
706 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
707
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
708 conv = (struct gaim_conversation *)l->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
709
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
710 /* Update the UI part of this. */
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
711 ops = gaim_window_get_ui_ops(win);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
712
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
713 if (ops != NULL && ops->move_conversation != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
714 ops->move_conversation(win, conv, new_index);
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
715
4415
c90039137172 [gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents: 4382
diff changeset
716 if (new_index > index)
c90039137172 [gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents: 4382
diff changeset
717 new_index--;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
718
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
719 /* Remove the old one. */
4415
c90039137172 [gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents: 4382
diff changeset
720 win->conversations = g_list_delete_link(win->conversations, l);
c90039137172 [gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents: 4382
diff changeset
721
c90039137172 [gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents: 4382
diff changeset
722 /* Insert it where it should go. */
c90039137172 [gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents: 4382
diff changeset
723 win->conversations = g_list_insert(win->conversations, conv, new_index);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
724
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
725 update_conv_indexes(win);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
726 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
727
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
728 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
729 gaim_window_get_conversation_at(const struct gaim_window *win,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
730 unsigned int index)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
731 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
732 if (win == NULL || index >= gaim_window_get_conversation_count(win))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
733 return NULL;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
734
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
735 return (struct gaim_conversation *)g_list_nth_data(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
736 gaim_window_get_conversations(win), index);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
737 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
738
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
739 size_t
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
740 gaim_window_get_conversation_count(const struct gaim_window *win)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
741 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
742 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
743 return 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
744
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
745 return win->conversation_count;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
746 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
747
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
748 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
749 gaim_window_switch_conversation(struct gaim_window *win, unsigned int index)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
750 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
751 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
752
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
753 if (win == NULL || index < 0 ||
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
754 index >= gaim_window_get_conversation_count(win))
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
755 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
756
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
757 ops = gaim_window_get_ui_ops(win);
3790
12b29552f1d7 [gaim-migrate @ 3930]
Rob Flynn <gaim@robflynn.com>
parents: 3789
diff changeset
758
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
759 if (ops != NULL && ops->switch_conversation != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
760 ops->switch_conversation(win, index);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
761
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
762 gaim_conversation_set_unseen(
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
763 gaim_window_get_conversation_at(win, index), 0);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
764 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
765
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
766 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
767 gaim_window_get_active_conversation(const struct gaim_window *win)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
768 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
769 struct gaim_window_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
770
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
771 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
772 return NULL;
206
610b7ffc4821 [gaim-migrate @ 216]
Rob Flynn <gaim@robflynn.com>
parents: 189
diff changeset
773
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
774 ops = gaim_window_get_ui_ops(win);
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
775
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
776 if (ops != NULL && ops->get_active_index != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
777 return gaim_window_get_conversation_at(win, ops->get_active_index(win));
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
778
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
779 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
780 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
781
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
782 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
783 gaim_window_get_conversations(const struct gaim_window *win)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
784 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
785 if (win == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
786 return NULL;
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
787
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
788 return win->conversations;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
789 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
790
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
791 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
792 gaim_get_windows(void)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
793 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
794 return windows;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
795 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
796
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
797 struct gaim_window *
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
798 gaim_get_first_window_with_type(GaimConversationType type)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
799 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
800 GList *wins, *convs;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
801 struct gaim_window *win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
802 struct gaim_conversation *conv;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
803
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
804 if (type == GAIM_CONV_UNKNOWN)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
805 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
806
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
807 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
808 win = (struct gaim_window *)wins->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
809
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
810 for (convs = gaim_window_get_conversations(win);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
811 convs != NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
812 convs = convs->next) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
813
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
814 conv = (struct gaim_conversation *)convs->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
815
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
816 if (gaim_conversation_get_type(conv) == type)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
817 return win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
818 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
819 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
820
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
821 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
822 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
823
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
824 struct gaim_window *
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
825 gaim_get_last_window_with_type(GaimConversationType type)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
826 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
827 GList *wins, *convs;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
828 struct gaim_window *win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
829 struct gaim_conversation *conv;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
830
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
831 if (type == GAIM_CONV_UNKNOWN)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
832 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
833
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
834 for (wins = g_list_last(gaim_get_windows());
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
835 wins != NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
836 wins = wins->prev) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
837
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
838 win = (struct gaim_window *)wins->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
839
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
840 for (convs = gaim_window_get_conversations(win);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
841 convs != NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
842 convs = convs->next) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
843
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
844 conv = (struct gaim_conversation *)convs->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
845
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
846 if (gaim_conversation_get_type(conv) == type)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
847 return win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
848 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
849 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
850
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
851 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
852 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
853
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
854 /**************************************************************************
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
855 * Conversation API
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
856 **************************************************************************/
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
857 struct gaim_conversation *
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
858 gaim_conversation_new(GaimConversationType type, struct gaim_account *account,
4476
62c1e5e656d0 [gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents: 4471
diff changeset
859 const char *name)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
860 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
861 struct gaim_conversation *conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
862
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
863 if (type == GAIM_CONV_UNKNOWN)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
864 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
865
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
866 /* Check if this conversation already exists. */
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
867 if ((conv = gaim_find_conversation_with_account(name, account)) != NULL)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
868 return conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
869
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
870 conv = g_malloc0(sizeof(struct gaim_conversation));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
871
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
872 conv->type = type;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
873 conv->account = account;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
874 conv->name = g_strdup(name);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
875 conv->title = g_strdup(name);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
876 conv->send_history = g_list_append(NULL, NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
877 conv->history = g_string_new("");
4877
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
878 conv->data = g_hash_table_new_full(g_str_hash, g_str_equal,
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
879 g_free, NULL);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
880
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
881 if (type == GAIM_CONV_IM)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
882 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
883 conv->u.im = g_malloc0(sizeof(struct gaim_im));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
884 conv->u.im->conv = conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
885
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
886 ims = g_list_append(ims, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
887
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
888 gaim_conversation_set_logging(conv,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
889 (logging_options & OPT_LOG_CONVOS));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
890 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
891 else if (type == GAIM_CONV_CHAT)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
892 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
893 conv->u.chat = g_malloc0(sizeof(struct gaim_chat));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
894 conv->u.chat->conv = conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
895
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
896 chats = g_list_append(chats, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
897
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
898 gaim_conversation_set_logging(conv, (logging_options & OPT_LOG_CHATS));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
899 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
900
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
901 conversations = g_list_append(conversations, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
902
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
903 /* Auto-set the title. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
904 gaim_conversation_autoset_title(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
905
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
906 /*
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
907 * Create a window if one does not exist. If it does, use the last
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
908 * created window.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
909 */
4818
1c371e4244d6 [gaim-migrate @ 5142]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
910 if (windows == NULL ||
1c371e4244d6 [gaim-migrate @ 5142]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
911 (type == GAIM_CONV_IM && !(im_options & OPT_IM_ONE_WINDOW)) ||
1c371e4244d6 [gaim-migrate @ 5142]
Nathan Walp <nwalp@pidgin.im>
parents: 4793
diff changeset
912 (type == GAIM_CONV_CHAT && !(chat_options & OPT_CHAT_ONE_WINDOW))) {
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
913 struct gaim_window *win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
914
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
915 win = gaim_window_new();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
916 gaim_window_add_conversation(win, conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
917
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
918 /* Ensure the window is visible. */
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
919 gaim_window_show(win);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
920 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
921 else {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
922 if (place_conv == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
923 gaim_conv_placement_set_active(0);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
924
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
925 place_conv(conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
926 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
927
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
928 plugin_event(event_new_conversation, name);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
929
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
930 return conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
931 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
932
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
933 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
934 gaim_conversation_destroy(struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
935 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
936 struct gaim_window *win;
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
937 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
938 struct gaim_connection *gc;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
939 const char *name;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
940 GList *node;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
941
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
942 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
943 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
944
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
945 win = gaim_conversation_get_window(conv);
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
946 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
947 gc = gaim_conversation_get_gc(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
948 name = gaim_conversation_get_name(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
949
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
950 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
951 if (!(misc_options & OPT_MISC_STEALTH_TYPING))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
952 serv_send_typing(gc, (char *)name, NOT_TYPING);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
953
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
954 if (gc && gc->prpl->convo_closed != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
955 gc->prpl->convo_closed(gc, (char *)name);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
956 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
957 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
958 /*
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
959 * This is unfortunately necessary, because calling serv_chat_leave()
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
960 * calls this gaim_conversation_destroy(), which leads to two calls
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
961 * here.. We can't just return after this, because then it'll return
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
962 * on the next pass. So, since serv_got_chat_left(), which is
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
963 * eventually called from the prpl that serv_chat_leave() calls,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
964 * removes this conversation from the gc's buddy_chats list, we're
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
965 * going to check to see if this exists in the list. If so, we want
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
966 * to return after calling this, because it'll be called again. If not,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
967 * fall through, because it'll have already been removed, and we'd
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
968 * be on the 2nd pass.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
969 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
970 * Long paragraph. <-- Short sentence.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
971 *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
972 * -- ChipX86
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
973 */
4638
b58c08b7cbe4 [gaim-migrate @ 4946]
Christian Hammond <chipx86@chipx86.com>
parents: 4622
diff changeset
974
4425
be8f9ca74ddf [gaim-migrate @ 4700]
Christian Hammond <chipx86@chipx86.com>
parents: 4415
diff changeset
975 if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
976 serv_chat_leave(gc, gaim_chat_get_id(GAIM_CHAT(conv)));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
977
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
978 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
979 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
980 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
981
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
982 plugin_event(event_del_conversation, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
983
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
984 if (conv->name != NULL) g_free(conv->name);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
985 if (conv->title != NULL) g_free(conv->title);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
986
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
987 for (node = g_list_first(conv->send_history);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
988 node != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
989 node = g_list_next(node)) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
990
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
991 if (node->data != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
992 g_free(node->data);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
993 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
994
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
995 g_list_free(g_list_first(conv->send_history));
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
996
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
997 if (conv->history != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
998 g_string_free(conv->history, TRUE);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
999
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1000 conversations = g_list_remove(conversations, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1001
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1002 if (conv->type == GAIM_CONV_IM) {
4574
57e939c91f72 [gaim-migrate @ 4855]
Christian Hammond <chipx86@chipx86.com>
parents: 4572
diff changeset
1003 GSList *snode;
57e939c91f72 [gaim-migrate @ 4855]
Christian Hammond <chipx86@chipx86.com>
parents: 4572
diff changeset
1004
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1005 gaim_im_stop_typing_timeout(conv->u.im);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1006 gaim_im_stop_type_again_timeout(conv->u.im);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1007
4574
57e939c91f72 [gaim-migrate @ 4855]
Christian Hammond <chipx86@chipx86.com>
parents: 4572
diff changeset
1008 for (snode = conv->u.im->images; snode != NULL; snode = snode->next) {
57e939c91f72 [gaim-migrate @ 4855]
Christian Hammond <chipx86@chipx86.com>
parents: 4572
diff changeset
1009 if (snode->data != NULL)
57e939c91f72 [gaim-migrate @ 4855]
Christian Hammond <chipx86@chipx86.com>
parents: 4572
diff changeset
1010 g_free(snode->data);
4572
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1011 }
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1012
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1013 g_slist_free(conv->u.im->images);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1014
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1015 g_free(conv->u.im);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1016
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1017 ims = g_list_remove(ims, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1018 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1019 else if (conv->type == GAIM_CONV_CHAT) {
4572
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1020
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1021 for (node = conv->u.chat->in_room; node != NULL; node = node->next) {
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1022 if (node->data != NULL)
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1023 g_free(node->data);
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1024 }
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1025
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1026 for (node = conv->u.chat->ignored; node != NULL; node = node->next) {
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1027 if (node->data != NULL)
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1028 g_free(node->data);
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1029 }
06084165a966 [gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents: 4522
diff changeset
1030
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1031 g_list_free(conv->u.chat->in_room);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1032 g_list_free(conv->u.chat->ignored);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1033
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1034 if (conv->u.chat->who != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1035 g_free(conv->u.chat->who);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1036
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1037 if (conv->u.chat->topic != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1038 g_free(conv->u.chat->topic);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1039
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1040 g_free(conv->u.chat);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1041
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1042 chats = g_list_remove(chats, conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1043 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1044
4877
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
1045 g_hash_table_destroy(conv->data);
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1046
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1047 if (win != NULL) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1048 gaim_window_remove_conversation(win,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1049 gaim_conversation_get_index(conv));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1050 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1051
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1052 if (ops != NULL && ops->destroy_conversation != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1053 ops->destroy_conversation(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1054
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1055 g_free(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1056 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1057
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1058 GaimConversationType
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1059 gaim_conversation_get_type(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1060 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1061 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1062 return GAIM_CONV_UNKNOWN;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1063
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1064 return conv->type;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1065 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1066
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1067 void
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1068 gaim_conversation_set_ui_ops(struct gaim_conversation *conv,
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1069 struct gaim_conversation_ui_ops *ops)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1070 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1071 if (conv == NULL || conv->ui_ops == ops)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1072 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1073
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1074 if (conv->ui_ops != NULL && conv->ui_ops->destroy_conversation != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1075 conv->ui_ops->destroy_conversation(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1076
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1077 conv->ui_data = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1078
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1079 conv->ui_ops = ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1080 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1081
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1082 struct gaim_conversation_ui_ops *
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1083 gaim_conversation_get_ui_ops(struct gaim_conversation *conv)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1084 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1085 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1086 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1087
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1088 return conv->ui_ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1089 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1090
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1091 void
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1092 gaim_conversation_set_account(struct gaim_conversation *conv,
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1093 struct gaim_account *account)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1094 {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1095 if (conv == NULL || account == gaim_conversation_get_account(conv))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1096 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1097
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1098 conv->account = account;
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1099
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1100 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1101 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1102
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1103 struct gaim_account *
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1104 gaim_conversation_get_account(const struct gaim_conversation *conv)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1105 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1106 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1107 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1108
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1109 return conv->account;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1110 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1111
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1112 struct gaim_connection *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1113 gaim_conversation_get_gc(const struct gaim_conversation *conv)
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1114 {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1115 struct gaim_account *account;
4425
be8f9ca74ddf [gaim-migrate @ 4700]
Christian Hammond <chipx86@chipx86.com>
parents: 4415
diff changeset
1116
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1117 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1118 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1119
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1120 account = gaim_conversation_get_account(conv);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1121
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1122 if (account == NULL)
4425
be8f9ca74ddf [gaim-migrate @ 4700]
Christian Hammond <chipx86@chipx86.com>
parents: 4415
diff changeset
1123 return NULL;
be8f9ca74ddf [gaim-migrate @ 4700]
Christian Hammond <chipx86@chipx86.com>
parents: 4415
diff changeset
1124
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1125 return account->gc;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1126 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1127
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1128 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1129 gaim_conversation_set_title(struct gaim_conversation *conv, const char *title)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1130 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1131 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1132
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1133 if (conv == NULL || title == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1134 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1135
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1136 if (conv->title != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1137 g_free(conv->title);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1138
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1139 conv->title = g_strdup(title);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1140
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1141 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1142
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1143 if (ops != NULL && ops->set_title != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1144 ops->set_title(conv, conv->title);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1145 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1146
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1147 const char *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1148 gaim_conversation_get_title(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1149 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1150 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1151 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1152
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1153 return conv->title;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1154 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1155
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1156 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1157 gaim_conversation_autoset_title(struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1158 {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1159 struct gaim_account *account;
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 738
diff changeset
1160 struct buddy *b;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1161 const char *text, *name;
3799
3163a8825063 [gaim-migrate @ 3941]
Luke Schierer <lschiere@pidgin.im>
parents: 3790
diff changeset
1162
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1163 if (conv == NULL)
2267
837aa71710c5 [gaim-migrate @ 2277]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2264
diff changeset
1164 return;
837aa71710c5 [gaim-migrate @ 2277]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2264
diff changeset
1165
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1166 account = gaim_conversation_get_account(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1167 name = gaim_conversation_get_name(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1168
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1169 if (((im_options & OPT_IM_ALIAS_TAB) == OPT_IM_ALIAS_TAB) &&
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1170 account != NULL && ((b = gaim_find_buddy(account, name)) != NULL)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1171
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1172 text = gaim_get_buddy_alias(b);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1173 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1174 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1175 text = name;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1176
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1177 gaim_conversation_set_title(conv, text);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1178 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1179
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1180 int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1181 gaim_conversation_get_index(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1182 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1183 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1184 return 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1185
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1186 return conv->conversation_pos;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1187 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1188
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1189 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1190 gaim_conversation_set_unseen(struct gaim_conversation *conv,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1191 GaimUnseenState state)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1192 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1193 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1194 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1195
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1196 conv->unseen = state;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1197
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1198 gaim_conversation_update(conv, GAIM_CONV_UPDATE_UNSEEN);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1199 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1200
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1201 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1202 gaim_conversation_foreach(void (*func)(struct gaim_conversation *conv))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1203 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1204 struct gaim_conversation *conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1205 GList *l;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1206
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1207 if (func == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1208 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1209
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1210 for (l = gaim_get_conversations(); l != NULL; l = l->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1211 conv = (struct gaim_conversation *)l->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1212
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1213 func(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1214 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1215 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1216
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1217 GaimUnseenState
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1218 gaim_conversation_get_unseen(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1219 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1220 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1221 return 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1222
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1223 return conv->unseen;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1224 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1225
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1226 const char *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1227 gaim_conversation_get_name(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1228 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1229 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1230 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1231
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1232 return conv->name;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1233 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1234
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1235 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1236 gaim_conversation_set_logging(struct gaim_conversation *conv, gboolean log)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1237 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1238 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1239 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1240
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1241 conv->logging = log;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1242
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1243 gaim_conversation_update(conv, GAIM_CONV_UPDATE_LOGGING);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1244 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1245
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1246 gboolean
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1247 gaim_conversation_is_logging(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1248 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1249 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1250 return FALSE;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1251
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1252 return conv->logging;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1253 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1254
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1255 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1256 gaim_conversation_get_send_history(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1257 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1258 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1259 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1260
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1261 return conv->send_history;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1262 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1263
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1264 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1265 gaim_conversation_set_history(struct gaim_conversation *conv,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1266 GString *history)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1267 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1268 if (conv == NULL)
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2426
diff changeset
1269 return;
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
1270
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1271 conv->history = history;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1272 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1273
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1274 GString *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1275 gaim_conversation_get_history(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1276 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1277 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1278 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1279
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1280 return conv->history;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1281 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1282
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1283 struct gaim_window *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1284 gaim_conversation_get_window(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1285 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1286 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1287 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1288
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1289 return conv->window;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1290 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1291
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1292 struct gaim_im *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1293 gaim_conversation_get_im_data(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1294 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1295 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1296 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1297
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1298 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1299 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1300
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1301 return conv->u.im;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1302 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1303
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1304 struct gaim_chat *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1305 gaim_conversation_get_chat_data(const struct gaim_conversation *conv)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1306 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1307 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1308 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1309
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1310 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1311 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1312
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1313 return conv->u.chat;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1314 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1315
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1316 void
4877
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
1317 gaim_conversation_set_data(struct gaim_conversation *conv, const char *key,
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
1318 gpointer data)
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1319 {
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1320 if (conv == NULL || key == NULL)
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1321 return;
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1322
4877
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
1323 g_hash_table_replace(conv->data, g_strdup(key), data);
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1324 }
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1325
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1326 gpointer
4877
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
1327 gaim_conversation_get_data(struct gaim_conversation *conv, const char *key)
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1328 {
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1329 if (conv == NULL || key == NULL)
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1330 return NULL;
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1331
4877
249382064693 [gaim-migrate @ 5207]
Christian Hammond <chipx86@chipx86.com>
parents: 4876
diff changeset
1332 return g_hash_table_lookup(conv->data, key);
4876
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1333 }
9567b13d0e98 [gaim-migrate @ 5206]
Christian Hammond <chipx86@chipx86.com>
parents: 4818
diff changeset
1334
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1335 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1336 gaim_get_conversations(void)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1337 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1338 return conversations;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1339 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1340
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1341 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1342 gaim_get_ims(void)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1343 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1344 return ims;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1345 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1346
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1347 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1348 gaim_get_chats(void)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1349 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1350 return chats;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1351 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1352
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1353 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1354 gaim_find_conversation(const char *name)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1355 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1356 struct gaim_conversation *c = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1357 char *cuser;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1358 GList *cnv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1360 if (name == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1361 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1362
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1363 cuser = g_strdup(normalize(name));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1364
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1365 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1366 c = (struct gaim_conversation *)cnv->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1367
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1368 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1369 break;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1370
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1371 c = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1372 }
2794
2d3f47783a22 [gaim-migrate @ 2807]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2788
diff changeset
1373
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1374 g_free(cuser);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1375
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1376 return c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1377 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1378
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1379 struct gaim_conversation *
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1380 gaim_find_conversation_with_account(const char *name, const struct gaim_account *account)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1381 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1382 struct gaim_conversation *c = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1383 char *cuser;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1384 GList *cnv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1385
4476
62c1e5e656d0 [gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents: 4471
diff changeset
1386 if (name == NULL)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1387 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1388
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1389 cuser = g_strdup(normalize(name));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1390
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1391 for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1392 c = (struct gaim_conversation *)cnv->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1393
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1394 if (!gaim_utf8_strcasecmp(cuser, normalize(gaim_conversation_get_name(c))) &&
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4481
diff changeset
1395 account == gaim_conversation_get_account(c)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1396
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1397 break;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1398 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1399
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1400 c = NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1401 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1402
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1403 g_free(cuser);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1404
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1405 return c;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1406 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1407
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1408 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1409 gaim_conversation_write(struct gaim_conversation *conv, const char *who,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1410 const char *message, size_t length, int flags,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1411 time_t mtime)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1412 {
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1413 struct gaim_account *account;
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1414 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1415 struct gaim_window *win;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1416 struct buddy *b;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1417 GaimUnseenState unseen;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1418 /* int logging_font_options = 0; */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1419
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1420 if (conv == NULL || message == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1421 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1422
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1423 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1424
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1425 if (ops == NULL || ops->write_conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1426 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1427
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1428 account = gaim_conversation_get_account(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1429
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1430 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT &&
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1431 (account->gc == NULL || !g_slist_find(account->gc->buddy_chats, conv)))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1432 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1433
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1434 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1435 !g_list_find(gaim_get_conversations(), conv))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1436 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1437
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1438 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM ||
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1439 !(account->gc->prpl->options & OPT_PROTO_UNIQUE_CHATNAME)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1440
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1441 if (who == NULL) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1442 if (flags & WFLAG_SEND) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1443 b = gaim_find_buddy(account, account->gc->username);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1444 if (b != NULL && strcmp(b->name, gaim_get_buddy_alias(b)))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1445 who = gaim_get_buddy_alias(b);
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1446 else if (*account->alias)
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1447 who = account->alias;
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1448 else if (*account->gc->displayname)
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1449 who = account->gc->displayname;
1772
896432d66303 [gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1764
diff changeset
1450 else
4608
5fcb44d771d2 [gaim-migrate @ 4896]
Nathan Walp <nwalp@pidgin.im>
parents: 4574
diff changeset
1451 who = account->gc->username;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1452 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1453 else {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1454 b = gaim_find_buddy(account, gaim_conversation_get_name(conv));
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1455
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1456 if (b != NULL)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1457 who = gaim_get_buddy_alias(b);
1772
896432d66303 [gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1764
diff changeset
1458 else
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1459 who = gaim_conversation_get_name(conv);
1772
896432d66303 [gaim-migrate @ 1782]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1764
diff changeset
1460 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1461 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1462 else {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1463 b = gaim_find_buddy(account, who);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1464
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1465 if (b != NULL)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
1466 who = gaim_get_buddy_alias(b);
741
58a6e6e26695 [gaim-migrate @ 751]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 738
diff changeset
1467 }
474
7720d0f9da8e [gaim-migrate @ 484]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 473
diff changeset
1468 }
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
1469
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1470 ops->write_conv(conv, who, message, length, flags, mtime);
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2363
diff changeset
1471
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1472 win = gaim_conversation_get_window(conv);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1473
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1474 if (!(flags & WFLAG_NOLOG) &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1475 ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1476 (chat_options & OPT_CHAT_POPUP)) ||
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1477 (gaim_conversation_get_type(conv) == GAIM_CONV_IM &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1478 (im_options & OPT_IM_POPUP)))) {
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1479
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1480 gaim_window_show(win);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1481 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1482
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1483 /* Tab highlighting */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1484 if (!(flags & WFLAG_RECV) && !(flags & WFLAG_SYSTEM))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1485 return;
1479
4c62ead808a2 [gaim-migrate @ 1489]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1464
diff changeset
1486
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1487 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1488 if ((flags & WFLAG_RECV) == WFLAG_RECV)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1489 gaim_im_set_typing_state(GAIM_IM(conv), NOT_TYPING);
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
1490 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1491
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1492 if (gaim_window_get_active_conversation(win) != conv) {
4616
767093a2ddaf [gaim-migrate @ 4907]
Nathan Walp <nwalp@pidgin.im>
parents: 4608
diff changeset
1493 if ((flags & WFLAG_NICK) == WFLAG_NICK ||
767093a2ddaf [gaim-migrate @ 4907]
Nathan Walp <nwalp@pidgin.im>
parents: 4608
diff changeset
1494 gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1495 unseen = GAIM_UNSEEN_NICK;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1496 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1497 unseen = GAIM_UNSEEN_TEXT;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1498 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1499 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1500 unseen = GAIM_UNSEEN_NONE;
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1501
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1502 gaim_conversation_set_unseen(conv, unseen);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1503 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1504
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1505 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1506 gaim_conversation_update_progress(struct gaim_conversation *conv,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1507 float percent)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1508 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1509 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1510
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1511 if (conv == NULL)
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
1512 return;
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
1513
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1514 if (percent < 0)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1515 percent = 0;
3768
f53370197bb9 [gaim-migrate @ 3907]
Sean Egan <seanegan@gmail.com>
parents: 3763
diff changeset
1516
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1517 /*
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1518 * NOTE: A percent >= 1 indicates that the progress bar should be
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1519 * closed.
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1520 */
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1521 ops = gaim_conversation_get_ui_ops(conv);
3768
f53370197bb9 [gaim-migrate @ 3907]
Sean Egan <seanegan@gmail.com>
parents: 3763
diff changeset
1522
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1523 if (ops != NULL && ops->update_progress != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1524 ops->update_progress(conv, percent);
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1525 }
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1526
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1527 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1528 gaim_conversation_update(struct gaim_conversation *conv,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1529 GaimConvUpdateType type)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1530 {
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1531 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1532
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1533 if (conv == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1534 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1535
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1536 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1537
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1538 if (ops != NULL && ops->updated != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1539 ops->updated(conv, type);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1540 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1541
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1542 /**************************************************************************
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1543 * IM Conversation API
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1544 **************************************************************************/
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1545 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1546 gaim_im_get_conversation(struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1547 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1548 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1549 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1550
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1551 return im->conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1552 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1553
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1554 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1555 gaim_im_set_typing_state(struct gaim_im *im, int state)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1556 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1557 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1558 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1559
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1560 im->typing_state = state;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1561 }
66
eb2151d7e88a [gaim-migrate @ 76]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1562
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1563 int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1564 gaim_im_get_typing_state(const struct gaim_im *im)
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1565 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1566 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1567 return 0;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1568
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1569 return im->typing_state;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1570 }
3704
04a911e7dfc9 [gaim-migrate @ 3835]
Rob Flynn <gaim@robflynn.com>
parents: 3699
diff changeset
1571
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1572 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1573 gaim_im_start_typing_timeout(struct gaim_im *im, int timeout)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1574 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1575 struct gaim_conversation *conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1576 const char *name;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1577
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1578 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1579 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1580
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1581 if (im->typing_timeout > 0)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1582 gaim_im_stop_typing_timeout(im);
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1583
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1584 conv = gaim_im_get_conversation(im);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1585 name = gaim_conversation_get_name(conv);
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1586
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1587 im->typing_timeout = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1588 timeout * 1000, reset_typing, g_strdup(name), g_free);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1589 }
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1590
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1591 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1592 gaim_im_stop_typing_timeout(struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1593 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1594 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1595 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1596
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1597 if (im->typing_timeout == 0)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1598 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1599
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1600 g_source_remove(im->typing_timeout);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1601 im->typing_timeout = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1602 }
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1603
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1604 guint
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1605 gaim_im_get_typing_timeout(const struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1606 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1607 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1608 return 0;
3699
b401bd1701b4 [gaim-migrate @ 3830]
Rob Flynn <gaim@robflynn.com>
parents: 3696
diff changeset
1609
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1610 return im->typing_timeout;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1611 }
3699
b401bd1701b4 [gaim-migrate @ 3830]
Rob Flynn <gaim@robflynn.com>
parents: 3696
diff changeset
1612
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1613 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1614 gaim_im_set_type_again(struct gaim_im *im, time_t val)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1615 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1616 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1617 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1618
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1619 im->type_again = val;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1620 }
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1621
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1622 time_t
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1623 gaim_im_get_type_again(const struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1624 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1625 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1626 return 0;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1627
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1628 return im->type_again;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1629 }
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1630
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1631 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1632 gaim_im_start_type_again_timeout(struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1633 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1634 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1635 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1636
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1637 im->type_again_timeout = g_timeout_add(SEND_TYPED_TIMEOUT, send_typed,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1638 gaim_im_get_conversation(im));
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1639 }
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1640
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1641 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1642 gaim_im_stop_type_again_timeout(struct gaim_im *im)
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1643 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1644 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1645 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1646
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1647 if (im->type_again_timeout == 0)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1648 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1649
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1650 g_source_remove(im->type_again_timeout);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1651 im->type_again_timeout = 0;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1652 }
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1653
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1654 guint
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1655 gaim_im_get_type_again_timeout(const struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1656 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1657 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1658 return 0;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1659
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1660 return im->type_again_timeout;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1661 }
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1662
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1663 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1664 gaim_im_update_typing(struct gaim_im *im)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1665 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1666 if (im == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1667 return;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1668
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1669 gaim_conversation_update(gaim_im_get_conversation(im),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1670 GAIM_CONV_UPDATE_TYPING);
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1671 }
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1672
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1673 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1674 gaim_im_write(struct gaim_im *im, const char *who, const char *message,
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1675 size_t len, int flags, time_t mtime)
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1676 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1677 struct gaim_conversation *c;
1898
73d73939f698 [gaim-migrate @ 1908]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1889
diff changeset
1678
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1679 if (im == NULL || message == NULL)
1898
73d73939f698 [gaim-migrate @ 1908]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1889
diff changeset
1680 return;
73d73939f698 [gaim-migrate @ 1908]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1889
diff changeset
1681
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1682 c = gaim_im_get_conversation(im);
2787
feea7103a235 [gaim-migrate @ 2800]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
1683
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1684 /* Raise the window, if specified in prefs. */
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1685 if (!(flags & WFLAG_NOLOG) & (im_options & OPT_IM_POPUP))
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1686 gaim_window_raise(gaim_conversation_get_window(c));
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1687
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1688 if (c->ui_ops != NULL && c->ui_ops->write_im != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1689 c->ui_ops->write_im(c, who, message, len, flags, mtime);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1690 else
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1691 gaim_conversation_write(c, who, message, -1, flags, mtime);
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1692 }
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1693
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1694 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1695 gaim_im_send(struct gaim_im *im, const char *message)
2379
cacaf7ace3a5 [gaim-migrate @ 2392]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2375
diff changeset
1696 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1697 if (im == NULL || message == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1698 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1699
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1700 common_send(gaim_im_get_conversation(im), message);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1701 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1702
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1703 /**************************************************************************
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1704 * Chat Conversation API
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1705 **************************************************************************/
2379
cacaf7ace3a5 [gaim-migrate @ 2392]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2375
diff changeset
1706
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1707 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1708 gaim_chat_get_conversation(struct gaim_chat *chat)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1709 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1710 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1711 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1712
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1713 return chat->conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1714 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1715
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1716 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1717 gaim_chat_set_users(struct gaim_chat *chat, GList *users)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1718 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1719 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1720 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1721
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1722 chat->in_room = users;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1723
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1724 return users;
2379
cacaf7ace3a5 [gaim-migrate @ 2392]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2375
diff changeset
1725 }
cacaf7ace3a5 [gaim-migrate @ 2392]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2375
diff changeset
1726
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1727 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1728 gaim_chat_get_users(const struct gaim_chat *chat)
1030
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1002
diff changeset
1729 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1730 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1731 return NULL;
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
1732
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1733 return chat->in_room;
1030
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1002
diff changeset
1734 }
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1002
diff changeset
1735
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1736 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1737 gaim_chat_ignore(struct gaim_chat *chat, const char *name)
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1738 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1739 if (chat == NULL || name == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1740 return;
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1741
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1742 /* Make sure the user isn't already ignored. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1743 if (gaim_chat_is_user_ignored(chat, name))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1744 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1745
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1746 gaim_chat_set_ignored(chat,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1747 g_list_append(gaim_chat_get_ignored(chat), g_strdup(name)));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1748 }
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1749
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1750 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1751 gaim_chat_unignore(struct gaim_chat *chat, const char *name)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1752 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1753 GList *item;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1754
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1755 if (chat == NULL || name == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1756 return;
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1757
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1758 /* Make sure the user is actually ignored. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1759 if (!gaim_chat_is_user_ignored(chat, name))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1760 return;
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1761
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1762 item = g_list_find(gaim_chat_get_ignored(chat),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1763 gaim_chat_get_ignored_user(chat, name));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1764
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1765 gaim_chat_set_ignored(chat,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1766 g_list_remove_link(gaim_chat_get_ignored(chat), item));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1767
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1768 g_free(item->data);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1769 g_list_free_1(item);
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1770 }
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1771
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1772 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1773 gaim_chat_set_ignored(struct gaim_chat *chat, GList *ignored)
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1774 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1775 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1776 return NULL;
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1777
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1778 chat->ignored = ignored;
993
eacd93d0089a [gaim-migrate @ 1003]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 980
diff changeset
1779
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1780 return ignored;
2111
109669b3887e [gaim-migrate @ 2121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2109
diff changeset
1781 }
109669b3887e [gaim-migrate @ 2121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2109
diff changeset
1782
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1783 GList *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1784 gaim_chat_get_ignored(const struct gaim_chat *chat)
2111
109669b3887e [gaim-migrate @ 2121]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2109
diff changeset
1785 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1786 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1787 return NULL;
1898
73d73939f698 [gaim-migrate @ 1908]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1889
diff changeset
1788
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1789 return chat->ignored;
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1790 }
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
1791
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1792 const char *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1793 gaim_chat_get_ignored_user(const struct gaim_chat *chat, const char *user)
1340
1526caa87138 [gaim-migrate @ 1350]
Rob Flynn <gaim@robflynn.com>
parents: 1253
diff changeset
1794 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1795 GList *ignored;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1796
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1797 if (chat == NULL || user == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1798 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1799
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1800 for (ignored = gaim_chat_get_ignored(chat);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1801 ignored != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1802 ignored = ignored->next) {
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2363
diff changeset
1803
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1804 const char *ign = (const char *)ignored->data;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1805
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1806 if (!gaim_utf8_strcasecmp(user, ign) ||
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1807 ((*ign == '+' || *ign == '%') && !gaim_utf8_strcasecmp(user, ign + 1)))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1808 return ign;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1809
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1810 if (*ign == '@') {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1811 ign++;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1812
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1813 if ((*ign == '+' && !gaim_utf8_strcasecmp(user, ign + 1)) ||
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1814 (*ign != '+' && !gaim_utf8_strcasecmp(user, ign)))
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1815 return ign;
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1816 }
2094
be10a1243ed7 [gaim-migrate @ 2104]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2090
diff changeset
1817 }
1341
6ec45c45157c [gaim-migrate @ 1351]
Rob Flynn <gaim@robflynn.com>
parents: 1340
diff changeset
1818
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1819 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1820 }
1341
6ec45c45157c [gaim-migrate @ 1351]
Rob Flynn <gaim@robflynn.com>
parents: 1340
diff changeset
1821
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1822 gboolean
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1823 gaim_chat_is_user_ignored(const struct gaim_chat *chat, const char *user)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1824 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1825 if (chat == NULL || user == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1826 return FALSE;
1341
6ec45c45157c [gaim-migrate @ 1351]
Rob Flynn <gaim@robflynn.com>
parents: 1340
diff changeset
1827
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1828 return (gaim_chat_get_ignored_user(chat, user) != NULL);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1829 }
1343
a0d89bdc733e [gaim-migrate @ 1353]
Rob Flynn <gaim@robflynn.com>
parents: 1342
diff changeset
1830
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1831 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1832 gaim_chat_set_topic(struct gaim_chat *chat, const char *who, const char *topic)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1833 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1834 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1835 return;
1343
a0d89bdc733e [gaim-migrate @ 1353]
Rob Flynn <gaim@robflynn.com>
parents: 1342
diff changeset
1836
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1837 if (chat->who != NULL) free(chat->who);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1838 if (chat->topic != NULL) free(chat->topic);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1839
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1840 chat->who = (who == NULL ? NULL : g_strdup(who));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1841 chat->topic = (topic == NULL ? NULL : g_strdup(topic));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1842
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1843 gaim_conversation_update(gaim_chat_get_conversation(chat),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1844 GAIM_CONV_UPDATE_TOPIC);
1340
1526caa87138 [gaim-migrate @ 1350]
Rob Flynn <gaim@robflynn.com>
parents: 1253
diff changeset
1845 }
1526caa87138 [gaim-migrate @ 1350]
Rob Flynn <gaim@robflynn.com>
parents: 1253
diff changeset
1846
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1847 const char *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1848 gaim_chat_get_topic(const struct gaim_chat *chat)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1849 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1850 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1851 return NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1852
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1853 return chat->topic;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1854 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1855
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1856 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1857 gaim_chat_set_id(struct gaim_chat *chat, int id)
1573
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
1858 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1859 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1860 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1861
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1862 chat->id = id;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1863 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1864
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1865 int
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1866 gaim_chat_get_id(const struct gaim_chat *chat)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1867 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1868 if (chat == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1869 return -1;
3951
32942c49dced [gaim-migrate @ 4132]
Luke Schierer <lschiere@pidgin.im>
parents: 3925
diff changeset
1870
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1871 return chat->id;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1872 }
3951
32942c49dced [gaim-migrate @ 4132]
Luke Schierer <lschiere@pidgin.im>
parents: 3925
diff changeset
1873
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1874 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1875 gaim_chat_write(struct gaim_chat *chat, const char *who,
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1876 const char *message, int flags, time_t mtime)
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1877 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1878 struct gaim_conversation *conv;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1879 struct gaim_connection *gc;
3866
994b5c4d15dd [gaim-migrate @ 4018]
Rob Flynn <gaim@robflynn.com>
parents: 3846
diff changeset
1880
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1881 if (chat == NULL || who == NULL || message == NULL)
3866
994b5c4d15dd [gaim-migrate @ 4018]
Rob Flynn <gaim@robflynn.com>
parents: 3846
diff changeset
1882 return;
994b5c4d15dd [gaim-migrate @ 4018]
Rob Flynn <gaim@robflynn.com>
parents: 3846
diff changeset
1883
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1884 conv = gaim_chat_get_conversation(chat);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1885 gc = gaim_conversation_get_gc(conv);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1886
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1887 /* Don't display this if the person who wrote it is ignored. */
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1888 if (gaim_chat_is_user_ignored(chat, who))
1573
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
1889 return;
3677
7571943d6851 [gaim-migrate @ 3807]
Rob Flynn <gaim@robflynn.com>
parents: 3671
diff changeset
1890
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1891 /* Raise the window, if specified in prefs. */
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1892 if (!(flags & WFLAG_NOLOG) & (chat_options & OPT_CHAT_POPUP))
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1893 gaim_window_raise(gaim_conversation_get_window(conv));
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1894
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1895 if (!(flags & WFLAG_WHISPER)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1896 char *str;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1897
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1898 str = g_strdup(normalize(who));
3677
7571943d6851 [gaim-migrate @ 3807]
Rob Flynn <gaim@robflynn.com>
parents: 3671
diff changeset
1899
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1900 if (!gaim_utf8_strcasecmp(str, normalize(gc->username)) ||
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1901 !gaim_utf8_strcasecmp(str, normalize(gc->displayname))) {
3683
e3583f15dfe0 [gaim-migrate @ 3813]
Rob Flynn <gaim@robflynn.com>
parents: 3682
diff changeset
1902
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1903 flags |= WFLAG_SEND;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1904 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1905 else {
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1906 flags |= WFLAG_RECV;
3677
7571943d6851 [gaim-migrate @ 3807]
Rob Flynn <gaim@robflynn.com>
parents: 3671
diff changeset
1907
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1908 if (find_nick(gc, message))
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1909 flags |= WFLAG_NICK;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1910 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1911
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1912 g_free(str);
3677
7571943d6851 [gaim-migrate @ 3807]
Rob Flynn <gaim@robflynn.com>
parents: 3671
diff changeset
1913 }
3705
91498932cea7 [gaim-migrate @ 3838]
Luke Schierer <lschiere@pidgin.im>
parents: 3704
diff changeset
1914
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1915 /* Pass this on to either the ops structure or the default write func. */
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1916 if (conv->ui_ops != NULL && conv->ui_ops->write_chat != NULL)
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1917 conv->ui_ops->write_chat(conv, who, message, flags, mtime);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1918 else
4382
76223649765b [gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents: 4378
diff changeset
1919 gaim_conversation_write(conv, who, message, -1, flags, mtime);
1573
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
1920 }
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
1921
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1922 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1923 gaim_chat_send(struct gaim_chat *chat, const char *message)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1924 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1925 if (chat == NULL || message == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1926 return;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1927
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1928 common_send(gaim_chat_get_conversation(chat), message);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1929 }
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1930
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1931 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1932 gaim_chat_add_user(struct gaim_chat *chat, const char *user,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1933 const char *extra_msg)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1934 {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1935 struct gaim_conversation *conv;
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1936 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1937 char tmp[BUF_LONG];
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1938
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1939 if (chat == NULL || user == NULL)
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1940 return;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1941
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1942 conv = gaim_chat_get_conversation(chat);
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1943 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1944
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1945 gaim_chat_set_users(chat,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1946 g_list_insert_sorted(gaim_chat_get_users(chat), g_strdup(user),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1947 insertname_compare));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1948
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1949 plugin_event(event_chat_buddy_join,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1950 gaim_conversation_get_gc(conv), gaim_chat_get_id(chat),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1951 user);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1952
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1953 if (ops != NULL && ops->chat_add_user != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1954 ops->chat_add_user(conv, user);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1955
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1956 if (chat_options & OPT_CHAT_LOGON) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1957 if (extra_msg == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1958 g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1959 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1960 g_snprintf(tmp, sizeof(tmp),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1961 _("%s [<I>%s</I>] entered the room."),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1962 user, extra_msg);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1963
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1964 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL));
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1965 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1966 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1967
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1968 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1969 gaim_chat_rename_user(struct gaim_chat *chat, const char *old_user,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1970 const char *new_user)
472
6a92cd7322cc [gaim-migrate @ 482]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 411
diff changeset
1971 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1972 struct gaim_conversation *conv;
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1973 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1974 char tmp[BUF_LONG];
4506
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1975 GList *names;
3866
994b5c4d15dd [gaim-migrate @ 4018]
Rob Flynn <gaim@robflynn.com>
parents: 3846
diff changeset
1976
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1977 if (chat == NULL || old_user == NULL || new_user == NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1978 return;
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 936
diff changeset
1979
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1980 conv = gaim_chat_get_conversation(chat);
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
1981 ops = gaim_conversation_get_ui_ops(conv);
3304
7c5325f460de [gaim-migrate @ 3322]
Sean Egan <seanegan@gmail.com>
parents: 3300
diff changeset
1982
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1983 gaim_chat_set_users(chat,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1984 g_list_insert_sorted(gaim_chat_get_users(chat), g_strdup(new_user),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1985 insertname_compare));
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1986
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1987 if (ops != NULL && ops->chat_rename_user != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
1988 ops->chat_rename_user(conv, old_user, new_user);
3671
0f468c22c702 [gaim-migrate @ 3801]
Rob Flynn <gaim@robflynn.com>
parents: 3641
diff changeset
1989
4506
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1990 for (names = gaim_chat_get_users(chat);
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1991 names != NULL;
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1992 names = names->next) {
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1993
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
1994 if (!gaim_utf8_strcasecmp((char *)names->data, old_user)) {
4506
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1995 gaim_chat_set_users(chat,
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1996 g_list_remove(gaim_chat_get_users(chat), names->data));
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1997 break;
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1998 }
f3afcc4dd133 [gaim-migrate @ 4781]
Christian Hammond <chipx86@chipx86.com>
parents: 4491
diff changeset
1999 }
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1414
diff changeset
2000
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2001 if (gaim_chat_is_user_ignored(chat, old_user)) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2002 gaim_chat_unignore(chat, old_user);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2003 gaim_chat_ignore(chat, new_user);
1428
00b3d02a2168 [gaim-migrate @ 1438]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1414
diff changeset
2004 }
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2005 else if (gaim_chat_is_user_ignored(chat, new_user))
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2006 gaim_chat_unignore(chat, new_user);
1573
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
2007
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2008 if (chat_options & OPT_CHAT_LOGON) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2009 g_snprintf(tmp, sizeof(tmp),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2010 _("%s is now known as %s"), old_user, new_user);
1573
3a8bd72f431f [gaim-migrate @ 1583]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1532
diff changeset
2011
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2012 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL));
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2013 }
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2014 }
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2015
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2016 void
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2017 gaim_chat_remove_user(struct gaim_chat *chat, const char *user,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2018 const char *reason)
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2019 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2020 struct gaim_conversation *conv;
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
2021 struct gaim_conversation_ui_ops *ops;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2022 char tmp[BUF_LONG];
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2023 GList *names;
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2024
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2025 if (chat == NULL || user == NULL)
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2026 return;
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2027
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2028 conv = gaim_chat_get_conversation(chat);
4465
6e37eb000b7a [gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents: 4425
diff changeset
2029 ops = gaim_conversation_get_ui_ops(conv);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2030
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2031 plugin_event(event_chat_buddy_leave, gaim_conversation_get_gc(conv),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2032 gaim_chat_get_id(chat), user);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2033
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2034 if (ops != NULL && ops->chat_remove_user != NULL)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2035 ops->chat_remove_user(conv, user);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2036
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2037 for (names = gaim_chat_get_users(chat);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2038 names != NULL;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2039 names = names->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2040
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
2041 if (!gaim_utf8_strcasecmp((char *)names->data, user)) {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2042 gaim_chat_set_users(chat,
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2043 g_list_remove(gaim_chat_get_users(chat), names->data));
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2044 break;
2843
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2045 }
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2046 }
87d11d2a7d59 [gaim-migrate @ 2856]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2834
diff changeset
2047
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2048 /* NOTE: Don't remove them from ignored in case they re-enter. */
2787
feea7103a235 [gaim-migrate @ 2800]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2773
diff changeset
2049
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2050 if (chat_options & OPT_CHAT_LOGON) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2051 if (reason != NULL && *reason != '\0')
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2052 g_snprintf(tmp, sizeof(tmp),
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2053 _("%s left the room (%s)."), user, reason);
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2054 else
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2055 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user);
1757
3dfe4aefd366 [gaim-migrate @ 1767]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1735
diff changeset
2056
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2057 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL));
1759
e0f936b4c91a [gaim-migrate @ 1769]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1757
diff changeset
2058 }
e0f936b4c91a [gaim-migrate @ 1769]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1757
diff changeset
2059 }
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2060
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2061 struct gaim_conversation *
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2062 gaim_find_chat(struct gaim_connection *gc, int id)
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2063 {
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2064 GList *l;
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2065 struct gaim_conversation *conv;
2499
933e139fd0d3 [gaim-migrate @ 2512]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2487
diff changeset
2066
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2067 for (l = gaim_get_chats(); l != NULL; l = l->next) {
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2068 conv = (struct gaim_conversation *)l->data;
2499
933e139fd0d3 [gaim-migrate @ 2512]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2487
diff changeset
2069
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2070 if (gaim_chat_get_id(GAIM_CHAT(conv)) == id &&
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2071 gaim_conversation_get_gc(conv) == gc)
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2072 return conv;
2499
933e139fd0d3 [gaim-migrate @ 2512]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2487
diff changeset
2073 }
933e139fd0d3 [gaim-migrate @ 2512]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2487
diff changeset
2074
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
2075 return NULL;
2191
657dbe515608 [gaim-migrate @ 2201]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
2076 }
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2077
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2078 /**************************************************************************
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2079 * Conversation placement functions
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2080 **************************************************************************/
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2081 /* This one places conversations in the last made window. */
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2082 static void
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2083 conv_placement_last_created_win(struct gaim_conversation *conv)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2084 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2085 struct gaim_window *win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2086
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2087 if (convo_options & OPT_CONVO_COMBINE)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2088 win = g_list_last(gaim_get_windows())->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2089 else
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2090 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv));
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2091
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2092 if (win == NULL) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2093 win = gaim_window_new();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2094
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2095 gaim_window_add_conversation(win, conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2096 gaim_window_show(win);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2097 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2098 else
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2099 gaim_window_add_conversation(win, conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2100 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2101
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2102 /* This one places each conversation in its own window. */
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2103 static void
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2104 conv_placement_new_window(struct gaim_conversation *conv)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2105 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2106 struct gaim_window *win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2107
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2108 win = gaim_window_new();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2109
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2110 gaim_window_add_conversation(win, conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2111
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2112 gaim_window_show(win);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2113 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2114
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2115 /*
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2116 * This groups things by, well, group. Buddies from groups will always be
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2117 * grouped together, and a buddy from a group not belonging to any currently
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2118 * open windows will get a new window.
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2119 */
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2120 static void
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2121 conv_placement_by_group(struct gaim_conversation *conv)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2122 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2123 struct gaim_window *win;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2124 GaimConversationType type;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2125
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2126 type = gaim_conversation_get_type(conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2127
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2128 if (type != GAIM_CONV_IM) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2129 win = gaim_get_last_window_with_type(type);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2130
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2131 if (win == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2132 conv_placement_new_window(conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2133 else
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2134 gaim_window_add_conversation(win, conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2135 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2136 else {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2137 struct buddy *b;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2138 struct group *grp = NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2139 GList *wins, *convs;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2140
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
2141 b = gaim_find_buddy(gaim_conversation_get_account(conv),
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2142 gaim_conversation_get_name(conv));
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2143
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2144 if (b != NULL)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
2145 grp = gaim_find_buddys_group(b);
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2146
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2147 /* Go through the list of IMs and find one with this group. */
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2148 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2149 struct gaim_window *win2;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2150 struct gaim_conversation *conv2;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2151 struct buddy *b2;
4478
fa2d74e20a89 [gaim-migrate @ 4753]
Christian Hammond <chipx86@chipx86.com>
parents: 4476
diff changeset
2152 struct group *g2 = NULL;
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2153
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2154 win2 = (struct gaim_window *)wins->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2155
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2156 for (convs = gaim_window_get_conversations(win2);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2157 convs != NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2158 convs = convs->next) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2159
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2160 conv2 = (struct gaim_conversation *)convs->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2161
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
2162 b2 = gaim_find_buddy(gaim_conversation_get_account(conv2),
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2163 gaim_conversation_get_name(conv2));
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2164
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2165 if (b2 != NULL)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4647
diff changeset
2166 g2 = gaim_find_buddys_group(b2);
4478
fa2d74e20a89 [gaim-migrate @ 4753]
Christian Hammond <chipx86@chipx86.com>
parents: 4476
diff changeset
2167
fa2d74e20a89 [gaim-migrate @ 4753]
Christian Hammond <chipx86@chipx86.com>
parents: 4476
diff changeset
2168 if (grp == g2) {
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2169 gaim_window_add_conversation(win2, conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2170
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2171 return;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2172 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2173 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2174 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2175
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2176 /* Make a new window. */
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2177 conv_placement_new_window(conv);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2178 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2179 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2180
4522
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2181 /* This groups things by account. Otherwise, the same semantics as above */
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2182 static void
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2183 conv_placement_by_account(struct gaim_conversation *conv)
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2184 {
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2185 GaimConversationType type;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2186 GList *wins, *convs;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2187 struct gaim_account *account;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2188
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2189
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2190 account = gaim_conversation_get_account(conv);
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2191 type = gaim_conversation_get_type(conv);
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2192
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2193
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2194 /* Go through the list of IMs and find one with this group. */
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2195 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) {
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2196 struct gaim_window *win2;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2197 struct gaim_conversation *conv2;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2198
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2199 win2 = (struct gaim_window *)wins->data;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2200
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2201 for (convs = gaim_window_get_conversations(win2);
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2202 convs != NULL;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2203 convs = convs->next) {
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2204
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2205 conv2 = (struct gaim_conversation *)convs->data;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2206
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2207 if (((convo_options & OPT_CONVO_COMBINE) ||
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2208 type == gaim_conversation_get_type(conv2)) &&
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2209 account == gaim_conversation_get_account(conv2)) {
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2210 gaim_window_add_conversation(win2, conv);
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2211 return;
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2212 }
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2213
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2214 }
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2215 }
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2216 /* Make a new window. */
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2217 conv_placement_new_window(conv);
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2218 }
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2219
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2220 static int
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2221 add_conv_placement_fnc(const char *name, gaim_conv_placement_fnc fnc)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2222 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2223 struct ConvPlacementData *data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2224
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2225 data = g_malloc0(sizeof(struct ConvPlacementData));
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2226
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2227 data->name = g_strdup(name);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2228 data->fnc = fnc;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2229
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2230 conv_placement_fncs = g_list_append(conv_placement_fncs, data);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2231
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2232 return gaim_conv_placement_get_fnc_count() - 1;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2233 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2234
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2235 static void
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2236 ensure_default_funcs(void)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2237 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2238 if (conv_placement_fncs == NULL) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2239 add_conv_placement_fnc(_("Last created window"),
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2240 conv_placement_last_created_win);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2241 add_conv_placement_fnc(_("New window"),
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2242 conv_placement_new_window);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2243 add_conv_placement_fnc(_("By group"),
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2244 conv_placement_by_group);
4522
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2245 add_conv_placement_fnc(_("By account"),
0738264a52ad [gaim-migrate @ 4800]
Nathan Walp <nwalp@pidgin.im>
parents: 4506
diff changeset
2246 conv_placement_by_account);
4469
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2247 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2248 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2249
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2250 int
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2251 gaim_conv_placement_add_fnc(const char *name, gaim_conv_placement_fnc fnc)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2252 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2253 if (name == NULL || fnc == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2254 return -1;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2255
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2256 if (conv_placement_fncs == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2257 ensure_default_funcs();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2258
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2259 return add_conv_placement_fnc(name, fnc);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2260 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2261
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2262 void
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2263 gaim_conv_placement_remove_fnc(int index)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2264 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2265 struct ConvPlacementData *data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2266 GList *node;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2267
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2268 if (index < 0 || index > g_list_length(conv_placement_fncs))
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2269 return;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2270
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2271 node = g_list_nth(conv_placement_fncs, index);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2272 data = (struct ConvPlacementData *)node->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2273
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2274 g_free(data->name);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2275 g_free(data);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2276
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2277 conv_placement_fncs = g_list_remove_link(conv_placement_fncs, node);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2278 g_list_free_1(node);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2279 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2280
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2281 int
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2282 gaim_conv_placement_get_fnc_count(void)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2283 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2284 ensure_default_funcs();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2285
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2286 return g_list_length(conv_placement_fncs);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2287 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2288
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2289 const char *
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2290 gaim_conv_placement_get_name(int index)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2291 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2292 struct ConvPlacementData *data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2293
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2294 ensure_default_funcs();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2295
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2296 if (index < 0 || index > g_list_length(conv_placement_fncs))
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2297 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2298
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2299 data = g_list_nth_data(conv_placement_fncs, index);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2300
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2301 if (data == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2302 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2303
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2304 return data->name;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2305 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2306
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2307 gaim_conv_placement_fnc
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2308 gaim_conv_placement_get_fnc(int index)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2309 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2310 struct ConvPlacementData *data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2311
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2312 ensure_default_funcs();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2313
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2314 if (index < 0 || index > g_list_length(conv_placement_fncs))
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2315 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2316
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2317 data = g_list_nth_data(conv_placement_fncs, index);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2318
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2319 if (data == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2320 return NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2321
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2322 return data->fnc;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2323 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2324
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2325 int
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2326 gaim_conv_placement_get_fnc_index(gaim_conv_placement_fnc fnc)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2327 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2328 struct ConvPlacementData *data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2329 GList *node;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2330 int i;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2331
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2332 ensure_default_funcs();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2333
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2334 for (node = conv_placement_fncs, i = 0;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2335 node != NULL;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2336 node = node->next, i++) {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2337
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2338 data = (struct ConvPlacementData *)node->data;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2339
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2340 if (data->fnc == fnc)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2341 return i;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2342 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2343
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2344 return -1;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2345 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2346
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2347 int
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2348 gaim_conv_placement_get_active(void)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2349 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2350 return place_conv_index;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2351 }
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2352
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2353 void
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2354 gaim_conv_placement_set_active(int index)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2355 {
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2356 gaim_conv_placement_fnc fnc;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2357
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2358 ensure_default_funcs();
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2359
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2360 fnc = gaim_conv_placement_get_fnc(index);
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2361
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2362 if (fnc == NULL)
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2363 return;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2364
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2365 place_conv = fnc;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2366 place_conv_index = index;
d76095396a0e [gaim-migrate @ 4744]
Christian Hammond <chipx86@chipx86.com>
parents: 4467
diff changeset
2367 }
4481
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2368
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2369 void
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2370 gaim_set_win_ui_ops(struct gaim_window_ui_ops *ops)
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2371 {
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2372 win_ui_ops = ops;
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2373 }
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2374
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2375 struct gaim_window_ui_ops *
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2376 gaim_get_win_ui_ops(void)
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2377 {
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2378 return win_ui_ops;
b30b0a02ada0 [gaim-migrate @ 4756]
Christian Hammond <chipx86@chipx86.com>
parents: 4478
diff changeset
2379 }