aboutsummaryrefslogtreecommitdiffstats
path: root/Mk/bsd.kde4.mk
diff options
context:
space:
mode:
authorbeat <beat@FreeBSD.org>2010-07-25 16:08:24 +0800
committerbeat <beat@FreeBSD.org>2010-07-25 16:08:24 +0800
commit3f37ec9e555a1afba50447bf2262aaaef814d326 (patch)
tree8650ab2632cf326d3928b9e44c9edb312226d261 /Mk/bsd.kde4.mk
parent5678c2684983de0194b3fdd6842c7ad29233afea (diff)
downloadfreebsd-ports-gnome-3f37ec9e555a1afba50447bf2262aaaef814d326.tar.gz
freebsd-ports-gnome-3f37ec9e555a1afba50447bf2262aaaef814d326.tar.zst
freebsd-ports-gnome-3f37ec9e555a1afba50447bf2262aaaef814d326.zip
- Update to 3.6.8
Diffstat (limited to 'Mk/bsd.kde4.mk')
0 files changed, 0 insertions, 0 deletions
03-17 16:53:48 +0800 rename empathy-dispatcher to empathy-request-util' href='/~lantw44/cgit/gsoc2013-empathy/commit/src/empathy-main-window.c?id=23d90f884b28cabd3b9b986998c118314a9238f9'>23d90f884
58505161b

6289d5e8a

96569c764
d6aa2f99e
e53b7431a
544f36035
d6aa2f99e
8e7b3f45c
398e3bc61


0cb1c94b0
65bf3f42d
598dd6403
398e3bc61
398e3bc61
ae7998610
d6aa2f99e

147ab96a5
c5b4c8eed
147ab96a5

0dca19234
147ab96a5
398e3bc61
28f655446
19c228d5c
d95165b81
8e7b3f45c
58505161b
58505161b
13c650f07
58505161b
30165e135
58505161b
f014e7c05
0f2684993
c448b89bb
8e7b3f45c
692886962

8e7b3f45c
f014e7c05


8e7b3f45c





8e7b3f45c


750400297
d7e8bf5c3

750400297
7cd053aff
53ff0c11c

154251095
53ff0c11c

2c5175128
d6aa2f99e

eb593876a
58505161b
f014e7c05
19c228d5c

f014e7c05

b3ee9d591
8e7b3f45c
96569c764


ee36de0c8
6289d5e8a
e8b798289
f9d98f63f
e8b798289


db9e0a4a2
0cb1c94b0
d9db98222

8e7b3f45c
fbaeb6930
40869ce43

c74b8f99f
40869ce43
40869ce43

65cb048dc
866aa89a1
65cb048dc
6289d5e8a
65cb048dc
6289d5e8a

8e7b3f45c
416da629f
4786fdc5f
4f128d19a
416da629f
e8b798289
932835ccd

e8b798289
8e7b3f45c
932835ccd
db9e0a4a2
8e7b3f45c
9dd268d14



65cb048dc

c448b89bb

a3006260d
53ff0c11c
e6d0aad4e
f014e7c05


53ff0c11c


f014e7c05



53ff0c11c


f014e7c05


fbaeb6930


f014e7c05







94e1daa81
d6aa2f99e
f014e7c05



fbaeb6930
f014e7c05
b7bbdc37b
5ad816894
f014e7c05

c75319eb4


fef2dec3e
f2ee2965a

f014e7c05


beb0b7e42
f014e7c05
d6aa2f99e


ee02e3e2d

f014e7c05


d6aa2f99e
f014e7c05



02e603f5a
f014e7c05








f2ee2965a
d6aa2f99e
22c93bf49
ee02e3e2d
f014e7c05






53ff0c11c
f014e7c05




53ff0c11c

d6aa2f99e
f014e7c05
53ff0c11c
f014e7c05

fbaeb6930
e037c0c20
f014e7c05


















53ff0c11c


f014e7c05



53ff0c11c


f014e7c05



db9e0a4a2






























































































225ca2e12
db9e0a4a2



































49f661f32















































































f014e7c05




49f661f32

f014e7c05
db9e0a4a2

f014e7c05







53ff0c11c
f014e7c05

db9e0a4a2




f014e7c05



49f661f32

f014e7c05

fbaeb6930
d6aa2f99e
f014e7c05









53ff0c11c
d6aa2f99e

f014e7c05



d6aa2f99e
f014e7c05
d6aa2f99e
f014e7c05
d6aa2f99e

f014e7c05

d6aa2f99e
fef2dec3e
d6aa2f99e

f014e7c05
d6aa2f99e
f014e7c05

65ba1ecd2

53ff0c11c
f014e7c05



a88e050a3
f014e7c05
a88e050a3
54cdaedca

a88e050a3
f014e7c05




d6aa2f99e
22c93bf49
f014e7c05

b5b4d3697
b3ee9d591









da3e82030

7c9578427






ab97f58c9
8b4a09ed7

e2087d9cd
da3e82030
750400297
da3e82030
b3ee9d591













750400297
7cd053aff
b3ee9d591



8a0d77c2a
8b82da132
8a0d77c2a
53ff0c11c
8a0d77c2a

53ff0c11c
8a0d77c2a

53ff0c11c
8a0d77c2a



8b82da132

8a0d77c2a





8b82da132
8a0d77c2a
02c572204
eb593876a
02c572204
9d4730f96
b51918d47
02c572204
b2f25f9f7
02c572204


8b82da132
9d4730f96

b51918d47
9d4730f96

2aa506e8a

a79cbb8de
2aa506e8a
9d4730f96
b2f25f9f7
9d4730f96


8b82da132
9d4730f96

b51918d47
9d4730f96

8a0d77c2a
9d4730f96


02c572204
717184f6d
02c572204
53ff0c11c
152f79da7
f18e8e832
02c572204
f18e8e832
9d4730f96




02c572204
bb3eb6c8c
ea19d00b7








02c572204
8beb22ec2
b51918d47
ea19d00b7
53ef8f9b7
53ff0c11c
152f79da7

02c572204

02c572204





9d4730f96
8429eac0c
863ca0ae5
152f79da7
53ff0c11c
152f79da7
02c572204
b51918d47
a8a0b7d81
02c572204
02c572204
bb3eb6c8c

2b6d806d6
d0c2fc30c
863ca0ae5
02c572204

863ca0ae5
64886f050
2b6d806d6
863ca0ae5
9d4730f96


c408acfee
9d4730f96




c408acfee
9d4730f96




c408acfee
9d4730f96


















152f79da7

02c572204

9d4730f96


















02c572204
b4930806a
53ff0c11c
02c572204
53ff0c11c
02c572204


eb593876a
02c572204
53ff0c11c
eb593876a
72a404293
02c572204
eb593876a
02c572204

eb593876a
53ff0c11c

02c572204
53ff0c11c

02c572204


53ff0c11c
eb593876a
02c572204
72a404293








02c572204

416da629f















c26345ba2









416da629f



1b3757bc5
416da629f
010b9fefd
8b7ca3f8f
416da629f

1b3757bc5
49af530a5
416da629f
1b3757bc5

416da629f




49af530a5
416da629f
49af530a5
416da629f
49af530a5

416da629f

49af530a5





416da629f

49af530a5
8b7ca3f8f




416da629f


416da629f
1b3757bc5



416da629f
1b3757bc5
416da629f

4f128d19a


416da629f
416da629f
416da629f

0892b114e
416da629f

4f128d19a
416da629f
416da629f











0ba165de9


416da629f
416da629f

















0892b114e

4f128d19a






0892b114e

416da629f



4f128d19a


1038e0350

010b9fefd

1038e0350



1038e0350

8b7ca3f8f
1038e0350

8b7ca3f8f

1038e0350
8b7ca3f8f
1038e0350


8b7ca3f8f







1038e0350
8b7ca3f8f
1038e0350

8b7ca3f8f

1038e0350



1038e0350






4f128d19a
fb56e32dc

4f128d19a
4786fdc5f
fb56e32dc
4f128d19a
1b3757bc5
4f128d19a
fb56e32dc
416da629f
fb56e32dc
1b3757bc5
4f128d19a
4f128d19a






