annotate src/conversation.c @ 5965:cd8f8e5d697e

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