4786fdc5f




1038e0350
010b9fefd
1038e0350
1b3757bc5







416da629f
1b3757bc5

416da629f
416da629f

02c572204
cddd93283











































eb593876a
8b82da132




b5b4d3697

a6a4c117c

eb593876a
b5b4d3697


717184f6d
b5b4d3697

65f7803dd
81068bbf3
35f3ccfb4
416da629f
0892b114e
cddd93283
b5b4d3697


81068bbf3
35f3ccfb4
b5b4d3697

b2f25f9f7
416da629f
b5b4d3697


f7a42f571
02c572204
e6d0aad4e
02c572204

e1fa17399
02c572204





e6d0aad4e

02c572204

8e7b3f45c
02c572204

8a9cd5deb
e1fa17399
02c572204


8e7b3f45c
02c572204

8e7b3f45c
02c572204

8e7b3f45c

53ff0c11c
8e7b3f45c
53ff0c11c
9dd268d14


8e7b3f45c


53ff0c11c
8e7b3f45c
53ff0c11c
d6aa2f99e
2c5175128
81068bbf3
53ff0c11c
db9e0a4a2
8e7b3f45c
9dd268d14
53ff0c11c
9dd268d14



53ff0c11c
9dd268d14
53ff0c11c
f014e7c05

53ff0c11c
f014e7c05

19c228d5c
53ff0c11c


f014e7c05
53ff0c11c

96569c764
53ff0c11c
8e7b3f45c

d95165b81
8b82da132
d95165b81
8b82da132
d95165b81
b70f96a52
d95165b81

2d5e4f0a1
d95165b81



8e7b3f45c
65cb048dc






866aa89a1
65cb048dc

53ff0c11c
65cb048dc





53ff0c11c
65cb048dc


c5b4c8eed
8b82da132
c5b4c8eed
53ff0c11c
c5b4c8eed


65cb048dc


ae7998610
65cb048dc


598dd6403








92633f9ea
0f2684993

63369cbc2
0f2684993


02ce3c9a8
65cb048dc

53ff0c11c
65cb048dc


53ff0c11c
96569c764

65cb048dc
a84e9e79c
d6aa2f99e
65cb048dc

30165e135
96569c764
2a5d562c8


53ff0c11c
96569c764
2a5d562c8
96569c764


2a5d562c8



d6aa2f99e
2a5d562c8


ad1cc3ce5
2a5d562c8

53ff0c11c
2a5d562c8








29cbf3a2b



53ff0c11c
29cbf3a2b
4fa12b807




c74b8f99f
4fa12b807


171cc611e
4fa12b807



2a5d562c8
4fa12b807

53ff0c11c
96569c764

4fa12b807
d6aa2f99e

29cbf3a2b

fbaeb6930
8b82da132

fbaeb6930
53ff0c11c
fbaeb6930



53ff0c11c
96569c764

d6aa2f99e

fbaeb6930

29cbf3a2b
c74b8f99f


29cbf3a2b





53ff0c11c
783c15aec

29cbf3a2b

783c15aec


4fa12b807
783c15aec



96569c764


783c15aec
96569c764

783c15aec
4fa12b807
d6aa2f99e




783c15aec

fbaeb6930

96569c764
8b82da132

fbaeb6930
53ff0c11c


96569c764

29cbf3a2b

fbaeb6930
29cbf3a2b
96569c764
2a5d562c8


53ff0c11c
783c15aec
2a5d562c8
96569c764







2a5d562c8
96569c764
783c15aec

972532d42


53ff0c11c
2a5d562c8


b3a5b441b
2d25c8605







30165e135


5cc326f74
4152e6dc0
30165e135
3b1bbb17b
30165e135
65cb048dc
b9c8f8942

8e7b3f45c
eb593876a
02c572204
6fe758a0d
02c572204

6fe758a0d
b9fba4f58
23d90f884
b9c8f8942

37e0041fe

585d72aa8
37e0041fe


585d72aa8
37e0041fe


585d72aa8

37e0041fe




585d72aa8
37e0041fe







585d72aa8
37e0041fe

















7d4202aa8
37e0041fe








f8c37da73


37e0041fe



7d4202aa8
585d72aa8
37e0041fe


585d72aa8











b9c8f8942






37e0041fe


585d72aa8
a89cddec3
37e0041fe



585d72aa8


b9c8f8942
37e0041fe
b9c8f8942
a89cddec3
02c572204


8b82da132
02c572204






8b82da132
02c572204
53ff0c11c
02c572204
0a42a7902


02c572204


6fe758a0d

02c572204
0a42a7902




72a404293

6fe758a0d
02c572204



6fe758a0d
53ff0c11c
65cb048dc
02c572204

6fe758a0d


58505161b

8b82da132
6fe758a0d
53ff0c11c

6fe758a0d
53ff0c11c

6fe758a0d


58505161b

8b82da132
6fe758a0d
53ff0c11c
6fe758a0d
02c572204
6fe758a0d

6fe758a0d


53ff0c11c
6fe758a0d
53ff0c11c
6fe758a0d
53ff0c11c
6fe758a0d

53ff0c11c
6fe758a0d



02c572204
6fe758a0d
53ff0c11c
02c572204
65cb048dc
8e7b3f45c
53ff0c11c



65cb048dc
53ff0c11c

65cb048dc
b103cb3c5
02c572204


b103cb3c5
02c572204
53ff0c11c
4f5bfccce

53ff0c11c
b103cb3c5
53ff0c11c
02c572204

53ff0c11c
02c572204



b103cb3c5


65cb048dc
8e7b3f45c

53ff0c11c
8e7b3f45c


65cb048dc
8e7b3f45c

53ff0c11c
b103cb3c5

53ff0c11c
b103cb3c5



8e7b3f45c


65cb048dc
8e7b3f45c

53ff0c11c
8e7b3f45c


8b82da132
65cb048dc
8e7b3f45c
53ff0c11c
50efb94e6
8e7b3f45c
65cb048dc
d6aa2f99e

50efb94e6
8e7b3f45c

8e7b3f45c
53ff0c11c
8e7b3f45c
50efb94e6
8e7b3f45c
53ff0c11c

8e7b3f45c
8e7b3f45c

65cb048dc
8e7b3f45c

d6aa2f99e

50efb94e6
8e7b3f45c

8e7b3f45c
53ff0c11c
8e7b3f45c
50efb94e6
8e7b3f45c
53ff0c11c

8e7b3f45c
8e7b3f45c

65cb048dc
8e7b3f45c

53ff0c11c

8e7b3f45c
65cb048dc
8e7b3f45c


65cb048dc
8e7b3f45c

2aa506e8a
a79cbb8de
8e7b3f45c


65cb048dc
8e7b3f45c

53ff0c11c
8e7b3f45c


65bf3f42d










4f8ce5f25
0ea574321
2e7a0efc8
8e7b3f45c
ee36de0c8










0ea574321
2e7a0efc8
0ea574321

8e7b3f45c


4f8ce5f25


2e7a0efc8
4f8ce5f25


65cb048dc
8e7b3f45c

53ff0c11c
8e7b3f45c


7e1d20222


55c0b1210
7e1d20222


65cb048dc
8e7b3f45c

53ff0c11c
8e7b3f45c


f9d98f63f
6fe758a0d

8e7b3f45c





2aa506e8a
f9d98f63f
a79cbb8de
8e7b3f45c


104362fe3
e8b798289
eb593876a


e8b798289
53ff0c11c
eb593876a



53ff0c11c
eb593876a


8a0d77c2a


cddd93283


eb593876a


8b82da132


eb593876a

53ff0c11c

32f691f2a
9dd268d14

53ff0c11c
9dd268d14






53ff0c11c
9dd268d14

32f691f2a

eb593876a
02c572204
e8b798289
02c572204
96569c764
02c572204
65cb048dc
02c572204
96569c764

02c572204
e8b798289
02c572204
02c572204


53ff0c11c
02c572204
65cb048dc
2cb90d908
65cb048dc
72a404293

02c572204
c5b4c8eed
02c572204
65bf3f42d

02c572204
e8b798289
65cb048dc


02c572204
e8b798289
53ff0c11c
02c572204
e8b798289
eb593876a
8b82da132
eb593876a
8b82da132
eb593876a



53ff0c11c
d5f2776ba
eb593876a
d5f2776ba


eb593876a


53ff0c11c
eb593876a

9dd268d14
eb593876a
9dd268d14
eb593876a

53ff0c11c
9dd268d14
416da629f

eb593876a
424ded372
32f691f2a



27bf66610

424ded372
53ff0c11c
424ded372

eb593876a


c448b89bb
a3006260d






c448b89bb
53ff0c11c

a3006260d


c448b89bb
a3006260d
53ff0c11c

c448b89bb


53ff0c11c



8e7b3f45c
53ff0c11c



























d6aa2f99e
02c572204
02c572204
65cb048dc
d310cd8ea
02c572204

02c572204

b3ee9d591
4c534b01f
8e7b3f45c
53ff0c11c

8e7b3f45c
53ff0c11c

8e7b3f45c
81068bbf3

53ff0c11c


96569c764
02c572204


53ff0c11c
1038e0350
53ff0c11c
db9e0a4a2
53ff0c11c
02ce3c9a8
53ff0c11c






30165e135
53ff0c11c

d9db98222

02c572204
4786fdc5f
4c534b01f
02c572204

8e7b3f45c
53ff0c11c


26b67edf4


02c572204
02c572204

c5b4c8eed
866aa89a1
02c572204



598dd6403
92633f9ea
02ce3c9a8
fbaeb6930
29cbf3a2b
c74b8f99f
30165e135
65cb048dc
02c572204

65bf3f42d
02c572204
b3a5b441b
02c572204
7e1d20222
02c572204

8e7b3f45c
02c572204

65cb048dc
53ff0c11c
02c572204
8e7b3f45c
5cc326f74
d310cd8ea
30165e135

53ff0c11c
8e7b3f45c
53ff0c11c
eb593876a
8e7b3f45c
53ff0c11c



8e7b3f45c
01e02a165
db9e0a4a2
53ff0c11c



9dd268d14
02c572204

8e7b3f45c
53ff0c11c
65cb048dc
53ff0c11c

65cb048dc
53ff0c11c

8e7b3f45c
225661fe0


02c572204
53ff0c11c

02c572204

d8bb9ec37
53ff0c11c
02c572204

53ff0c11c
8e7b3f45c
02c572204
53ff0c11c


53ff0c11c

f9d98f63f

53ff0c11c
8e7b3f45c
02c572204
f9d98f63f
53ff0c11c


8e7b3f45c
2c5175128





d6aa2f99e


da5ec3c2b

8c812cfbd


d6aa2f99e

8c812cfbd
d6aa2f99e
0cb1c94b0
53ff0c11c
2c5175128
d6aa2f99e
0cb1c94b0
d6aa2f99e
02c572204
d6aa2f99e

02c572204

8e7b3f45c
0cb1c94b0
53ff0c11c
d6aa2f99e

53ff0c11c
4c534b01f
0cb1c94b0
4c534b01f
53ff0c11c
d6aa2f99e
0cb1c94b0
b3ee9d591

da3e82030
b3ee9d591





d9db98222
02c572204



53ff0c11c
8e7b3f45c
4786fdc5f






1038e0350
02c572204
19c228d5c
53ff0c11c
d6aa2f99e
53ff0c11c
d6aa2f99e
53ff0c11c
d6aa2f99e
53ff0c11c
eb593876a
02c572204
53ff0c11c
eb593876a
02c572204
53ff0c11c
8a0d77c2a

8e7b3f45c
53ff0c11c
02c572204
d6aa2f99e

02c572204
8e7b3f45c
8e7b3f45c
02c572204
53ff0c11c
96569c764
53ff0c11c
96569c764


8e7b3f45c
65cb048dc
8e7b3f45c
fbaeb6930
53ff0c11c
96569c764


fbaeb6930
53ff0c11c
96569c764

fbaeb6930
29cbf3a2b
53ff0c11c
96569c764


8e7b3f45c
53ff0c11c
40869ce43

beb301da4
29cbf3a2b
53ff0c11c
96569c764


53ff0c11c
96569c764



53ff0c11c
40869ce43

beb301da4

53ff0c11c




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389

                                                                           
                                     
                                         












                                                                     

                                                               
  
                                                 
                                                               





                     
                           

                       
                                           
                                
                        
 
                                       
                                     
                                            

                                                

                                               
                                         
                                                  
                                         
                                              
                                                  
 


                                                      
                                               
                                                           
                                                         
                                            
                                                  
                                                      

                                                    
                                                      
                                                   

                                                    
                                                 
                                            
 
                                    
                                  
                                 
                                
                                
                                 
                                 
                                        
                             
                                     
                                  
                               
                                           
 

                                      
 


                                              





                                                             


                                   
      

                              
  
 

                                                                        
                                                                                    

                               
                                                 

                                                  
                                                 
                                                  
                                               

                                               

                                                  
                                       
 


                                                   
                                            
                                          
                                         
                                                   


                                                 
                                          
                                           

                                               
 
                                               

                                               
                                                    
                                            

                                             
                                           
                                             
                                                    
                                          
                                               

                                                       
 
                                                     
                                                            
                                             
 
                                                

                                                      
                                       
 
                                                  
                                      
 



                                                                   

                                                                        

                                                               
                                                         
  
 


                                                  


                                                        



                                


                                                 


                


                                   







                                                   
                                                                
                                    



                                             
                                        
 
                                        
                                                                                 

                                


                               
                                                                         

                                            


                                                   
                                                                                       
                


                                                                                          

                                              


                                                         
                                                                             



                                                              
                                                 








                                                                              
    
                                    
                                   
                                  






                                                
                                                        




                                              

                                         
                                                        
 
                                                                        

                                          
                                     
                                                                    


















                                                                  


                                                        



                                 


                                                                                   



                                      






























































































                                                                                      
                                                                    



































                                                                                  















































































                                                                                         




                                                         

                                                     
                                                 

                                                            







                                                           
                                                        

                              




                                                        



                              

                                             

                           
                             
                                                                        









                                                             
                                                        

                                       



                                   
                                                                                
                                                     
 
                                         

                                                                    

                                
                                 
                                                                                 

         
                       
                         

         

                                                                 
                                                                        



                                                
                                                 
                                                       
 

                                                                           
                                                                               




                                 
    
                                      

 
           









                                                                 

                                                          






                                                                                        
 

                                                                                  
 
                                                       
                                                                                      
                 













                                                                             
                                                   
                                                                           



           
                                                    
                                                     
 
                                                        

                                
                                                                   

                                                  
                                                            



           

                                                            





                                                           
                                                              
                                                              
 
                           
 
                                                                   
                                                         
 
                                                   


           
                                                             

                                                             
                           

                                                                   

                                                  
                                                                    
                                               
 
                                                   


           
                                                              

                                                              
                           

                                                                   
                                                   


           
                                                     
                                                      
 
                                                        
                            
                                
                         
                         




                                
                       
                                   








                                                                             
 
                                                       
                                                                                     
                                                              
 
                                                               

                                                                         

                                                          





                                                              
                                       
                                                                                   
 
                                                    
                                                                                   
                                   
 
                                                       
                                                                                      
                                
 

                                                           
                                                                         
                                                          
                                

                     
                                                                               
                                                                            
                                                                          
 


                                                                                   
                                                                   




                                                                                
                                                                     




                                                                                 
                                                               


















                                                                                                                       

                                                                

                                                                  


















                                                                          
 
                                                                       
                                            
 
                                                                             


           
                                                     
 
                                                        
                                       
                            
 
                                                                                 

                                      
                         

                                                                 
                

                                                                


                                        
                                                           
                                                              
         








                                                                                    

 















                                                                      









                                                                         



                                                        
                                                       
 
                                                              
                         

                                 
                                   
                          
 

                                                                          




                                      
                                        
                
                                                                              
 

                                                                 

         





                                                           

                                           
 




                                                                     


           
                                                        



                                                      
 
                                                          

 


                                                                   
 
                                                        

                          
                       

                             
                                                 
                                                 











                                                                      


                                                                          
 

















                                                                         

                                                                       






                                                              

                                                         



                      


                      

                                                                   

                                                                   



                                                        

                                       
                           

                                                                   

                                                                        
 
                                


                                                                  







                                                                        
 
                           

                                                                    

                                                          



                                                                                






                                                                          
           

                                                      
 
                                                        
                                                                 
                          
                         
 
                         
                       
 
                                                                        
                       






                                                                           




                                                                         
                                       
                                                                          
 







                                                                            
 

                                                                     
 

 
           











































                                                                
                                                       




                                                               

                                                             

                                                        
                                           


                                                              
                                                            

         
                                                           
                                                                                 
                                                                        
 
                                                       
                                                                    


                                                        
                                                                                 
                                                                     

                                                                                  
                                                           
                                                            


         
           
                              
 

                        
                                                                                                    





                                                         

 

                              
 

                              
 
                                                                              


                                                                       
 

                                                 
 

                                

           
                                              
 
                                                        


                            


                                             
                                              
 
                                               
                                                
                                               
                                         
                                            
                                           
 
                                                              
                                                                      



                                                                       
                                                             
 
                                                                  

                                                                         
                                                                  

                                                                           
                                             


                                                
 

                                                  
 
                                                                             

 
               
                                                     
                                                    
                                                        
 
                                      

                                                 
                                                              



                     
           






                                                    
                                                       

                                                       
                                                                         





                                                           
                                                              


           
                                                        
                                                        
 
                                                           


           


                                                           
                                                                 


           








                                                               
                                                            

                                                            
                                   


           
                                                            

                                                            
                                                        


                                                        
                                                   

                                                              
 
                                                                        
                                 

 
           
                                                                 


                                                              
                                                        
                   
 


                                                     



                                       
                                                                 


                                                                        
                                                                       

                                                                                         
                                                                               








                                                                                             



                                                              
                                                        
                                          




                                
                                                            


                                                    
                                                         



                                                                                   
                                                                                                   

                                                          
                                                                

                                                                             
         

                                                                            

 
           

                                                              
 
                                                        



                                                      
                                                   

                                                                

                                                                            

 
                                                                 


                                                         





                                                                   
                                                        

                                

                                                            


                                                                         
 



                                                          


                                                                                
                                             

                                                                      
                                        
 




                                                                          

                                      

 
                                                                               

                                                                            
 


                                                           

                                                                  

 
 
           
                                                                      


                                                                   
                                                        
                   
 







                                                                 
         
 

                                                     


                                                                              
                                                                              


           
                                                             







                                                                     


                                                        
                        
                                 
      
 
 
           

                                         
 
                                
                             
 

                                                          
 
                                                    
                                                    

 

              
                           


                                  
                      


                                 

                                                       




                                                      
                                              







                                                             
                                      

















                                                         
                                     








                                                     


                                                



                                                      
        
                                       


                                                           











                                                                






                                                               


                                                                              
                                                                      
                                                            



                                                                               


                                                                            
                       
         
 
                                                                     


           
                                                                           






                                                                          
                                                                    
 
                                                        
                               


                                         


                                                                   

         
                                                    




                                                                 

                                                               
 



                                                                                      
 
                                                                
                                             

                                    


           

                                                                              
                                                                            
 

                                                        
                                                                  

                                                                   


           

                                                                                
                                                                              
 
                                                        
                             
                         

                                                                         


                                                                   
                                                                                          
                        
                                                       
                
                                                       

         
                                                                                



                                
                                                                    
 
                                                        
                             
                        
 



                                                                               
                                 

                                                                           
                                                
 


                                                                         
 
                         
                                                       

         
                                                                                
 
                                                                   

                                                                                   
                                                                     



                                                                                     


           
                                                        

                                                        
                                                               


           
                                                              

                                                              
                                                        

                             
                                                                                          



                                                             


           
                                                                

                                                                
                                                            


           
                                               
                                               
 
                                                        
                           
 
                                                                                   

                                                               
                      

                                   
 
                                                          
                                                           
                                                                     
 

                                                               
 

                                                          
                       

         

                                                          
                      

                                   
 
                                                          
                                                           
                                                                   
 

                                                               
 

                                                          
                       

         

                                                       
 
               


           
                                                        

                                                        
                                                                            
                                            


           
                                                                    

                                                                    
                                                                   


           










                                                                           
    
                                                                
                     
 










                                                                                  
 
                        

                                                                      


           


                                                           
                                                            


           
                                                     

                                                     
                                                       


           


                                                     
                                                                   


           
                                                        

                                                        
                                                                


               
                                                                        

                                                                      





                                              
                                                  
                                                                      
                                            


                     
 
           


                                                           
 
                                                        



                                                            
                                                     


                                       


                                                   


                                                            


           


                                                                    

                                                                   

                                                        
                    

                                                                    
                                                                 






                                                                               
                                                                           

                                                                        

         
                                                                  
 
 
           
                                                           
                                                     
                                                               
 

                                                                 
 
 
           


                                                              
                                                        
                            
                              
                         
                                            

                                      
                                   
                                
                                   

                                            
          
 


                                                                             
         
 
                                       
 
 
           
                                                         
                                                  
                                                     



                                                                       
                                                        
                             
 


                                                                                


                       
                                                                                 

                                                          
                                  
 
                                                                         

                                                                                 
                                                                   
                                                                             

                                                            
         
 



                                                                               

                                           
                                                                                    
                                                     

                                              


                               
           






                                                              
 

                                                        


                       
                                                        
                                                  

                                                                          


         



                                                                         
 



























                                                                                 
                                                     
                                      
                                     
                                                      
                                                  

                                               

                                           
                                        
                                              
 

                                                                         
 

                                                                                  
 

                                                                 


                                                                      
 


                                                                         
                                                                     
                                                                           
                                                                         
                                                                     
                                                                       
                                                                                 






                                                                                                   
                                                                         

                                                                                         

                                                                               
                                                                    
                                                                                                         
                                                                   

                                             
 


                                                                    


                                                                             
                                             

                                                                                              
                                                                                        
                                                                                      



                                                                                                        
                                                                                                      
                                                                                                   
                                                                                               
                                                                                                   
                                                                                                
                                                                                                                 
                                                                                        
                                                                      

                                                                                                                
                                                                                                        
                                                                                              
                                                                                                      
                                                                                  
                                                                                  

                                                                                        
 

                                                         
 
                                        
                             
 
                         
                                                        

      
                                                          
 
                                                                      
                                                                               
 



                                                             
 
                                                    
 



                                                                              
 

                                                          
 
                                                                         
                                              

                                                                  
                                                        

                                                       
 


                                          
                                     

                                                                 

                                            
                                                                     
                                                                         

                                                    
                                                                            
 
                                 


                                                                                  

                                                                      

                                                                        
                                         
 
                                    
                                                                 


                                                                            
 





                                                                               


                                                                         

                                            


                                                                                                            

                                                             
                                                                                                           
                                                        
 
                                                                             
                                                                 
                                                                             
 
                                                             
                                              

                                                                 

                                                                    
 
                               
                                                    

                                                                       
                                                        
                                                                    
                                
 
                                                
                                                                           
 

                                                                                
                           





                                                                   
 



                                             
                                                                   
 






                                                                            
 
                                   
                                                                     
                                                                     
 
                                                             
                                                                           
                                                               
                                                                             
                                                                            
                                                                               
                                  
                                                                   
                                                                      
                                  
                                                                    

                                                                       
 
                                                                   
                   

                                                                         
                            
         
 
                            
                                                                  
                                                                              
                                             


                                                                          
 
                                                                         
 
                             
                                             


                                                                            
 
                                                                 

                                                                              
 
                                        
                                                   


                                                                            
 
                                                                     

                                                                                  
 
                                
                                             


                                                                               
                                             



                                                                               
                                                                    

                                                                               

 




                                                             
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2002-2007 Imendio AB
 * Copyright (C) 2007-2010 Collabora Ltd.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 *
 * Authors: Xavier Claessens <xclaesse@gmail.com>
 *          Danielle Madeley <danielle.madeley@collabora.co.uk>
 */

#include <config.h>

#include <sys/stat.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>

#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
#include <folks/folks.h>

#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-request-util.h>
#include <libempathy/empathy-chatroom-manager.h>
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-individual-manager.h>
#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-status-presets.h>
#include <libempathy/empathy-tp-contact-factory.h>

#include <libempathy-gtk/empathy-contact-dialogs.h>
#include <libempathy-gtk/empathy-contact-list-store.h>
#include <libempathy-gtk/empathy-contact-list-view.h>
#include <libempathy-gtk/empathy-live-search.h>
#include <libempathy-gtk/empathy-contact-blocking-dialog.h>
#include <libempathy-gtk/empathy-contact-search-dialog.h>
#include <libempathy-gtk/empathy-geometry.h>
#include <libempathy-gtk/empathy-gtk-enum-types.h>
#include <libempathy-gtk/empathy-individual-dialogs.h>
#include <libempathy-gtk/empathy-individual-store.h>
#include <libempathy-gtk/empathy-individual-view.h>
#include <libempathy-gtk/empathy-new-message-dialog.h>
#include <libempathy-gtk/empathy-new-call-dialog.h>
#include <libempathy-gtk/empathy-log-window.h>
#include <libempathy-gtk/empathy-presence-chooser.h>
#include <libempathy-gtk/empathy-sound-manager.h>
#include <libempathy-gtk/empathy-ui-utils.h>

#include "empathy-accounts-dialog.h"
#include "empathy-call-observer.h"
#include "empathy-chat-manager.h"
#include "empathy-main-window.h"
#include "empathy-preferences.h"
#include "empathy-about-dialog.h"
#include "empathy-debug-window.h"
#include "empathy-new-chatroom-dialog.h"
#include "empathy-map-view.h"
#include "empathy-chatrooms-window.h"
#include "empathy-event-manager.h"
#include "empathy-ft-manager.h"
#include "empathy-migrate-butterfly-logs.h"

#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>

/* Flashing delay for icons (milliseconds). */
#define FLASH_TIMEOUT 500

/* Minimum width of roster window if something goes wrong. */
#define MIN_WIDTH 50

/* Accels (menu shortcuts) can be configured and saved */
#define ACCELS_FILENAME "accels.txt"

/* Name in the geometry file */
#define GEOMETRY_NAME "main-window"

enum {
    PAGE_CONTACT_LIST = 0,
    PAGE_NO_MATCH
};

G_DEFINE_TYPE (EmpathyMainWindow, empathy_main_window, GTK_TYPE_WINDOW);

#define GET_PRIV(self) ((EmpathyMainWindowPriv *)((EmpathyMainWindow *) self)->priv)

struct _EmpathyMainWindowPriv {
    EmpathyContactList      *contact_manager;
    EmpathyIndividualStore  *individual_store;
    EmpathyIndividualView   *individual_view;
    TpAccountManager        *account_manager;
    EmpathyChatroomManager  *chatroom_manager;
    EmpathyEventManager     *event_manager;
    EmpathySoundManager     *sound_mgr;
    EmpathyCallObserver     *call_observer;
    guint                    flash_timeout_id;
    gboolean                 flash_on;
    gboolean                 empty;

    GSettings              *gsettings_ui;
    GSettings              *gsettings_contacts;

    GtkWidget              *preferences;
    GtkWidget              *main_vbox;
    GtkWidget              *throbber;
    GtkWidget              *throbber_tool_item;
    GtkWidget              *presence_toolbar;
    GtkWidget              *presence_chooser;
    GtkWidget              *errors_vbox;
    GtkWidget              *auth_vbox;
    GtkWidget              *search_bar;
    GtkWidget              *notebook;
    GtkWidget              *no_entry_label;

    GtkToggleAction        *show_protocols;
    GtkRadioAction         *sort_by_name;
    GtkRadioAction         *sort_by_status;
    GtkRadioAction         *normal_with_avatars;
    GtkRadioAction         *normal_size;
    GtkRadioAction         *compact_size;

    GtkUIManager           *ui_manager;
    GtkAction              *view_history;
    GtkAction              *room_join_favorites;
    GtkWidget              *room_menu;
    GtkWidget              *room_separator;
    GtkWidget              *edit_context;
    GtkWidget              *edit_context_separator;

    GtkActionGroup         *balance_action_group;
    GtkAction              *view_balance_show_in_roster;
    GtkWidget              *balance_vbox;

    guint                   size_timeout_id;

    /* reffed TpAccount* => visible GtkInfoBar* */
    GHashTable             *errors;

    /* EmpathyEvent* => visible GtkInfoBar* */
    GHashTable             *auths;

    /* stores a mapping from TpAccount to Handler ID to prevent
     * to listen more than once to the status-changed signal */
    GHashTable             *status_changed_handlers;

    /* Actions that are enabled when there are connected accounts */
    GList                  *actions_connected;

    /* The idle event source to migrate butterfly's logs */
    guint butterfly_log_migration_members_changed_id;
};

static void
main_window_flash_stop (EmpathyMainWindow *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);

    if (priv->flash_timeout_id == 0) {
        return;
    }

    DEBUG ("Stop flashing");
    g_source_remove (priv->flash_timeout_id);
    priv->flash_timeout_id = 0;
    priv->flash_on = FALSE;
}

typedef struct {
    EmpathyEvent       *event;
    gboolean            on;
    EmpathyMainWindow  *window;
} FlashForeachData;

static gboolean
main_window_flash_foreach (GtkTreeModel *model,
               GtkTreePath  *path,
               GtkTreeIter  *iter,
               gpointer      user_data)
{
    FlashForeachData *data = (FlashForeachData *) user_data;
    FolksIndividual *individual;
    EmpathyContact   *contact;
    const gchar      *icon_name;
    GtkTreePath      *parent_path = NULL;
    GtkTreeIter       parent_iter;
    GdkPixbuf        *pixbuf = NULL;

    gtk_tree_model_get (model, iter,
                EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
                -1);

    if (individual == NULL)
        return FALSE;

    contact = empathy_contact_dup_from_folks_individual (individual);
    if (contact != data->event->contact)
        goto out;

    if (data->on) {
        icon_name = data->event->icon_name;
        pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
    } else {
        pixbuf = empathy_individual_store_get_individual_status_icon (
                        GET_PRIV (data->window)->individual_store,
                        individual);
        if (pixbuf != NULL)
            g_object_ref (pixbuf);
    }

    gtk_tree_store_set (GTK_TREE_STORE (model), iter,
                EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf,
                -1);

    /* To make sure the parent is shown correctly, we emit
     * the row-changed signal on the parent so it prompts
     * it to be refreshed by the filter func.
     */
    if (gtk_tree_model_iter_parent (model, &parent_iter, iter)) {
        parent_path = gtk_tree_model_get_path (model, &parent_iter);
    }
    if (parent_path) {
        gtk_tree_model_row_changed (model, parent_path, &parent_iter);
        gtk_tree_path_free (parent_path);
    }

out:
    g_object_unref (individual);
    tp_clear_object (&contact);
    tp_clear_object (&pixbuf);

    return FALSE;
}

static gboolean
main_window_flash_cb (EmpathyMainWindow *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkTreeModel     *model;
    GSList           *events, *l;
    gboolean          found_event = FALSE;
    FlashForeachData  data;

    priv->flash_on = !priv->flash_on;
    data.on = priv->flash_on;
    model = GTK_TREE_MODEL (priv->individual_store);

    events = empathy_event_manager_get_events (priv->event_manager);
    for (l = events; l; l = l->next) {
        data.event = l->data;
        data.window = window;
        if (!data.event->contact || !data.event->must_ack) {
            continue;
        }

        found_event = TRUE;
        gtk_tree_model_foreach (model,
                    main_window_flash_foreach,
                    &data);
    }

    if (!found_event) {
        main_window_flash_stop (window);
    }

    return TRUE;
}

static void
main_window_flash_start (EmpathyMainWindow *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);

    if (priv->flash_timeout_id != 0) {
        return;
    }

    DEBUG ("Start flashing");
    priv->flash_timeout_id = g_timeout_add (FLASH_TIMEOUT,
                        (GSourceFunc) main_window_flash_cb,
                        window);
    main_window_flash_cb (window);
}

static void
main_window_remove_auth (EmpathyMainWindow *window,
             EmpathyEvent      *event)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkWidget *error_widget;

    error_widget = g_hash_table_lookup (priv->auths, event);
    if (error_widget != NULL) {
        gtk_widget_destroy (error_widget);
        g_hash_table_remove (priv->auths, event);
    }
}

static void
main_window_auth_add_clicked_cb (GtkButton         *button,
                 EmpathyMainWindow *window)
{
    EmpathyEvent *event;

    event = g_object_get_data (G_OBJECT (button), "event");

    empathy_event_approve (event);

    main_window_remove_auth (window, event);
}

static void
main_window_auth_close_clicked_cb (GtkButton         *button,
                   EmpathyMainWindow *window)
{
    EmpathyEvent *event;

    event = g_object_get_data (G_OBJECT (button), "event");

    empathy_event_decline (event);
    main_window_remove_auth (window, event);
}

static void
main_window_auth_display (EmpathyMainWindow *window,
              EmpathyEvent      *event)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    TpAccount *account = event->account;
    GtkWidget *info_bar;
    GtkWidget *content_area;
    GtkWidget *image;
    GtkWidget *label;
    GtkWidget *add_button;
    GtkWidget *close_button;
    GtkWidget *action_area;
    GtkWidget *action_table;
    const gchar *icon_name;
    gchar *str;

    if (g_hash_table_lookup (priv->auths, event) != NULL) {
        return;
    }

    info_bar = gtk_info_bar_new ();
    gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_QUESTION);

    gtk_widget_set_no_show_all (info_bar, TRUE);
    gtk_box_pack_start (GTK_BOX (priv->auth_vbox), info_bar, FALSE, TRUE, 0);
    gtk_widget_show (info_bar);

    icon_name = tp_account_get_icon_name (account);
    image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
    gtk_widget_show (image);

    str = g_markup_printf_escaped ("<b>%s</b>\n%s",
                       tp_account_get_display_name (account),
                       _("Password required"));

    label = gtk_label_new (str);
    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
    gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
    gtk_widget_show (label);

    g_free (str);

    content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
    gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0);

    image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
    add_button = gtk_button_new ();
    gtk_button_set_image (GTK_BUTTON (add_button), image);
    gtk_widget_set_tooltip_text (add_button, _("Provide Password"));
    gtk_widget_show (add_button);

    image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON);
    close_button = gtk_button_new ();
    gtk_button_set_image (GTK_BUTTON (close_button), image);
    gtk_widget_set_tooltip_text (close_button, _("Disconnect"));
    gtk_widget_show (close_button);

    action_table = gtk_table_new (1, 2, FALSE);
    gtk_table_set_col_spacings (GTK_TABLE (action_table), 6);
    gtk_widget_show (action_table);

    action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
    gtk_box_pack_start (GTK_BOX (action_area), action_table, FALSE, FALSE, 0);

    gtk_table_attach (GTK_TABLE (action_table), add_button, 0, 1, 0, 1,
              (GtkAttachOptions) (GTK_SHRINK),
              (GtkAttachOptions) (GTK_SHRINK), 0, 0);
    gtk_table_attach (GTK_TABLE (action_table), close_button, 1, 2, 0, 1,
              (GtkAttachOptions) (GTK_SHRINK),
              (GtkAttachOptions) (GTK_SHRINK), 0, 0);

    g_object_set_data_full (G_OBJECT (info_bar),
                "event", event, NULL);
    g_object_set_data_full (G_OBJECT (add_button),
                "event", event, NULL);
    g_object_set_data_full (G_OBJECT (close_button),
                "event", event, NULL);

    g_signal_connect (add_button, "clicked",
              G_CALLBACK (main_window_auth_add_clicked_cb),
              window);
    g_signal_connect (close_button, "clicked",
              G_CALLBACK (main_window_auth_close_clicked_cb),
              window);

    gtk_widget_show (priv->auth_vbox);

    g_hash_table_insert (priv->auths, event, info_bar);
}

static void
modify_event_count (GtkTreeModel *model,
            GtkTreeIter *iter,
            EmpathyEvent *event,
            gboolean increase)
{
    FolksIndividual *individual;
    EmpathyContact *contact;
    guint count;

    gtk_tree_model_get (model, iter,
                EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL, &individual,
                EMPATHY_INDIVIDUAL_STORE_COL_EVENT_COUNT, &count,
                -1);

    if (individual == NULL)
        return;

    increase ? count++ : count--;

    contact = empathy_contact_dup_from_folks_individual (individual);
    if (contact == event->contact) {
        gtk_tree_store_set (GTK_TREE_STORE (model), iter,
                    EMPATHY_INDIVIDUAL_STORE_COL_EVENT_COUNT, count, -1);
    }

    tp_clear_object (&contact);
    g_object_unref (individual);
}

static gboolean
increase_event_count_foreach (GtkTreeModel *model,
                  GtkTreePath *path,
                  GtkTreeIter *iter,
                  gpointer user_data)
{
    EmpathyEvent *event = user_data;

    modify_event_count (model, iter, event, TRUE);

    return FALSE;
}

static void
increase_event_count (EmpathyMainWindow *self,
              EmpathyEvent *event)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (self);
    GtkTreeModel *model;

    model = GTK_TREE_MODEL (priv->individual_store);

    gtk_tree_model_foreach (model, increase_event_count_foreach, event);
}

static gboolean
decrease_event_count_foreach (GtkTreeModel *model,
                  GtkTreePath *path,
                  GtkTreeIter *iter,
                  gpointer user_data)
{
    EmpathyEvent *event = user_data;

    modify_event_count (model, iter, event, FALSE);

    return FALSE;
}

static void
decrease_event_count (EmpathyMainWindow *self,
              EmpathyEvent *event)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (self);
    GtkTreeModel *model;

    model = GTK_TREE_MODEL (priv->individual_store);

    gtk_tree_model_foreach (model, decrease_event_count_foreach, event);
}

static void
main_window_event_added_cb (EmpathyEventManager *manager,
                EmpathyEvent        *event,
                EmpathyMainWindow   *window)
{
    if (event->contact) {
        increase_event_count (window, event);

        main_window_flash_start (window);
    } else if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
        main_window_auth_display (window, event);
    }
}

static void
main_window_event_removed_cb (EmpathyEventManager *manager,
                  EmpathyEvent        *event,
                  EmpathyMainWindow   *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    FlashForeachData data;

    if (event->type == EMPATHY_EVENT_TYPE_AUTH) {
        main_window_remove_auth (window, event);
        return;
    }

    if (!event->contact) {
        return;
    }

    decrease_event_count (window, event);

    data.on = FALSE;
    data.event = event;
    data.window = window;
    gtk_tree_model_foreach (GTK_TREE_MODEL (priv->individual_store),
                main_window_flash_foreach,
                &data);
}

static void
main_window_row_activated_cb (EmpathyContactListView *view,
                  GtkTreePath            *path,
                  GtkTreeViewColumn      *col,
                  EmpathyMainWindow      *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    EmpathyContact *contact = NULL;
    FolksIndividual *individual;
    GtkTreeModel   *model;
    GtkTreeIter     iter;
    GSList         *events, *l;

    model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->individual_view));
    gtk_tree_model_get_iter (model, &iter, path);

    gtk_tree_model_get (model, &iter,
                EMPATHY_INDIVIDUAL_STORE_COL_INDIVIDUAL,
                &individual,
                -1);

    if (individual != NULL) {
        contact = empathy_contact_dup_from_folks_individual (individual);
    }

    if (!contact) {
        goto OUT;
    }

    /* If the contact has an event activate it, otherwise the
     * default handler of row-activated will be called. */
    events = empathy_event_manager_get_events (priv->event_manager);
    for (l = events; l; l = l->next) {
        EmpathyEvent *event = l->data;

        if (event->contact == contact) {
            DEBUG ("Activate event");
            empathy_event_activate (event);

            /* We don't want the default handler of this signal
             * (e.g. open a chat) */
            g_signal_stop_emission_by_name (view, "row-activated");
            break;
        }
    }

    g_object_unref (contact);
OUT:
    tp_clear_object (&individual);
}

static void
main_window_row_deleted_cb (GtkTreeModel      *model,
                GtkTreePath       *path,
                EmpathyMainWindow *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkTreeIter help_iter;

    if (!gtk_tree_model_get_iter_first (model, &help_iter)) {
        priv->empty = TRUE;

        if (empathy_individual_view_is_searching (
                priv->individual_view)) {
            gchar *tmp;

            tmp = g_strdup_printf ("<b><span size='xx-large'>%s</span></b>",
                _("No match found"));

            gtk_label_set_markup (GTK_LABEL (priv->no_entry_label), tmp);
            g_free (tmp);

            gtk_label_set_line_wrap (GTK_LABEL (priv->no_entry_label),
                TRUE);

            gtk_notebook_set_current_page (
                    GTK_NOTEBOOK (priv->notebook), PAGE_NO_MATCH);
        }
    }
}

static void
main_window_row_inserted_cb (GtkTreeModel      *model,
                 GtkTreePath       *path,
                 GtkTreeIter       *iter,
                 EmpathyMainWindow *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);

    if (priv->empty) {
        priv->empty = FALSE;
        gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
                PAGE_CONTACT_LIST);
        gtk_widget_grab_focus (GTK_WIDGET (priv->individual_view));
    }
}

static void
main_window_remove_error (EmpathyMainWindow *window,
              TpAccount         *account)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkWidget *error_widget;

    error_widget = g_hash_table_lookup (priv->errors, account);
    if (error_widget != NULL) {
        gtk_widget_destroy (error_widget);
        g_hash_table_remove (priv->errors, account);
    }
}

static void
main_window_account_disabled_cb (TpAccountManager  *manager,
                 TpAccount         *account,
                 EmpathyMainWindow *window)
{
    main_window_remove_error (window, account);
}

static void
main_window_error_retry_clicked_cb (GtkButton         *button,
                    EmpathyMainWindow *window)
{
    TpAccount *account;

    account = g_object_get_data (G_OBJECT (button), "account");
    tp_account_reconnect_async (account, NULL, NULL);

    main_window_remove_error (window, account);
}

static void
main_window_error_edit_clicked_cb (GtkButton         *button,
                   EmpathyMainWindow *window)
{
    TpAccount *account;

    account = g_object_get_data (G_OBJECT (button), "account");

    empathy_accounts_dialog_show_application (
            gtk_widget_get_screen (GTK_WIDGET (button)),
            account, FALSE, FALSE);

    main_window_remove_error (window, account);
}

static void
main_window_error_close_clicked_cb (GtkButton         *button,
                    EmpathyMainWindow *window)
{
    TpAccount *account;

    account = g_object_get_data (G_OBJECT (button), "account");
    main_window_remove_error (window, account);
}

static void
main_window_error_display (EmpathyMainWindow *window,
               TpAccount         *account)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkWidget *info_bar;
    GtkWidget *content_area;
    GtkWidget *label;
    GtkWidget *image;
    GtkWidget *retry_button;
    GtkWidget *edit_button;
    GtkWidget *close_button;
    GtkWidget *action_area;
    GtkWidget *action_table;
    gchar     *str;
    const gchar     *icon_name;
    const gchar *error_message;
    gboolean user_requested;

    error_message =
        empathy_account_get_error_message (account, &user_requested);

    if (user_requested) {
        return;
    }

    str = g_markup_printf_escaped ("<b>%s</b>\n%s",
                           tp_account_get_display_name (account),
                           error_message);

    info_bar = g_hash_table_lookup (priv->errors, account);
    if (info_bar) {
        label = g_object_get_data (G_OBJECT (info_bar), "label");

        /* Just set the latest error and return */
        gtk_label_set_markup (GTK_LABEL (label), str);
        g_free (str);

        return;
    }

    info_bar = gtk_info_bar_new ();
    gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_ERROR);

    gtk_widget_set_no_show_all (info_bar, TRUE);
    gtk_box_pack_start (GTK_BOX (priv->errors_vbox), info_bar, FALSE, TRUE, 0);
    gtk_widget_show (info_bar);

    icon_name = tp_account_get_icon_name (account);
    image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_SMALL_TOOLBAR);
    gtk_widget_show (image);

    label = gtk_label_new (str);
    gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
    gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
    gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
    gtk_widget_show (label);
    g_free (str);

    content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
    gtk_box_pack_start (GTK_BOX (content_area), image, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (content_area), label, TRUE, TRUE, 0);

    image = gtk_image_new_from_stock (GTK_STOCK_REFRESH, GTK_ICON_SIZE_BUTTON);
    retry_button = gtk_button_new ();
    gtk_button_set_image (GTK_BUTTON (retry_button), image);
    gtk_widget_set_tooltip_text (retry_button, _("Reconnect"));
    gtk_widget_show (retry_button);

    image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON);
    edit_button = gtk_button_new ();
    gtk_button_set_image (GTK_BUTTON (edit_button), image);
    gtk_widget_set_tooltip_text (edit_button, _("Edit Account"));
    gtk_widget_show (edit_button);

    image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON);
    close_button = gtk_button_new ();
    gtk_button_set_image (GTK_BUTTON (close_button), image);
    gtk_widget_set_tooltip_text (close_button, _("Close"));
    gtk_widget_show (close_button);

    action_table = gtk_table_new (1, 3, FALSE);
    gtk_table_set_col_spacings (GTK_TABLE (action_table), 2);
    gtk_widget_show (action_table);

    action_area = gtk_info_bar_get_action_area (GTK_INFO_BAR (info_bar));
    gtk_box_pack_start (GTK_BOX (action_area), action_table, FALSE, FALSE, 0);

    gtk_table_attach (GTK_TABLE (action_table), retry_button, 0, 1, 0, 1,
                                        (GtkAttachOptions) (GTK_SHRINK),
                                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
    gtk_table_attach (GTK_TABLE (action_table), edit_button, 1, 2, 0, 1,
                                        (GtkAttachOptions) (GTK_SHRINK),
                                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);
    gtk_table_attach (GTK_TABLE (action_table), close_button, 2, 3, 0, 1,
                                        (GtkAttachOptions) (GTK_SHRINK),
                                        (GtkAttachOptions) (GTK_SHRINK), 0, 0);

    g_object_set_data (G_OBJECT (info_bar), "label", label);
    g_object_set_data_full (G_OBJECT (info_bar),
                "account", g_object_ref (account),
                g_object_unref);
    g_object_set_data_full (G_OBJECT (edit_button),
                "account", g_object_ref (account),
                g_object_unref);
    g_object_set_data_full (G_OBJECT (close_button),
                "account", g_object_ref (account),
                g_object_unref);
    g_object_set_data_full (G_OBJECT (retry_button),
                "account", g_object_ref (account),
                g_object_unref);

    g_signal_connect (edit_button, "clicked",
              G_CALLBACK (main_window_error_edit_clicked_cb),
              window);
    g_signal_connect (close_button, "clicked",
              G_CALLBACK (main_window_error_close_clicked_cb),
              window);
    g_signal_connect (retry_button, "clicked",
              G_CALLBACK (main_window_error_retry_clicked_cb),
              window);

    gtk_widget_set_tooltip_text (priv->errors_vbox, error_message);
    gtk_widget_show (priv->errors_vbox);

    g_hash_table_insert (priv->errors, g_object_ref (account), info_bar);
}

static void
main_window_update_status (EmpathyMainWindow *window)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    gboolean connected, connecting;
    GList *l, *children;

    connected = empathy_account_manager_get_accounts_connected (&connecting);

    /* Update the spinner state */
    if (connecting) {
        gtk_spinner_start (GTK_SPINNER (priv->throbber));
        gtk_widget_show (priv->throbber_tool_item);
    } else {
        gtk_spinner_stop (GTK_SPINNER (priv->throbber));
        gtk_widget_hide (priv->throbber_tool_item);
    }

    /* Update widgets sensibility */
    for (l = priv->actions_connected; l; l = l->next) {
        gtk_action_set_sensitive (l->data, connected);
    }

    /* Update favourite rooms sensitivity */
    children = gtk_container_get_children (GTK_CONTAINER (priv->room_menu));
    for (l = children; l != NULL; l = l->next) {
        if (g_object_get_data (G_OBJECT (l->data), "is_favorite") != NULL) {
            gtk_widget_set_sensitive (GTK_WIDGET (l->data), connected);
        }
    }
    g_list_free (children);
}

static char *
main_window_account_to_action_name (TpAccount *account)
{
    char *r;

    /* action names can't have '/' in them, replace it with '.' */
    r = g_strdup (tp_account_get_path_suffix (account));
    r = g_strdelimit (r, "/", '.');

    return r;
}

static void
main_window_balance_activate_cb (GtkAction         *action,
                 EmpathyMainWindow *window)
{
    const char *uri;

    uri = g_object_get_data (G_OBJECT (action), "manage-credit-uri");

    if (!tp_str_empty (uri)) {
        DEBUG ("Top-up credit URI: %s", uri);
        empathy_url_show (GTK_WIDGET (window), uri);
    } else {
        DEBUG ("unknown protocol for top-up");
    }
}

static void
main_window_balance_update_balance (GtkAction   *action,
                    TpConnection *conn)
{
    TpAccount *account = tp_connection_get_account (conn);
    GtkWidget *label;
    int amount = 0;
    guint scale = G_MAXINT32;
    const gchar *currency = "";
    char *money, *str;

    if (!tp_connection_get_balance (conn, &amount, &scale, &currency))
        return;

    if (amount == 0 &&
        scale == G_MAXINT32 &&
        tp_str_empty (currency)) {
        /* unknown balance */
        money = g_strdup ("--");
    } else {
        char *tmp = empathy_format_currency (amount, scale, currency);

        money = g_strdup_printf ("%s %s", currency, tmp);
        g_free (tmp);
    }

    /* Translators: this string will be something like:
     *   Top up My Account ($1.23)..." */
    str = g_strdup_printf (_("Top up %s (%s)..."),
        tp_account_get_display_name (account),
        money);

    gtk_action_set_label (action, str);
    g_free (str);

    /* update the money label in the roster */
    label = g_object_get_data (G_OBJECT (action), "money-label");

    gtk_label_set_text (GTK_LABEL (label), money);
    g_free (money);
}

static void
main_window_balance_changed_cb (TpConnection      *conn,
                guint balance,
                guint scale,
                const gchar *currency,
                GtkAction *action)
{
    main_window_balance_update_balance (action, conn);
}

static GtkAction *
main_window_setup_balance_create_action (EmpathyMainWindow *window,
                     TpAccount *account)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkAction *action;
    char *name, *ui;
    guint merge_id;
    GError *error = NULL;

    /* create the action group if required */
    if (priv->balance_action_group == NULL) {
        priv->balance_action_group =
            gtk_action_group_new ("balance-action-group");

        gtk_ui_manager_insert_action_group (priv->ui_manager,
            priv->balance_action_group, -1);
    }

    /* create the action */
    name = main_window_account_to_action_name (account);
    action = gtk_action_new (name,
        tp_account_get_display_name (account),
        _("Top up account credit"),
        NULL);
    g_object_bind_property (account, "icon-name", action, "icon-name",
        G_BINDING_SYNC_CREATE);

    g_signal_connect (action, "activate",
        G_CALLBACK (main_window_balance_activate_cb), window);

    gtk_action_group_add_action (priv->balance_action_group, action);
    g_object_unref (action);

    ui = g_strdup_printf (
        "<ui>"
        " <menubar name='menubar'>"
        "  <menu action='view'>"
        "   <placeholder name='view_balance_placeholder'>"
        "    <menuitem action='%s'/>"
        "   </placeholder>"
        "  </menu>"
        " </menubar>"
        "</ui>",
        name);

    merge_id = gtk_ui_manager_add_ui_from_string (priv->ui_manager,
        ui, -1, &error);
    if (error != NULL) {
        DEBUG ("Failed to add balance UI for %s: %s",
            tp_account_get_display_name (account),
            error->message);
        g_error_free (error);
    }

    g_object_set_data (G_OBJECT (action),
        "merge-id", GUINT_TO_POINTER (merge_id));

    g_free (name);
    g_free (ui);

    return action;
}

static GtkWidget *
main_window_setup_balance_create_widget (EmpathyMainWindow *window,
                     GtkAction         *action,
                     TpAccount *account)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkWidget *hbox, *image, *label, *button;

    hbox = gtk_hbox_new (FALSE, 6);

    /* protocol icon */
    image = gtk_image_new ();
    gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
    g_object_bind_property (action, "icon-name", image, "icon-name",
        G_BINDING_SYNC_CREATE);

    /* account name label */
    label = gtk_label_new ("");
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
    g_object_bind_property (account, "display-name", label, "label",
        G_BINDING_SYNC_CREATE);

    /* balance label */
    label = gtk_label_new ("");
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
    g_object_set_data (G_OBJECT (action), "money-label", label);

    /* top up button */
    button = gtk_button_new_with_label (_("Top Up..."));
    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
    g_signal_connect_swapped (button, "clicked",
        G_CALLBACK (gtk_action_activate), action);

    gtk_box_pack_start (GTK_BOX (priv->balance_vbox), hbox, FALSE, TRUE, 0);
    gtk_widget_show_all (hbox);

    /* tie the lifetime of the widget to the lifetime of the action */
    g_object_weak_ref (G_OBJECT (action),
        (GWeakNotify) gtk_widget_destroy, hbox);

    return hbox;
}

static void
main_window_setup_balance (EmpathyMainWindow *window,
               TpAccount         *account)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    TpConnection *conn = tp_account_get_connection (account);
    GtkAction *action;
    const gchar *uri;

    if (conn == NULL)
        return;

    if (!tp_proxy_is_prepared (conn, TP_CONNECTION_FEATURE_BALANCE))
        return;

    DEBUG ("Setting up balance for acct: %s",
        tp_account_get_display_name (account));

    /* create the action */
    action = main_window_setup_balance_create_action (window, account);

    if (action == NULL)
        return;

    gtk_action_set_visible (priv->view_balance_show_in_roster, TRUE);

    /* create the display widget */
    main_window_setup_balance_create_widget (window, action, account);

    /* check the current balance and monitor for any changes */
    uri = tp_connection_get_balance_uri (conn);

    g_object_set_data_full (G_OBJECT (action), "manage-credit-uri",
        g_strdup (uri), g_free);
    gtk_action_set_sensitive (GTK_ACTION (action), !tp_str_empty (uri));

    main_window_balance_update_balance (GTK_ACTION (action), conn);

    g_signal_connect (conn, "balance-changed",
        G_CALLBACK (main_window_balance_changed_cb), action);

}

static void
main_window_remove_balance_action (EmpathyMainWindow *window,
                   TpAccount         *account)
{
    EmpathyMainWindowPriv *priv = GET_PRIV (window);
    GtkAction *action;
    char *name;
    GList *a;

    if (priv->balance_action_group == NULL)
        return;

    name = main_window_account_to_action_name (account);

    action = gtk_action_group_get_action (
        priv->balance_action_group, name);

    if (action != NULL) {
        guint merge_id;

        DEBUG ("Removing action");

        merge_id = GPOINTER_TO_UINT (g_object_get_data (
            G_OBJECT (action),
            "merge-id"));

        gtk_ui_manager_remove_ui (priv->ui_manager,
            merge_id);