Code

Indent support for XSLT extensions output.
[inkscape.git] / src / pedro / pedrogui.cpp
1 /*
2  * Simple demo GUI for the Pedro mini-XMPP client.
3  *
4  * Authors:
5  *   Bob Jamison
6  *
7  * Copyright (C) 2005-2007 Bob Jamison
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public
11  *  License as published by the Free Software Foundation; either
12  *  version 2.1 of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  */
24 #include "pedrogui.h"
26 #include <stdarg.h>
28 namespace Pedro
29 {
33 //#########################################################################
34 //# I C O N S
35 //#########################################################################
37 static const guint8 icon_available[] =
38 { ""
39   /* Pixbuf magic (0x47646b50) */
40   "GdkP"
41   /* length: header (24) + pixel_data (672) */
42   "\0\0\2\270"
43   /* pixdata_type (0x1010002) */
44   "\1\1\0\2"
45   /* rowstride (48) */
46   "\0\0\0""0"
47   /* width (12) */
48   "\0\0\0\14"
49   /* height (14) */
50   "\0\0\0\16"
51   /* pixel_data: */
52   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333"
53   "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
54   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377"
55   "\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0"
56   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377"
57   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\37733"
58   "3\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377"
59   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
60   "\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377"
61   "\377\0""333\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\0"
62   "\0\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377\377\377"
63   "\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377"
64   "\0\377\0\0\0\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377"
65   "\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377"
66   "\0\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377"
67   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377"
68   "\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0\377333\377\377"
69   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""3"
70   "33\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0"
71   "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
72   "\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377"
73   "\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"
74   "\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0\0\377"
75   "\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
76   "\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0\0\377"
77   "\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
78   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377"
79   "\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
80   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
81   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
82   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0"};
85 static const guint8 icon_away[] =
86 { ""
87   /* Pixbuf magic (0x47646b50) */
88   "GdkP"
89   /* length: header (24) + pixel_data (672) */
90   "\0\0\2\270"
91   /* pixdata_type (0x1010002) */
92   "\1\1\0\2"
93   /* rowstride (48) */
94   "\0\0\0""0"
95   /* width (12) */
96   "\0\0\0\14"
97   /* height (14) */
98   "\0\0\0\16"
99   /* pixel_data: */
100   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
101   "\0""333\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
102   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
103   "\377\0""333\377\377\377\0\377\377\377\0\377333\377\377\377\377\0\377"
104   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
105   "\377\377\0""333\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
106   "\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"
107   "\377\377\377\0\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0"
108   "\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\377\377\0\377\377\377"
109   "\0\377\377\377\0\377\0\0\377\377\377\377\377\377\377\377\377\377\377"
110   "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
111   "\377\377\377\377\377\377\0\0\377\377\377\377\0\377\0\0\377\377\377\377"
112   "\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377"
113   "\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\0\0\377"
114   "\377\0\0\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\0\0"
115   "\0\377\0\0\0\377\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377"
116   "\377\377\0\0\377\377\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377"
117   "\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\0\0\0\377\377\377"
118   "\377\377\377\0\0\377\377\0\0\377\377\377\377\377\0\0\0\377\377\377\377"
119   "\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\377\377\377"
120   "\377\0\0\0\377\377\377\377\377\377\0\0\377\377\377\377\0\377\0\0\377"
121   "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
122   "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0"
123   "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377\377\0\0\377"
124   "\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0\377\377\0\0"
125   "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
126   "\377\0\377\377\377\0LLL\377333\377\0\0\0\377\0\0\0\377LLL\377\377\377"
127   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
128   "\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377\377\377"
129   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
130   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
131   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
132   "\0"};
135 static const guint8 icon_chat[] =
136 { ""
137   /* Pixbuf magic (0x47646b50) */
138   "GdkP"
139   /* length: header (24) + pixel_data (672) */
140   "\0\0\2\270"
141   /* pixdata_type (0x1010002) */
142   "\1\1\0\2"
143   /* rowstride (48) */
144   "\0\0\0""0"
145   /* width (12) */
146   "\0\0\0\14"
147   /* height (14) */
148   "\0\0\0\16"
149   /* pixel_data: */
150   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377"
151   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
152   "\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377"
153   "\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0"
154   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377"
155   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377\377\377"
156   "\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377"
157   "\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377\377\377\0\37733"
158   "3\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377"
159   "fff\377\377\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377333\377"
160   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377fff"
161   "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\0\0\0\377\0"
162   "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""33"
163   "3\377\377\377\0\377fff\377\377\377\0\377\0\0\0\377\377\377\0\377\377"
164   "\377\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377"
165   "\377\0""333\377\377\377\0\377fff\377\0\0\0\377\377\377\0\377\377\377"
166   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\377"
167   "\0\377\377\377\0\377\377\377\0""333\377\0\0\0\377\377\377\0\377\377\377"
168   "\0\377\0\0\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377\377\0\377"
169   "\0\0\0\377\377\377\377\0\377\377\377\0""333\377\0\0\0\377\377\377\0\377"
170   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
171   "\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0LLL\377\0\0\0\377"
172   "\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\0\0\0\377\377\377"
173   "\0\377\377\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0LLL\377333"
174   "\377\0\0\0\377\377\377\0\377\377\377\0\377\0\0\0\377\377\377\0\377\377"
175   "\377\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
176   "\377\0""333\377333\377\0\0\0\377\377\377\0\377\377\377\0\377\377\377"
177   "\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
178   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\0\0\0\377"
179   "\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0"};
182 static const guint8 icon_dnd[] =
183 { ""
184   /* Pixbuf magic (0x47646b50) */
185   "GdkP"
186   /* length: header (24) + pixel_data (672) */
187   "\0\0\2\270"
188   /* pixdata_type (0x1010002) */
189   "\1\1\0\2"
190   /* rowstride (48) */
191   "\0\0\0""0"
192   /* width (12) */
193   "\0\0\0\14"
194   /* height (14) */
195   "\0\0\0\16"
196   /* pixel_data: */
197   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377333\377\377"
198   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
199   "\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377\377"
200   "\0\377\377\377\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0"
201   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377"
202   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377333\377\377\377\377"
203   "\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377\377"
204   "\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377\377\377\0\37733"
205   "3\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377"
206   "fff\377\377\377\0\377fff\377\377\377\0\377fff\377\377\377\0\377333\377"
207   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\0\377fff"
208   "\377\377\377\0\377\377\377\0\377\377\377\0\377\177\0\0\377\177\0\0\377"
209   "\177\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"
210   "333\377\377\377\0\377fff\377\377\377\0\377\177\0\0\377\377\0\0\377\377"
211   "\0\0\377\377\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\377\377"
212   "\377\0""333\377\377\377\0\377fff\377\177\0\0\377\377\377\377\377fff\377"
213   "\377\0\0\377fff\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377"
214   "\377\0\377\377\377\0""333\377\177\0\0\377\377\0\0\377fff\377\377\377"
215   "\377\377fff\377\377\377\377\377fff\377\377\0\0\377\177\0\0\377\377\377"
216   "\377\0\377\377\377\0""333\377\177\0\0\377\377\0\0\377\377\0\0\377fff"
217   "\377\377\377\377\377fff\377\377\0\0\377\377\0\0\377\177\0\0\377\377\377"
218   "\377\0\377\377\377\0LLL\377\177\0\0\377\377\0\0\377fff\377\377\377\377"
219   "\377fff\377\377\377\377\377fff\377\377\0\0\377\177\0\0\377\377\377\377"
220   "\0\377\377\377\0LLL\377333\377\177\0\0\377\377\377\377\377fff\377\377"
221   "\0\0\377fff\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377\377"
222   "\0\377\377\377\0\377\377\377\0""333\377333\377\177\0\0\377\377\0\0\377"
223   "\377\0\0\377\377\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\377"
224   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
225   "\377\377\0\177\0\0\377\177\0\0\377\177\0\0\377\377\377\377\0\377\377"
226   "\377\0\377\377\377\0"};
229 static const guint8 icon_error[] =
230 { ""
231   /* Pixbuf magic (0x47646b50) */
232   "GdkP"
233   /* length: header (24) + pixel_data (672) */
234   "\0\0\2\270"
235   /* pixdata_type (0x1010002) */
236   "\1\1\0\2"
237   /* rowstride (48) */
238   "\0\0\0""0"
239   /* width (12) */
240   "\0\0\0\14"
241   /* height (14) */
242   "\0\0\0\16"
243   /* pixel_data: */
244   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
245   "\0""333\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
246   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377"
247   "\377\377\377\0\0\0\0\377\350\350\350\377333\377\377\377\377\0\377\377"
248   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377"
249   "\350\350\350\377fff\377\0\0\0\377\350\350\350\377\350\350\350\377333"
250   "\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377"
251   "\350\350\350\377\350\350\350\377\350\350\350\377\0\0\0\377\350\350\350"
252   "\377\350\350\350\377\350\350\350\377333\377\377\377\377\0\377\377\377"
253   "\0\377\377\377\0""333\377\350\350\350\377\350\350\350\377\0\0\0\377\0"
254   "\0\0\377fff\377\350\350\350\377\350\350\350\377333\377\377\377\377\0"
255   "\377\377\377\0\377\377\377\0""333\377\350\350\350\377\350\350\350\377"
256   "\0\0\0\377\350\350\350\377\0\0\0\377\0\0\0\377\0\0\0\377333\377\377\377"
257   "\377\0\377\377\377\0\377\377\377\0""333\377\350\350\350\377\0\0\0\377"
258   "\350\350\350\377\0\0\0\377\350\350\350\377\350\350\350\377\350\350\350"
259   "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""3"
260   "33\377\350\350\350\377\0\0\0\377\0\0\0\377\0\0\0\377\350\350\350\377"
261   "fff\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
262   "\377\0""333\377\0\0\0\377\350\350\350\377\350\350\350\377\350\350\350"
263   "\377\0\0\0\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
264   "\377\0\377\377\377\0\377\377\377\0""333\377\350\350\350\377\350\350\350"
265   "\377\350\350\350\377333\377\377\377\377\0\377\377\377\0\377\377\377\0"
266   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0"
267   "\377\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377"
268   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0"
269   "\0\377\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377"
270   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
271   "\377\0\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377"
272   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
273   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
274   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"};
277 static const guint8 icon_offline[] =
278 { ""
279   /* Pixbuf magic (0x47646b50) */
280   "GdkP"
281   /* length: header (24) + pixel_data (672) */
282   "\0\0\2\270"
283   /* pixdata_type (0x1010002) */
284   "\1\1\0\2"
285   /* rowstride (48) */
286   "\0\0\0""0"
287   /* width (12) */
288   "\0\0\0\14"
289   /* height (14) */
290   "\0\0\0\16"
291   /* pixel_data: */
292   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333"
293   "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
294   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377"
295   "\377\377\377\377\377\377\377\377\377\377333\377\377\377\377\0\377\377"
296   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377"
297   "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
298   "\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
299   "\377\0""333\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377"
300   "\377\377\377\377\377\377\377\377\377\377\377\377\377\377333\377\377\377"
301   "\377\0\377\377\377\0\377\377\377\0""333\377\377\377\377\377\377\377\377"
302   "\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377\377\377\377"
303   "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377"
304   "\377\377\377\377\377\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377"
305   "\377\377\377\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377"
306   "\0""333\377\377\377\377\377\377\377\377\377\377\377\377\377\0\0\0\377"
307   "\377\377\377\377\377\377\377\377\377\377\377\377333\377\377\377\377\0"
308   "\377\377\377\0\377\377\377\0\377\377\377\0""333\377\377\377\377\377\377"
309   "\377\377\377\0\0\0\377\377\377\377\377\377\377\377\377333\377\377\377"
310   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377"
311   "\377\377\377\377\377\377\377\377\0\0\0\377\377\377\377\377\377\377\377"
312   "\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
313   "\377\377\0\377\377\377\0""333\377\377\377\377\377\377\377\377\377\377"
314   "\377\377\377333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
315   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377\0\0"
316   "\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377"
317   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0LLL\377\0\0\0\377"
318   "\0\0\0\377\0\0\0\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0"
319   "\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377"
320   "\0\0\0\0\377\0\0\0\377\0\0\0\377\377\377\377\0\377\377\377\0\377\377"
321   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
322   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
323   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0"};
326 static const guint8 icon_xa[] =
327 { ""
328   /* Pixbuf magic (0x47646b50) */
329   "GdkP"
330   /* length: header (24) + pixel_data (672) */
331   "\0\0\2\270"
332   /* pixdata_type (0x1010002) */
333   "\1\1\0\2"
334   /* rowstride (48) */
335   "\0\0\0""0"
336   /* width (12) */
337   "\0\0\0\14"
338   /* height (14) */
339   "\0\0\0\16"
340   /* pixel_data: */
341   "\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377333\377333\377"
342   "333\377\377\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
343   "\377\0\377\377\377\0\377\377\377\0\377\0\0\377333\377\377\377\0\377\377"
344   "\377\0\377\377\377\0\377333\377\377\0\0\377\377\377\377\0\377\377\377"
345   "\0\377\377\377\0\377\377\377\0\377\377\377\0\377\0\0\377\377\377\0\377"
346   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\0\0\377"
347   "\177\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0""333\377\377\0\0"
348   "\377\377\377\0\377fff\377\377\377\0\377\177\0\0\377\177\0\0\377\377\0"
349   "\0\377\377\377\377\377\177\0\0\377\377\377\377\0\377\377\377\0""333\377"
350   "\377\0\0\377\177\0\0\377\177\0\0\377\177\0\0\377\377\377\377\377\377"
351   "\377\377\377\377\377\377\377\0\0\0\377\0\0\0\377\177\0\0\377\177\0\0"
352   "\377\177\0\0\377\377\0\0\377\377\377\377\377\377\377\377\377\377\377"
353   "\377\377\262\262\262\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377"
354   "\377\377\177\0\0\377\177\0\0\377\377\377\377\377\262\262\262\377\0\0"
355   "\0\377\262\262\262\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377"
356   "\377\262\262\262\377\0\0\0\377\177\0\0\377\177\0\0\377\377\377\377\377"
357   "\0\0\0\377\377\377\377\377\0\0\0\377\0\0\0\377\377\377\377\377\0\0\0"
358   "\377\0\0\0\377\377\377\377\377\0\0\0\377\177\0\0\377\177\0\0\377\377"
359   "\377\377\377\0\0\0\377\377\377\377\377\0\0\0\377\377\377\377\377\0\0"
360   "\0\377\0\0\0\377\377\377\377\377\377\377\377\377\377\377\377\377\177"
361   "\0\0\377\377\377\377\0\177\0\0\377\262\262\262\377\0\0\0\377\262\262"
362   "\262\377\377\377\377\377\377\377\377\377\377\377\377\377\177\0\0\377"
363   "\177\0\0\377\177\0\0\377\377\377\377\0\377\377\377\0\177\0\0\377\377"
364   "\377\377\377\377\377\377\377\177\0\0\377\177\0\0\377\177\0\0\377\177"
365   "\0\0\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
366   "\377\377\0\177\0\0\377\177\0\0\377\177\0\0\377333\377\0\0\0\377\0\0\0"
367   "\377LLL\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377"
368   "\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0""333\377333\377"
369   "333\377\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
370   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
371   "\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377\377\0\377\377"
372   "\377\0\377\377\377\0\377\377\377\0"};
375 //#########################################################################
376 //# R O S T E R
377 //#########################################################################
380 void Roster::doubleClickCallback(const Gtk::TreeModel::Path &path,
381                    Gtk::TreeViewColumn *col)
383     Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model();
384     Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection();
385     Gtk::TreeModel::iterator iter = sel->get_selected();
386     DOMString nick = iter->get_value(rosterColumns.userColumn);
387     //printf("Double clicked:%s\n", nick.c_str());
388     if (parent)
389         parent->doChat(nick);
393 void Roster::chatCallback()
395     Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model();
396     Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection();
397     Gtk::TreeModel::iterator iter = sel->get_selected();
398     DOMString nick = iter->get_value(rosterColumns.userColumn);
399     //printf("Chat with:%s\n", nick.c_str());
400     if (parent)
401         parent->doChat(nick);
404 void Roster::sendFileCallback()
406     Glib::RefPtr<Gtk::TreeModel> model = rosterView.get_model();
407     Glib::RefPtr<Gtk::TreeSelection> sel = rosterView.get_selection();
408     Gtk::TreeModel::iterator iter = sel->get_selected();
409     DOMString nick = iter->get_value(rosterColumns.userColumn);
410     //printf("Send file to:%s\n", nick.c_str());
411     if (parent)
412         parent->doSendFile(nick);
415 bool Roster::buttonPressCallback(GdkEventButton* event)
417     if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
418         {
419         Gtk::Widget *wid = uiManager->get_widget("/PopupMenu");
420         Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid);
421         popupMenu->popup(event->button, event->time);
422         return true;
423         }
424     else
425         return false;
428 bool Roster::doSetup()
430     set_size_request(200,200);
432     pixbuf_available = Gdk::Pixbuf::create_from_inline(
433                       sizeof(icon_available), icon_available, false);
434     pixbuf_away     = Gdk::Pixbuf::create_from_inline(
435                       sizeof(icon_away), icon_away, false);
436     pixbuf_chat     = Gdk::Pixbuf::create_from_inline(
437                       sizeof(icon_chat), icon_chat, false);
438     pixbuf_dnd      = Gdk::Pixbuf::create_from_inline(
439                       sizeof(icon_dnd), icon_dnd, false);
440     pixbuf_error    = Gdk::Pixbuf::create_from_inline(
441                       sizeof(icon_error), icon_error, false);
442     pixbuf_offline  = Gdk::Pixbuf::create_from_inline(
443                       sizeof(icon_offline), icon_offline, false);
444     pixbuf_xa       = Gdk::Pixbuf::create_from_inline(
445                       sizeof(icon_xa), icon_xa, false);
447     rosterView.setParent(this);
448     treeStore = Gtk::TreeStore::create(rosterColumns);
449     rosterView.set_model(treeStore);
451     Gtk::CellRendererText *rend0 = new Gtk::CellRendererText();
452     //rend0->property_background() = "gray";
453     //rend0->property_foreground() = "black";
454     rosterView.append_column("Group", *rend0);
455     Gtk::TreeViewColumn *col0 = rosterView.get_column(0);
456     col0->add_attribute(*rend0, "text", 0);
458     Gtk::CellRendererPixbuf *rend1 = new Gtk::CellRendererPixbuf();
459     rosterView.append_column("Status", *rend1);
460     Gtk::TreeViewColumn *col1 = rosterView.get_column(1);
461     col1->add_attribute(*rend1, "pixbuf", 1);
463     Gtk::CellRendererText *rend2 = new Gtk::CellRendererText();
464     rosterView.append_column("Item", *rend2);
465     Gtk::TreeViewColumn *col2 = rosterView.get_column(2);
466     col2->add_attribute(*rend2, "text", 2);
468     Gtk::CellRendererText *rend3 = new Gtk::CellRendererText();
469     rosterView.append_column("Name", *rend3);
470     Gtk::TreeViewColumn *col3 = rosterView.get_column(3);
471     col3->add_attribute(*rend3, "text", 3);
473     Gtk::CellRendererText *rend4 = new Gtk::CellRendererText();
474     rosterView.append_column("Subscription", *rend4);
475     Gtk::TreeViewColumn *col4 = rosterView.get_column(4);
476     col4->add_attribute(*rend4, "text", 4);
478     rosterView.signal_row_activated().connect(
479         sigc::mem_fun(*this, &Roster::doubleClickCallback) );
481     add(rosterView);
482     set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
484     //##### POPUP MENU
485     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
487     actionGroup->add( Gtk::Action::create("UserMenu", "_User Menu") );
489     actionGroup->add( Gtk::Action::create("Chat",
490                                   Gtk::Stock::CONNECT, "Chat"),
491     sigc::mem_fun(*this, &Roster::chatCallback) );
492     actionGroup->add( Gtk::Action::create("SendFile",
493                                   Gtk::Stock::CONNECT, "Send file"),
494     sigc::mem_fun(*this, &Roster::sendFileCallback) );
497     uiManager = Gtk::UIManager::create();
499     uiManager->insert_action_group(actionGroup, 0);
501     Glib::ustring ui_info =
502         "<ui>"
503         "  <popup name='PopupMenu'>"
504         "    <menuitem action='Chat'/>"
505         "    <menuitem action='SendFile'/>"
506         "  </popup>"
507         "</ui>";
509     uiManager->add_ui_from_string(ui_info);
512     show_all_children();
514     return true;
518 /**
519  * Clear the roster
520  */
521 void Roster::clear()
523     treeStore->clear();
526 /**
527  * Regenerate the roster
528  */
529 void Roster::refresh()
531    if (!parent)
532         return;
533     treeStore->clear();
534     std::vector<XmppUser> items = parent->client.getRoster();
536     //## Add in tree fashion
537     DOMString lastGroup = "";
538     Gtk::TreeModel::Row row = *(treeStore->append());
539     row[rosterColumns.groupColumn] = "";
540     for (unsigned int i=0 ; i<items.size() ; i++)
541         {
542         XmppUser user = items[i];
543         if (user.group != lastGroup)
544             {
545             if (lastGroup.size()>0)
546                 row = *(treeStore->append());
547             row[rosterColumns.groupColumn] = user.group;
548             lastGroup = user.group;
549             }
550         Glib::RefPtr<Gdk::Pixbuf> pb = pixbuf_offline;
551         if (user.show == "available")
552             pb = pixbuf_available;
553         else if (user.show == "away")
554             pb = pixbuf_away;
555         else if (user.show == "chat")
556             pb = pixbuf_chat;
557         else if (user.show == "dnd")
558             pb = pixbuf_dnd;
559         else if (user.show == "xa")
560             pb = pixbuf_xa;
561         else
562             {
563             //printf("Unknown show for %s:'%s'\n", user.c_str(), show.c_str());
564             }
565         Gtk::TreeModel::Row childRow = *(treeStore->append(row.children()));
566         childRow[rosterColumns.statusColumn] = pb;
567         childRow[rosterColumns.userColumn]   = user.jid;
568         childRow[rosterColumns.nameColumn]   = user.nick;
569         childRow[rosterColumns.subColumn]    = user.subscription;
570         }
571     rosterView.expand_all();
574 //#########################################################################
575 //# M E S S A G E    L I S T
576 //#########################################################################
578 bool MessageList::doSetup()
580     set_size_request(400,200);
582     messageListBuffer = Gtk::TextBuffer::create();
583     messageList.set_buffer(messageListBuffer);
584     messageList.set_editable(false);
585     messageList.set_wrap_mode(Gtk::WRAP_WORD_CHAR);
587     Glib::RefPtr<Gtk::TextBuffer::TagTable> table =
588         messageListBuffer->get_tag_table();
589     Glib::RefPtr<Gtk::TextBuffer::Tag> color0 =
590         Gtk::TextBuffer::Tag::create("color0");
591     color0->property_foreground() = "DarkGreen";
592     color0->property_weight()     = Pango::WEIGHT_BOLD;
593     table->add(color0);
594     Glib::RefPtr<Gtk::TextBuffer::Tag> color1 =
595         Gtk::TextBuffer::Tag::create("color1");
596     color1->property_foreground() = "chocolate4";
597     color1->property_weight()     = Pango::WEIGHT_BOLD;
598     table->add(color1);
599     Glib::RefPtr<Gtk::TextBuffer::Tag> color2 =
600         Gtk::TextBuffer::Tag::create("color2");
601     color2->property_foreground() = "red4";
602     color2->property_weight()     = Pango::WEIGHT_BOLD;
603     table->add(color2);
604     Glib::RefPtr<Gtk::TextBuffer::Tag> color3 =
605         Gtk::TextBuffer::Tag::create("color3");
606     color3->property_foreground() = "MidnightBlue";
607     color3->property_weight()     = Pango::WEIGHT_BOLD;
608     table->add(color3);
609     Glib::RefPtr<Gtk::TextBuffer::Tag> color4 =
610         Gtk::TextBuffer::Tag::create("color4");
611     color4->property_foreground() = "turquoise4";
612     color4->property_weight()     = Pango::WEIGHT_BOLD;
613     table->add(color4);
614     Glib::RefPtr<Gtk::TextBuffer::Tag> color5 =
615         Gtk::TextBuffer::Tag::create("color5");
616     color5->property_foreground() = "OliveDrab";
617     color5->property_weight()     = Pango::WEIGHT_BOLD;
618     table->add(color5);
619     Glib::RefPtr<Gtk::TextBuffer::Tag> color6 =
620         Gtk::TextBuffer::Tag::create("color6");
621     color6->property_foreground() = "purple4";
622     color6->property_weight()     = Pango::WEIGHT_BOLD;
623     table->add(color6);
624     Glib::RefPtr<Gtk::TextBuffer::Tag> color7 =
625         Gtk::TextBuffer::Tag::create("color7");
626     color7->property_foreground() = "VioletRed4";
627     color7->property_weight()     = Pango::WEIGHT_BOLD;
628     table->add(color7);
630     add(messageList);
631     set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
634     show_all_children();
636     return true;
639 /**
640  * Clear all messages from the list
641  */
642 void MessageList::clear()
644     messageListBuffer->erase(messageListBuffer->begin(),
645                              messageListBuffer->end());
649 /**
650  * Post a message to the list
651  */
652 void MessageList::postMessage(const DOMString &from, const DOMString &msg)
654     DOMString out = "<";
655     out.append(from);
656     out.append("> ");
658     int val = 0;
659     for (unsigned int i=0 ; i<from.size() ; i++)
660        val += from[i];
661     val = val % 8;
663     char buf[16];
664     sprintf(buf, "color%d", val);
665     DOMString tagName = buf;
667     messageListBuffer->insert_with_tag(
668             messageListBuffer->end(), out, tagName);
669     messageListBuffer->insert(messageListBuffer->end(), msg);
670     messageListBuffer->insert(messageListBuffer->end(), "\n");
671     //Gtk::Adjustment *adj = get_vadjustment();
672     //adj->set_value(adj->get_upper()-adj->get_page_size());
673     Glib::RefPtr<Gtk::TextBuffer::Mark> mark =
674         messageListBuffer->create_mark("temp", messageListBuffer->end());
675     messageList.scroll_mark_onscreen(mark);
676     messageListBuffer->delete_mark(mark);
681 //#########################################################################
682 //# U S E R     L I S T
683 //#########################################################################
684 void UserList::doubleClickCallback(const Gtk::TreeModel::Path &path,
685                    Gtk::TreeViewColumn *col)
687     Glib::RefPtr<Gtk::TreeModel> model = userList.get_model();
688     Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection();
689     Gtk::TreeModel::iterator iter = sel->get_selected();
690     DOMString nick = iter->get_value(userListColumns.userColumn);
691     //printf("Double clicked:%s\n", nick.c_str());
692     if (parent)
693         parent->doChat(nick);
697 void UserList::chatCallback()
699     Glib::RefPtr<Gtk::TreeModel> model = userList.get_model();
700     Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection();
701     Gtk::TreeModel::iterator iter = sel->get_selected();
702     DOMString nick = iter->get_value(userListColumns.userColumn);
703     //printf("Chat with:%s\n", nick.c_str());
704     if (parent)
705         parent->doChat(nick);
708 void UserList::sendFileCallback()
710     Glib::RefPtr<Gtk::TreeModel> model = userList.get_model();
711     Glib::RefPtr<Gtk::TreeSelection> sel = userList.get_selection();
712     Gtk::TreeModel::iterator iter = sel->get_selected();
713     DOMString nick = iter->get_value(userListColumns.userColumn);
714     //printf("Send file to:%s\n", nick.c_str());
715     if (parent)
716         parent->doSendFile(nick);
719 bool UserList::buttonPressCallback(GdkEventButton* event)
721     if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
722         {
723         Gtk::Widget *wid = uiManager->get_widget("/PopupMenu");
724         Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid);
725         popupMenu->popup(event->button, event->time);
726         return true;
727         }
728     else
729         return false;
732 bool UserList::doSetup()
734     set_size_request(200,200);
736     setParent(NULL);
738     pixbuf_available = Gdk::Pixbuf::create_from_inline(
739                       sizeof(icon_available), icon_available, false);
740     pixbuf_away     = Gdk::Pixbuf::create_from_inline(
741                       sizeof(icon_away), icon_away, false);
742     pixbuf_chat     = Gdk::Pixbuf::create_from_inline(
743                       sizeof(icon_chat), icon_chat, false);
744     pixbuf_dnd      = Gdk::Pixbuf::create_from_inline(
745                       sizeof(icon_dnd), icon_dnd, false);
746     pixbuf_error    = Gdk::Pixbuf::create_from_inline(
747                       sizeof(icon_error), icon_error, false);
748     pixbuf_offline  = Gdk::Pixbuf::create_from_inline(
749                       sizeof(icon_offline), icon_offline, false);
750     pixbuf_xa       = Gdk::Pixbuf::create_from_inline(
751                       sizeof(icon_xa), icon_xa, false);
753     userList.setParent(this);
754     userListStore = Gtk::ListStore::create(userListColumns);
755     userList.set_model(userListStore);
757     Gtk::CellRendererPixbuf *rend0 = new Gtk::CellRendererPixbuf();
758     userList.append_column("Status", *rend0);
759     Gtk::TreeViewColumn *col0 = userList.get_column(0);
760     col0->add_attribute(*rend0, "pixbuf", 0);
762     Gtk::CellRendererText *rend1 = new Gtk::CellRendererText();
763     //rend1->property_background() = "gray";
764     //rend1->property_foreground() = "black";
765     userList.append_column("User", *rend1);
766     Gtk::TreeViewColumn *col1 = userList.get_column(1);
767     col1->add_attribute(*rend1, "text", 1);
769     userList.set_headers_visible(false);
771     userList.signal_row_activated().connect(
772         sigc::mem_fun(*this, &UserList::doubleClickCallback) );
774     add(userList);
775     set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
777     //##### POPUP MENU
778     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
780     actionGroup->add( Gtk::Action::create("UserMenu", "_User Menu") );
782     actionGroup->add( Gtk::Action::create("Chat",
783                                   Gtk::Stock::CONNECT, "Chat"),
784     sigc::mem_fun(*this, &UserList::chatCallback) );
785     actionGroup->add( Gtk::Action::create("SendFile",
786                                   Gtk::Stock::CONNECT, "Send file"),
787     sigc::mem_fun(*this, &UserList::sendFileCallback) );
790     uiManager = Gtk::UIManager::create();
792     uiManager->insert_action_group(actionGroup, 0);
794     Glib::ustring ui_info =
795         "<ui>"
796         "  <popup name='PopupMenu'>"
797         "    <menuitem action='Chat'/>"
798         "    <menuitem action='SendFile'/>"
799         "  </popup>"
800         "</ui>";
802     uiManager->add_ui_from_string(ui_info);
804     show_all_children();
806     return true;
809 /**
810  * Clear all messages from the list
811  */
812 void UserList::clear()
814     userListStore->clear();
818 /**
819  * Add a user to the list
820  */
821 void UserList::addUser(const DOMString &user, const DOMString &show)
823     Glib::RefPtr<Gdk::Pixbuf> pb = pixbuf_offline;
824     if (show == "available")
825         pb = pixbuf_available;
826     else if (show == "away")
827         pb = pixbuf_away;
828     else if (show == "chat")
829         pb = pixbuf_chat;
830     else if (show == "dnd")
831         pb = pixbuf_dnd;
832     else if (show == "xa")
833         pb = pixbuf_xa;
834     else
835         {
836         //printf("Unknown show for %s:'%s'\n", user.c_str(), show.c_str());
837         }
838     Gtk::TreeModel::Row row = *(userListStore->append());
839     row[userListColumns.userColumn]   = user;
840     row[userListColumns.statusColumn] = pb;
846 //#########################################################################
847 //# C H A T    W I N D O W
848 //#########################################################################
849 ChatWindow::ChatWindow(PedroGui &par, const DOMString jidArg)
850                         : parent(par)
852     jid = jidArg;
853     doSetup();
856 ChatWindow::~ChatWindow()
860 void ChatWindow::leaveCallback()
862     hide();
863     parent.chatDelete(jid);
867 void ChatWindow::hideCallback()
869     hide();
870     parent.chatDelete(jid);
874 void ChatWindow::textEnterCallback()
876     DOMString str = inputTxt.get_text();
877     if (str.size() > 0)
878         parent.client.message(jid, str);
879     inputTxt.set_text("");
880     messageList.postMessage(parent.client.getJid(), str);
883 bool ChatWindow::doSetup()
885     DOMString title = "Private Chat - ";
886     title.append(jid);
887     set_title(title);
889     set_size_request(500,300);
891     signal_hide().connect(
892            sigc::mem_fun(*this, &ChatWindow::hideCallback) );
894     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
895     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
896     actionGroup->add( Gtk::Action::create("Leave",  Gtk::Stock::CANCEL),
897         sigc::mem_fun(*this, &ChatWindow::leaveCallback) );
900     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
902     uiManager->insert_action_group(actionGroup, 0);
903     add_accel_group(uiManager->get_accel_group());
905     Glib::ustring ui_info =
906         "<ui>"
907         "  <menubar name='MenuBar'>"
908         "    <menu action='MenuFile'>"
909         "      <menuitem action='Leave'/>"
910         "    </menu>"
911         "  </menubar>"
912         "</ui>";
914     add(vbox);
916     uiManager->add_ui_from_string(ui_info);
917     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
918     vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);
920     vbox.pack_end(vPaned);
922     vPaned.add1(messageList);
923     vPaned.add2(inputTxt);
925     inputTxt.signal_activate().connect(
926            sigc::mem_fun(*this, &ChatWindow::textEnterCallback) );
928     show_all_children();
930     return true;
933 bool ChatWindow::postMessage(const DOMString &data)
935     messageList.postMessage(jid, data);
936     return true;
939 //#########################################################################
940 //# G R O U P    C H A T    W I N D O W
941 //#########################################################################
943 GroupChatWindow::GroupChatWindow(PedroGui &par,
944                                  const DOMString &groupJidArg,
945                                  const DOMString &nickArg)
946                                : parent(par)
948     groupJid = groupJidArg;
949     nick     = nickArg;
950     doSetup();
953 GroupChatWindow::~GroupChatWindow()
958 void GroupChatWindow::leaveCallback()
960     parent.client.groupChatLeave(groupJid, nick);
961     hide();
962     parent.groupChatDelete(groupJid, nick);
965 void GroupChatWindow::hideCallback()
967     parent.client.groupChatLeave(groupJid, nick);
968     hide();
969     parent.groupChatDelete(groupJid, nick);
972 void GroupChatWindow::textEnterCallback()
974     DOMString str = inputTxt.get_text();
975     if (str.size() > 0)
976         parent.client.groupChatMessage(groupJid, str);
977     inputTxt.set_text("");
980 bool GroupChatWindow::doSetup()
982     DOMString title = "Group Chat - ";
983     title.append(groupJid);
984     set_title(title);
986     userList.setParent(this);
988     set_size_request(500,300);
990     signal_hide().connect(
991            sigc::mem_fun(*this, &GroupChatWindow::hideCallback) );
993     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
994     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
995     actionGroup->add( Gtk::Action::create("Leave",  Gtk::Stock::CANCEL),
996         sigc::mem_fun(*this, &GroupChatWindow::leaveCallback) );
999     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1001     uiManager->insert_action_group(actionGroup, 0);
1002     add_accel_group(uiManager->get_accel_group());
1004     Glib::ustring ui_info =
1005         "<ui>"
1006         "  <menubar name='MenuBar'>"
1007         "    <menu action='MenuFile'>"
1008          "      <menuitem action='Leave'/>"
1009         "    </menu>"
1010         "  </menubar>"
1011         "</ui>";
1013     add(vbox);
1014     uiManager->add_ui_from_string(ui_info);
1015     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1016     vbox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1018     vbox.pack_end(vPaned);
1020     vPaned.add1(hPaned);
1021     vPaned.add2(inputTxt);
1022     inputTxt.signal_activate().connect(
1023            sigc::mem_fun(*this, &GroupChatWindow::textEnterCallback) );
1026     hPaned.add1(messageList);
1027     hPaned.add2(userList);
1030     show_all_children();
1033     return true;
1036 bool GroupChatWindow::receiveMessage(const DOMString &from,
1037                                      const DOMString &data)
1039     messageList.postMessage(from, data);
1040     return true;
1043 bool GroupChatWindow::receivePresence(const DOMString &fromNick,
1044                                       bool presence,
1045                                       const DOMString &show,
1046                                       const DOMString &status)
1049     DOMString presStr = "";
1050     presStr.append(fromNick);
1051     if (!presence)
1052         presStr.append(" left the group");
1053     else
1054         {
1055         if (show.size()<1)
1056             presStr.append(" joined the group");
1057         else
1058             {
1059             presStr.append(" : ");
1060             presStr.append(show);
1061             }
1062         }
1064     if (presStr != "xa")
1065         messageList.postMessage("*", presStr);
1067     userList.clear();
1068     std::vector<XmppUser> memberList =
1069          parent.client.groupChatGetUserList(groupJid);
1070     for (unsigned int i=0 ; i<memberList.size() ; i++)
1071         {
1072         XmppUser user = memberList[i];
1073         userList.addUser(user.nick, user.show);
1074         }
1075     return true;
1079 void GroupChatWindow::doChat(const DOMString &nick)
1081     printf("##Chat with %s\n", nick.c_str());
1082     DOMString fullJid = groupJid;
1083     fullJid.append("/");
1084     fullJid.append(nick);
1085     parent.doChat(fullJid);
1088 void GroupChatWindow::doSendFile(const DOMString &nick)
1090     printf("##Send file to %s\n", nick.c_str());
1091     DOMString fullJid = groupJid;
1092     fullJid.append("/");
1093     fullJid.append(nick);
1094     parent.doSendFile(fullJid);
1101 //#########################################################################
1102 //# C O N F I G    D I A L O G
1103 //#########################################################################
1106 void ConfigDialog::okCallback()
1108     Glib::ustring pass     = passField.get_text();
1109     Glib::ustring newpass  = newField.get_text();
1110     Glib::ustring confpass = confField.get_text();
1111     if ((pass.size()     < 5 || pass.size()    > 12 ) ||
1112         (newpass.size()  < 5 || newpass.size() > 12 ) ||
1113         (confpass.size() < 5 || confpass.size()> 12 ))
1114         {
1115         Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters",
1116             false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
1117         dlg.run();
1118         }
1119     else if (newpass != confpass)
1120         {
1121         Gtk::MessageDialog dlg(*this, "New password and confirmation do not match",
1122             false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
1123         dlg.run();
1124         }
1125     else
1126         {
1127         //response(Gtk::RESPONSE_OK);
1128         hide();
1129         }
1132 void ConfigDialog::cancelCallback()
1134     //response(Gtk::RESPONSE_CANCEL);
1135     hide();
1138 void ConfigDialog::on_response(int response_id)
1140     if (response_id == Gtk::RESPONSE_OK)
1141         okCallback();
1142     else
1143         cancelCallback();
1146 bool ConfigDialog::doSetup()
1148     set_title("Change Password");
1149     set_size_request(300,200);
1151     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1152     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1153     actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"),
1154         sigc::mem_fun(*this, &ConfigDialog::okCallback) );
1155     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1156          sigc::mem_fun(*this, &ConfigDialog::cancelCallback) );
1159     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1161     uiManager->insert_action_group(actionGroup, 0);
1162     add_accel_group(uiManager->get_accel_group());
1164     Glib::ustring ui_info =
1165         "<ui>"
1166         "  <menubar name='MenuBar'>"
1167         "    <menu action='MenuFile'>"
1168         "      <menuitem action='Change'/>"
1169         "      <separator/>"
1170         "      <menuitem action='Cancel'/>"
1171         "    </menu>"
1172         "  </menubar>"
1173         "</ui>";
1175     uiManager->add_ui_from_string(ui_info);
1176     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1177     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1179     table.resize(3, 2);
1180     get_vbox()->pack_start(table);
1182     passLabel.set_text("Current Password");
1183     table.attach(passLabel, 0, 1, 0, 1);
1184     passField.set_visibility(false);
1185     passField.set_text(parent.client.getPassword());
1186     table.attach(passField, 1, 2, 0, 1);
1188     newLabel.set_text("New Password");
1189     table.attach(newLabel, 0, 1, 1, 2);
1190     newField.set_visibility(false);
1191     table.attach(newField, 1, 2, 1, 2);
1193     confLabel.set_text("Confirm New Password");
1194     table.attach(confLabel, 0, 1, 2, 3);
1195     confField.set_visibility(false);
1196     confField.signal_activate().connect(
1197            sigc::mem_fun(*this, &ConfigDialog::okCallback) );
1198     table.attach(confField, 1, 2, 2, 3);
1200     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1201     add_button(Gtk::Stock::OK,     Gtk::RESPONSE_OK);
1203     show_all_children();
1205     return true;
1208 //#########################################################################
1209 //# P A S S W O R D      D I A L O G
1210 //#########################################################################
1213 void PasswordDialog::okCallback()
1215     Glib::ustring pass     = passField.get_text();
1216     Glib::ustring newpass  = newField.get_text();
1217     Glib::ustring confpass = confField.get_text();
1218     if ((pass.size()     < 5 || pass.size()    > 12 ) ||
1219         (newpass.size()  < 5 || newpass.size() > 12 ) ||
1220         (confpass.size() < 5 || confpass.size()> 12 ))
1221         {
1222         Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters",
1223             false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
1224         dlg.run();
1225         }
1226     else if (newpass != confpass)
1227         {
1228         Gtk::MessageDialog dlg(*this, "New password and confirmation do not match",
1229             false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
1230         dlg.run();
1231         }
1232     else
1233         {
1234         //response(Gtk::RESPONSE_OK);
1235         hide();
1236         }
1239 void PasswordDialog::cancelCallback()
1241     //response(Gtk::RESPONSE_CANCEL);
1242     hide();
1245 void PasswordDialog::on_response(int response_id)
1247     if (response_id == Gtk::RESPONSE_OK)
1248         okCallback();
1249     else
1250         cancelCallback();
1253 bool PasswordDialog::doSetup()
1255     set_title("Change Password");
1256     set_size_request(300,200);
1258     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1259     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1260     actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"),
1261         sigc::mem_fun(*this, &PasswordDialog::okCallback) );
1262     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1263         sigc::mem_fun(*this, &PasswordDialog::cancelCallback) );
1266     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1268     uiManager->insert_action_group(actionGroup, 0);
1269     add_accel_group(uiManager->get_accel_group());
1271     Glib::ustring ui_info =
1272         "<ui>"
1273         "  <menubar name='MenuBar'>"
1274         "    <menu action='MenuFile'>"
1275         "      <menuitem action='Change'/>"
1276         "      <separator/>"
1277         "      <menuitem action='Cancel'/>"
1278         "    </menu>"
1279         "  </menubar>"
1280         "</ui>";
1282     uiManager->add_ui_from_string(ui_info);
1283     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1284     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1286     table.resize(3, 2);
1287     get_vbox()->pack_start(table);
1289     passLabel.set_text("Current Password");
1290     table.attach(passLabel, 0, 1, 0, 1);
1291     passField.set_visibility(false);
1292     passField.set_text(parent.client.getPassword());
1293     table.attach(passField, 1, 2, 0, 1);
1295     newLabel.set_text("New Password");
1296     table.attach(newLabel, 0, 1, 1, 2);
1297     newField.set_visibility(false);
1298     table.attach(newField, 1, 2, 1, 2);
1300     confLabel.set_text("Confirm New Password");
1301     table.attach(confLabel, 0, 1, 2, 3);
1302     confField.set_visibility(false);
1303     confField.signal_activate().connect(
1304            sigc::mem_fun(*this, &PasswordDialog::okCallback) );
1305     table.attach(confField, 1, 2, 2, 3);
1307     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1308     add_button(Gtk::Stock::OK,     Gtk::RESPONSE_OK);
1310     show_all_children();
1312     return true;
1315 //#########################################################################
1316 //# C H A T    D I A L O G
1317 //#########################################################################
1320 void ChatDialog::okCallback()
1322     response(Gtk::RESPONSE_OK);
1323     hide();
1326 void ChatDialog::cancelCallback()
1328     response(Gtk::RESPONSE_CANCEL);
1329     hide();
1333 bool ChatDialog::doSetup()
1335     set_title("Chat with User");
1336     set_size_request(300,200);
1338     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1339     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1340     actionGroup->add( Gtk::Action::create("Chat", Gtk::Stock::CONNECT, "Chat"),
1341     sigc::mem_fun(*this, &ChatDialog::okCallback) );
1342     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1343     sigc::mem_fun(*this, &ChatDialog::cancelCallback) );
1346     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1348     uiManager->insert_action_group(actionGroup, 0);
1349     add_accel_group(uiManager->get_accel_group());
1351     Glib::ustring ui_info =
1352         "<ui>"
1353         "  <menubar name='MenuBar'>"
1354         "    <menu action='MenuFile'>"
1355         "      <menuitem action='Chat'/>"
1356         "      <separator/>"
1357         "      <menuitem action='Cancel'/>"
1358         "    </menu>"
1359         "  </menubar>"
1360         "</ui>";
1362     uiManager->add_ui_from_string(ui_info);
1363     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1364     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1366     table.resize(2, 2);
1367     get_vbox()->pack_start(table);
1369     userLabel.set_text("User");
1370     table.attach(userLabel, 0, 1, 0, 1);
1371     //userField.set_text("");
1372     table.attach(userField, 1, 2, 0, 1);
1374     //userField.set_text("");
1375     table.attach(textField, 0, 2, 1, 2);
1377     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1378     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1380     show_all_children();
1382     return true;
1385 //#########################################################################
1386 //# G R O U P    C H A T   D I A L O G
1387 //#########################################################################
1390 void GroupChatDialog::okCallback()
1392     response(Gtk::RESPONSE_OK);
1393     hide();
1396 void GroupChatDialog::cancelCallback()
1398     response(Gtk::RESPONSE_CANCEL);
1399     hide();
1403 bool GroupChatDialog::doSetup()
1405     set_title("Join Group Chat");
1406     set_size_request(300,200);
1408     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1409     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1410     actionGroup->add( Gtk::Action::create("Join", Gtk::Stock::CONNECT, "Join Group"),
1411     sigc::mem_fun(*this, &GroupChatDialog::okCallback) );
1412     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1413     sigc::mem_fun(*this, &GroupChatDialog::cancelCallback) );
1416     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1418     uiManager->insert_action_group(actionGroup, 0);
1419     add_accel_group(uiManager->get_accel_group());
1421     Glib::ustring ui_info =
1422         "<ui>"
1423         "  <menubar name='MenuBar'>"
1424         "    <menu action='MenuFile'>"
1425         "      <menuitem action='Join'/>"
1426         "      <separator/>"
1427         "      <menuitem action='Cancel'/>"
1428         "    </menu>"
1429         "  </menubar>"
1430         "</ui>";
1432     uiManager->add_ui_from_string(ui_info);
1433     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1434     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1436     table.resize(4, 2);
1437     get_vbox()->pack_start(table);
1439     groupLabel.set_text("Group");
1440     table.attach(groupLabel, 0, 1, 0, 1);
1441     groupField.set_text(parent.config.getMucGroup());
1442     table.attach(groupField, 1, 2, 0, 1);
1444     hostLabel.set_text("Host");
1445     table.attach(hostLabel, 0, 1, 1, 2);
1446     hostField.set_text(parent.config.getMucHost());
1447     table.attach(hostField, 1, 2, 1, 2);
1449     nickLabel.set_text("Alt Name");
1450     table.attach(nickLabel, 0, 1, 2, 3);
1451     nickField.set_text(parent.config.getMucNick());
1452     table.attach(nickField, 1, 2, 2, 3);
1454     passLabel.set_text("Password");
1455     table.attach(passLabel, 0, 1, 3, 4);
1456     passField.set_visibility(false);
1457     passField.set_text(parent.config.getMucPassword());
1458     table.attach(passField, 1, 2, 3, 4);
1461     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1462     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1464     show_all_children();
1466     return true;
1472 //#########################################################################
1473 //# C O N N E C T    D I A L O G
1474 //#########################################################################
1477 void ConnectDialog::okCallback()
1479     response(Gtk::RESPONSE_OK);
1480     hide();
1483 void ConnectDialog::saveCallback()
1485     Gtk::Entry txtField;
1486     Gtk::Dialog dlg("Account name", *this, true, true);
1487     dlg.get_vbox()->pack_start(txtField);
1488     txtField.signal_activate().connect(
1489            sigc::bind(sigc::mem_fun(dlg, &Gtk::Dialog::response),
1490               Gtk::RESPONSE_OK  ));
1491     dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1492     dlg.add_button(Gtk::Stock::OK,     Gtk::RESPONSE_OK);
1493     dlg.show_all_children();
1494     int ret = dlg.run();
1495     if (ret != Gtk::RESPONSE_OK)
1496         return;
1498     Glib::ustring name = txtField.get_text();
1499     if (name.size() < 1)
1500         {
1501         parent.error("Account name too short");
1502         return;
1503         }
1505     if (parent.config.accountExists(name))
1506         {
1507         parent.config.accountRemove(name);          
1508         }
1510     XmppAccount account;
1511     account.setName(name);
1512     account.setHost(getHost());
1513     account.setPort(getPort());
1514     account.setUsername(getUser());
1515     account.setPassword(getPass());
1516     parent.config.accountAdd(account);
1518     refresh();
1520     parent.configSave();
1523 void ConnectDialog::cancelCallback()
1525     response(Gtk::RESPONSE_CANCEL);
1526     hide();
1530 void ConnectDialog::doubleClickCallback(
1531                    const Gtk::TreeModel::Path &path,
1532                    Gtk::TreeViewColumn *col)
1534     Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model();
1535     Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection();
1536     Gtk::TreeModel::iterator iter = sel->get_selected();
1537     DOMString name = iter->get_value(accountColumns.nameColumn);
1538     //printf("Double clicked:%s\n", name.c_str());
1539     XmppAccount account;
1540     if (!parent.config.accountFind(name, account))
1541         return;
1542     setHost(account.getHost()); 
1543     setPort(account.getPort()); 
1544     setUser(account.getUsername()); 
1545     setPass(account.getPassword()); 
1547     response(Gtk::RESPONSE_OK);
1548     hide();
1551 void ConnectDialog::selectedCallback()
1553     Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model();
1554     Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection();
1555     Gtk::TreeModel::iterator iter = sel->get_selected();
1556     DOMString name = iter->get_value(accountColumns.nameColumn);
1557     //printf("Single clicked:%s\n", name.c_str());
1558     XmppAccount account;
1559     if (!parent.config.accountFind(name, account))
1560         return;
1561     setHost(account.getHost()); 
1562     setPort(account.getPort()); 
1563     setUser(account.getUsername()); 
1564     setPass(account.getPassword()); 
1567 void ConnectDialog::deleteCallback()
1569     Glib::RefPtr<Gtk::TreeModel> model = accountView.get_model();
1570     Glib::RefPtr<Gtk::TreeSelection> sel = accountView.get_selection();
1571     Gtk::TreeModel::iterator iter = sel->get_selected();
1572     DOMString name = iter->get_value(accountColumns.nameColumn);
1574     parent.config.accountRemove(name);
1575     refresh();
1576     parent.configSave();
1577     
1582 void ConnectDialog::buttonPressCallback(GdkEventButton* event)
1584     if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
1585         {
1586         Gtk::Widget *wid = accountUiManager->get_widget("/PopupMenu");
1587         Gtk::Menu *popupMenu = dynamic_cast<Gtk::Menu*>(wid);
1588         popupMenu->popup(event->button, event->time);
1589         }
1593 bool ConnectDialog::doSetup()
1595     set_title("Connect");
1596     set_size_request(300,400);
1598     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1599     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1600     actionGroup->add( Gtk::Action::create("Connect",
1601         Gtk::Stock::CONNECT, "Connect"),
1602         sigc::mem_fun(*this, &ConnectDialog::okCallback) );
1603     actionGroup->add( Gtk::Action::create("Save",
1604         Gtk::Stock::CONNECT, "Save as account"),
1605         sigc::mem_fun(*this, &ConnectDialog::saveCallback) );
1606     actionGroup->add( Gtk::Action::create("Cancel",
1607         Gtk::Stock::CANCEL, "Cancel"),
1608         sigc::mem_fun(*this, &ConnectDialog::cancelCallback) );
1611     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1613     uiManager->insert_action_group(actionGroup, 0);
1614     add_accel_group(uiManager->get_accel_group());
1616     Glib::ustring ui_info =
1617         "<ui>"
1618         "  <menubar name='MenuBar'>"
1619         "    <menu action='MenuFile'>"
1620         "      <menuitem action='Connect'/>"
1621         "      <separator/>"
1622         "      <menuitem action='Save'/>"
1623         "      <separator/>"
1624         "      <menuitem action='Cancel'/>"
1625         "    </menu>"
1626         "  </menubar>"
1627         "</ui>";
1629     uiManager->add_ui_from_string(ui_info);
1630     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1631     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1633     table.resize(6, 2);
1634     get_vbox()->pack_start(table);
1636     parent.client.setHost("broadway.dynalias.com");
1637     parent.client.setPort(5222);
1638     parent.client.setUsername("");
1639     parent.client.setPassword("");
1640     parent.client.setResource("pedroXmpp");
1642     hostLabel.set_text("Host");
1643     table.attach(hostLabel, 0, 1, 0, 1);
1644     hostField.set_text(parent.client.getHost());
1645     table.attach(hostField, 1, 2, 0, 1);
1647     portLabel.set_text("Port");
1648     table.attach(portLabel, 0, 1, 1, 2);
1649     portSpinner.set_digits(0);
1650     portSpinner.set_range(1, 65000);
1651     portSpinner.set_value(parent.client.getPort());
1652     table.attach(portSpinner, 1, 2, 1, 2);
1654     userLabel.set_text("Username");
1655     table.attach(userLabel, 0, 1, 2, 3);
1656     userField.set_text(parent.client.getUsername());
1657     table.attach(userField, 1, 2, 2, 3);
1659     passLabel.set_text("Password");
1660     table.attach(passLabel, 0, 1, 3, 4);
1661     passField.set_visibility(false);
1662     passField.set_text(parent.client.getPassword());
1663     passField.signal_activate().connect(
1664            sigc::mem_fun(*this, &ConnectDialog::okCallback) );
1665     table.attach(passField, 1, 2, 3, 4);
1667     resourceLabel.set_text("Resource");
1668     table.attach(resourceLabel, 0, 1, 4, 5);
1669     resourceField.set_text(parent.client.getResource());
1670     table.attach(resourceField, 1, 2, 4, 5);
1672     registerLabel.set_text("Register");
1673     table.attach(registerLabel, 0, 1, 5, 6);
1674     registerButton.set_active(false);
1675     table.attach(registerButton, 1, 2, 5, 6);
1677     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1678     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1681     //######################
1682     //# ACCOUNT LIST
1683     //######################
1686     accountListStore = Gtk::ListStore::create(accountColumns);
1687     accountView.set_model(accountListStore);
1689     accountView.signal_row_activated().connect(
1690         sigc::mem_fun(*this, &ConnectDialog::doubleClickCallback) );
1692     accountView.get_selection()->signal_changed().connect(
1693         sigc::mem_fun(*this, &ConnectDialog::selectedCallback) );
1695     accountView.append_column("Account", accountColumns.nameColumn);
1696     accountView.append_column("Host",    accountColumns.hostColumn);
1698     //accountView.signal_row_activated().connect(
1699     //    sigc::mem_fun(*this, &AccountDialog::connectCallback) );
1701     accountScroll.add(accountView);
1702     accountScroll.set_policy(Gtk::POLICY_ALWAYS, Gtk::POLICY_ALWAYS);
1704     get_vbox()->pack_start(accountScroll);
1706     //##### POPUP MENU
1707     accountView.signal_button_press_event().connect_notify(
1708         sigc::mem_fun(*this, &ConnectDialog::buttonPressCallback) );
1710     Glib::RefPtr<Gtk::ActionGroup> accountActionGroup =
1711                 Gtk::ActionGroup::create();
1713     accountActionGroup->add( Gtk::Action::create("PopupMenu", "_Account") );
1715     accountActionGroup->add( Gtk::Action::create("Delete",
1716                                   Gtk::Stock::DELETE, "Delete"),
1717         sigc::mem_fun(*this, &ConnectDialog::deleteCallback) );
1720     accountUiManager = Gtk::UIManager::create();
1722     accountUiManager->insert_action_group(accountActionGroup, 0);
1724     Glib::ustring account_ui_info =
1725         "<ui>"
1726         "  <popup name='PopupMenu'>"
1727         "    <menuitem action='Delete'/>"
1728         "  </popup>"
1729         "</ui>";
1731     accountUiManager->add_ui_from_string(account_ui_info);
1732     //Gtk::Widget* accountMenuBar = uiManager->get_widget("/PopupMenu");
1733     //get_vbox()->pack_start(*accountMenuBar, Gtk::PACK_SHRINK);
1735     refresh();
1737     show_all_children();
1739     return true;
1743 /**
1744  * Regenerate the account list
1745  */
1746 void ConnectDialog::refresh()
1748     accountListStore->clear();
1750     std::vector<XmppAccount> accounts = parent.config.getAccounts();
1751     for (unsigned int i=0 ; i<accounts.size() ; i++)
1752         {
1753         XmppAccount account = accounts[i];
1754         Gtk::TreeModel::Row row = *(accountListStore->append());
1755         row[accountColumns.nameColumn] = account.getName();
1756         row[accountColumns.hostColumn] = account.getHost();
1757         }
1758     accountView.expand_all();
1763 //#########################################################################
1764 //# F I L E    S E N D    D I A L O G
1765 //#########################################################################
1768 void FileSendDialog::okCallback()
1770     response(Gtk::RESPONSE_OK);
1771     hide();
1774 void FileSendDialog::cancelCallback()
1776     response(Gtk::RESPONSE_CANCEL);
1777     hide();
1781 void FileSendDialog::buttonCallback()
1783     Gtk::FileChooserDialog dlg("Select a file to send",
1784                       Gtk::FILE_CHOOSER_ACTION_OPEN);
1785     dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1786     dlg.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1787     int ret = dlg.run();
1788     if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT)
1789         {
1790         fileName = dlg.get_filename();
1791         fileNameField.set_text(fileName);
1792         }
1795 bool FileSendDialog::doSetup()
1797     set_title("Send file to user");
1798     set_size_request(400,150);
1800     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1801     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1802     actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"),
1803         sigc::mem_fun(*this, &FileSendDialog::okCallback) );
1804     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1805         sigc::mem_fun(*this, &FileSendDialog::cancelCallback) );
1808     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1810     uiManager->insert_action_group(actionGroup, 0);
1811     add_accel_group(uiManager->get_accel_group());
1813     Glib::ustring ui_info =
1814         "<ui>"
1815         "  <menubar name='MenuBar'>"
1816         "    <menu action='MenuFile'>"
1817         "      <menuitem action='Send'/>"
1818         "      <separator/>"
1819         "      <menuitem action='Cancel'/>"
1820         "    </menu>"
1821         "  </menubar>"
1822         "</ui>";
1824     uiManager->add_ui_from_string(ui_info);
1825     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1826     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1828     table.resize(2, 2);
1829     get_vbox()->pack_start(table);
1831     jidLabel.set_text("User ID");
1832     table.attach(jidLabel, 0, 1, 0, 1);
1833     jidField.set_text("inkscape");
1834     table.attach(jidField, 1, 2, 0, 1);
1836     selectFileButton.set_label("Select");
1837     selectFileButton.signal_clicked().connect(
1838            sigc::mem_fun(*this, &FileSendDialog::buttonCallback) );
1839     table.attach(selectFileButton, 0, 1, 1, 2);
1841     fileName = "";
1842     fileNameField.set_text("No file selected");
1843     fileNameField.set_editable(false);
1844     table.attach(fileNameField, 1, 2, 1, 2);
1846     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1847     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1849     show_all_children();
1851     return true;
1855 //#########################################################################
1856 //# F I L E    R E C E I V E   D I A L O G
1857 //#########################################################################
1860 void FileReceiveDialog::okCallback()
1862     response(Gtk::RESPONSE_OK);
1863     hide();
1866 void FileReceiveDialog::cancelCallback()
1868     response(Gtk::RESPONSE_CANCEL);
1869     hide();
1872 void FileReceiveDialog::buttonCallback()
1874     Gtk::FileChooserDialog dlg("Select a file to save",
1875                       Gtk::FILE_CHOOSER_ACTION_SAVE);
1876     dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1877     dlg.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1878     int ret = dlg.run();
1879     if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT)
1880         {
1881         fileName = dlg.get_filename();
1882         fileNameField.set_text(fileName);
1883         }
1887 bool FileReceiveDialog::doSetup()
1889     set_title("File being sent by user");
1890     set_size_request(450,250);
1892     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1893     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1894     actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"),
1895         sigc::mem_fun(*this, &FileReceiveDialog::okCallback) );
1896     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1897         sigc::mem_fun(*this, &FileReceiveDialog::cancelCallback) );
1900     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1902     uiManager->insert_action_group(actionGroup, 0);
1903     add_accel_group(uiManager->get_accel_group());
1905     Glib::ustring ui_info =
1906         "<ui>"
1907         "  <menubar name='MenuBar'>"
1908         "    <menu action='MenuFile'>"
1909         "      <menuitem action='Send'/>"
1910         "      <separator/>"
1911         "      <menuitem action='Cancel'/>"
1912         "    </menu>"
1913         "  </menubar>"
1914         "</ui>";
1916     uiManager->add_ui_from_string(ui_info);
1917     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1918     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1920     table.resize(6, 2);
1921     get_vbox()->pack_start(table);
1923     jidLabel.set_text("User ID");
1924     table.attach(jidLabel, 0, 1, 0, 1);
1925     jidField.set_text(jid);
1926     jidField.set_editable(false);
1927     table.attach(jidField, 1, 2, 0, 1);
1929     offeredLabel.set_text("File Offered");
1930     table.attach(offeredLabel, 0, 1, 1, 2);
1931     offeredField.set_text(offeredName);
1932     offeredField.set_editable(false);
1933     table.attach(offeredField, 1, 2, 1, 2);
1935     descLabel.set_text("Description");
1936     table.attach(descLabel, 0, 1, 2, 3);
1937     descField.set_text(desc);
1938     descField.set_editable(false);
1939     table.attach(descField, 1, 2, 2, 3);
1941     char buf[32];
1942     snprintf(buf, 31, "%ld", fileSize);
1943     sizeLabel.set_text("Size");
1944     table.attach(sizeLabel, 0, 1, 3, 4);
1945     sizeField.set_text(buf);
1946     sizeField.set_editable(false);
1947     table.attach(sizeField, 1, 2, 3, 4);
1949     hashLabel.set_text("MD5 Hash");
1950     table.attach(hashLabel, 0, 1, 4, 5);
1951     hashField.set_text(hash);
1952     hashField.set_editable(false);
1953     table.attach(hashField, 1, 2, 4, 5);
1955     selectFileButton.set_label("Select");
1956     selectFileButton.signal_clicked().connect(
1957            sigc::mem_fun(*this, &FileReceiveDialog::buttonCallback) );
1958     table.attach(selectFileButton, 0, 1, 5, 6);
1960     fileName = "";
1961     fileNameField.set_text("No file selected");
1962     fileNameField.set_editable(false);
1963     table.attach(fileNameField, 1, 2, 5, 6);
1966     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1967     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1969     show_all_children();
1971     return true;
1975 //#########################################################################
1976 //# M A I N    W I N D O W
1977 //#########################################################################
1979 PedroGui::PedroGui()
1981     doSetup();
1984 PedroGui::~PedroGui()
1986     chatDeleteAll();
1987     groupChatDeleteAll();
1991 void PedroGui::error(const char *fmt, ...)
1993     va_list args;
1994     va_start(args, fmt);
1995     gchar * buffer = g_strdup_vprintf(fmt, args);
1996     va_end(args) ;
1998     Gtk::MessageDialog dlg(buffer,
1999                            false,
2000                            Gtk::MESSAGE_ERROR,
2001                            Gtk::BUTTONS_OK,
2002                            true);
2003     dlg.run();
2004     g_free(buffer);
2007 void PedroGui::status(const char *fmt, ...)
2009     va_list args;
2010     va_start(args, fmt);
2011     gchar * buffer = g_strdup_vprintf(fmt, args);
2012     va_end(args) ;
2013     messageList.postMessage("STATUS", buffer);
2014     g_free(buffer);
2017 //################################
2018 //# CHAT WINDOW MANAGEMENT
2019 //################################
2020 bool PedroGui::chatCreate(const DOMString &userJid)
2022     std::vector<ChatWindow *>::iterator iter;
2023     for (iter=chats.begin() ; iter != chats.end() ; iter++)
2024         {
2025         if (userJid == (*iter)->getJid())
2026             return false;
2027         }
2028     ChatWindow *chat = new ChatWindow(*this, userJid);
2029     chat->show();
2030     chats.push_back(chat);
2031     return true;
2034 bool PedroGui::chatDelete(const DOMString &userJid)
2036     std::vector<ChatWindow *>::iterator iter;
2037     for (iter=chats.begin() ; iter != chats.end() ; )
2038         {
2039         if (userJid == (*iter)->getJid())
2040             {
2041             delete(*iter);
2042             iter = chats.erase(iter);
2043             }
2044         else
2045             iter++;
2046         }
2047     return true;
2050 bool PedroGui::chatDeleteAll()
2052     std::vector<ChatWindow *>::iterator iter;
2053     for (iter=chats.begin() ; iter != chats.end() ; )
2054         {
2055         delete(*iter);
2056         iter = chats.erase(iter);
2057         }
2058     return true;
2061 bool PedroGui::chatMessage(const DOMString &from, const DOMString &data)
2063     std::vector<ChatWindow *>::iterator iter;
2064     for (iter=chats.begin() ; iter != chats.end() ; iter++)
2065         {
2066         if (from == (*iter)->getJid())
2067             {
2068             (*iter)->postMessage(data);
2069             return true;
2070             }
2071         }
2072     ChatWindow *chat = new ChatWindow(*this, from);
2073     chat->show();
2074     chats.push_back(chat);
2075     chat->postMessage(data);
2076     return true;
2080 //################################
2081 //# GROUP CHAT WINDOW MANAGEMENT
2082 //################################
2084 bool PedroGui::groupChatCreate(const DOMString &groupJid, const DOMString &nick)
2086     std::vector<GroupChatWindow *>::iterator iter;
2087     for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++)
2088         {
2089         if (groupJid == (*iter)->getGroupJid())
2090             return false;
2091         }
2092     GroupChatWindow *chat = new GroupChatWindow(*this, groupJid, nick);
2093     chat->show();
2094     groupChats.push_back(chat);
2095     return true;
2099 bool PedroGui::groupChatDelete(const DOMString &groupJid, const DOMString &nick)
2101     std::vector<GroupChatWindow *>::iterator iter;
2102     for (iter=groupChats.begin() ; iter != groupChats.end() ;)
2103         {
2104         if (groupJid == (*iter)->getGroupJid() &&
2105             nick     == (*iter)->getNick())
2106             {
2107             delete(*iter);
2108             iter = groupChats.erase(iter);
2109             }
2110         else
2111             iter++;
2112         }
2113     return true;
2117 bool PedroGui::groupChatDeleteAll()
2119     std::vector<GroupChatWindow *>::iterator iter;
2120     for (iter=groupChats.begin() ; iter != groupChats.end() ; )
2121         {
2122         delete(*iter);
2123         iter = groupChats.erase(iter);
2124         }
2125     return true;
2129 bool PedroGui::groupChatMessage(const DOMString &groupJid,
2130               const DOMString &from, const DOMString &data)
2132     std::vector<GroupChatWindow *>::iterator iter;
2133     for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++)
2134         {
2135         if (groupJid == (*iter)->getGroupJid())
2136             {
2137             (*iter)->receiveMessage(from, data);
2138             }
2139         }
2140     return true;
2143 bool PedroGui::groupChatPresence(const DOMString &groupJid,
2144                       const DOMString &nick, bool presence,
2145                       const DOMString &show,
2146                       const DOMString &status)
2148     std::vector<GroupChatWindow *>::iterator iter;
2149     for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++)
2150         {
2151         if (groupJid == (*iter)->getGroupJid())
2152             {
2153             (*iter)->receivePresence(nick, presence, show, status);
2154             }
2155         }
2156     return true;
2159 //################################
2160 //# EVENTS
2161 //################################
2163 /**
2164  *
2165  */
2166 void PedroGui::padlockEnable()
2168     padlockIcon.set(Gtk::Stock::DIALOG_AUTHENTICATION,
2169                Gtk::ICON_SIZE_MENU);
2172 /**
2173  *
2174  */
2175 void PedroGui::padlockDisable()
2177     padlockIcon.clear();
2181 /**
2182  *
2183  */
2184 void PedroGui::handleConnectEvent()
2186      status("##### CONNECTED");
2187      actionEnable("Connect",    false);
2188      actionEnable("Chat",       true);
2189      actionEnable("GroupChat",  true);
2190      actionEnable("Disconnect", true);
2191      actionEnable("RegPass",    true);
2192      actionEnable("RegCancel",  true);
2193      DOMString title = "Pedro - ";
2194      title.append(client.getJid());
2195      set_title(title);
2199 /**
2200  *
2201  */
2202 void PedroGui::handleDisconnectEvent()
2204      status("##### DISCONNECTED");
2205      actionEnable("Connect",    true);
2206      actionEnable("Chat",       false);
2207      actionEnable("GroupChat",  false);
2208      actionEnable("Disconnect", false);
2209      actionEnable("RegPass",    false);
2210      actionEnable("RegCancel",  false);
2211      padlockDisable();
2212      DOMString title = "Pedro";
2213      set_title(title);
2214      chatDeleteAll();
2215      groupChatDeleteAll();
2216      roster.clear();
2220 /**
2221  *
2222  */
2223 void PedroGui::doEvent(const XmppEvent &event)
2226     int typ = event.getType();
2227     switch (typ)
2228         {
2229         case XmppEvent::EVENT_STATUS:
2230             {
2231             //printf("##### STATUS: %s\n", event.getData().c_str());
2232             status("%s", event.getData().c_str());
2233             break;
2234             }
2235         case XmppEvent::EVENT_ERROR:
2236             {
2237             //printf("##### ERROR: %s\n", event.getData().c_str());
2238             error("%s", event.getData().c_str());
2239             padlockDisable();
2240             break;
2241             }
2242         case XmppEvent::EVENT_SSL_STARTED:
2243             {
2244             padlockEnable();
2245             break;
2246             }
2247         case XmppEvent::EVENT_CONNECTED:
2248             {
2249             handleConnectEvent();
2250             break;
2251             }
2252         case XmppEvent::EVENT_DISCONNECTED:
2253             {
2254             handleDisconnectEvent();
2255             break;
2256             }
2257         case XmppEvent::EVENT_MESSAGE:
2258             {
2259             status("##### MESSAGE: %s\n", event.getFrom().c_str());
2260             chatMessage(event.getFrom(), event.getData());
2261             break;
2262             }
2263         case XmppEvent::EVENT_PRESENCE:
2264             {
2265             status("##### PRESENCE: %s\n", event.getFrom().c_str());
2266             roster.refresh();
2267             break;
2268             }
2269         case XmppEvent::EVENT_ROSTER:
2270             {
2271             status("##### ROSTER\n");
2272             roster.refresh();
2273             break;
2274             }
2275         case XmppEvent::EVENT_MUC_JOIN:
2276             {
2277             status("##### GROUP JOINED: %s\n", event.getGroup().c_str());
2278             break;
2279             }
2280         case XmppEvent::EVENT_MUC_MESSAGE:
2281             {
2282             //printf("##### MUC_MESSAGE: %s\n", event.getGroup().c_str());
2283             groupChatMessage(event.getGroup(),
2284                     event.getFrom(), event.getData());
2285             break;
2286             }
2287         case XmppEvent::EVENT_MUC_PRESENCE:
2288             {
2289             //printf("##### MUC_USER LIST: %s\n", event.getFrom().c_str());
2290             groupChatPresence(event.getGroup(),
2291                               event.getFrom(),
2292                               event.getPresence(),
2293                               event.getShow(),
2294                               event.getStatus());
2295             break;
2296             }
2297         case XmppEvent::EVENT_MUC_LEAVE:
2298             {
2299             status("##### GROUP LEFT: %s\n", event.getGroup().c_str());
2300             groupChatDelete(event.getGroup(), event.getFrom());
2301             break;
2302             }
2303         case XmppEvent::EVENT_FILE_RECEIVE:
2304             {
2305             status("##### FILE RECEIVE: %s\n", event.getFileName().c_str());
2306             doReceiveFile(event.getFrom(), event.getIqId(), event.getStreamId(),
2307                        event.getFileName(), event.getFileDesc(),
2308                        event.getFileSize(), event.getFileHash());
2309             break;
2310             }
2311         case XmppEvent::EVENT_REGISTRATION_NEW:
2312             {
2313             status("##### REGISTERED: %s at %s\n",
2314                        event.getTo().c_str(), event.getFrom().c_str());
2315             break;
2316             }
2317         case XmppEvent::EVENT_REGISTRATION_CHANGE_PASS:
2318             {
2319             status("##### PASSWORD CHANGED: %s at %s\n",
2320                        event.getTo().c_str(), event.getFrom().c_str());
2321             break;
2322             }
2323         case XmppEvent::EVENT_REGISTRATION_CANCEL:
2324             {
2325             //client.disconnect();
2326             status("##### REGISTERATION CANCELLED: %s at %s\n",
2327                        event.getTo().c_str(), event.getFrom().c_str());
2328             break;
2329             }
2330         default:
2331             {
2332             printf("unknown event type: %d\n", typ);
2333             break;
2334             }
2335         }
2339 /**
2340  *
2341  */
2342 bool PedroGui::checkEventQueue()
2344     while (client.eventQueueAvailable() > 0)
2345         {
2346         XmppEvent evt = client.eventQueuePop();
2347         doEvent(evt);
2348         }
2350     while( Gtk::Main::events_pending() )
2351         Gtk::Main::iteration();
2353     return true;
2357 //##################
2358 //# COMMANDS
2359 //##################
2360 void PedroGui::doChat(const DOMString &jid)
2362     if (jid.size()>0)
2363         {
2364         chatCreate(jid);
2365         return;
2366         }
2368     FileSendDialog dlg(*this);
2369     int ret = dlg.run();
2370     if (ret == Gtk::RESPONSE_OK)
2371         {
2372         chatCreate(dlg.getJid());
2373         }
2377 void PedroGui::doSendFile(const DOMString &jid)
2379     FileSendDialog dlg(*this);
2380     if (jid.size()>0)
2381         dlg.setJid(jid);
2382     int ret = dlg.run();
2383     if (ret == Gtk::RESPONSE_OK)
2384         {
2385         DOMString fileName = dlg.getFileName();
2386         printf("fileName:%s\n", fileName.c_str());
2387         DOMString offeredName = "";
2388         DOMString desc = "";
2389         client.fileSendBackground(jid, offeredName, fileName, desc);
2390         }
2394 void PedroGui::doReceiveFile(
2395                       const DOMString &jid,
2396                       const DOMString &iqId,
2397                       const DOMString &streamId,
2398                       const DOMString &offeredName,
2399                       const DOMString &desc,
2400                       long  size,
2401                       const DOMString &hash
2402                       )
2405     FileReceiveDialog dlg(*this, jid, iqId, streamId,
2406                           offeredName, desc, size, hash);
2407     int ret = dlg.run();
2408     if (ret == Gtk::RESPONSE_OK)
2409         {
2410         DOMString fileName = dlg.getFileName();
2411         printf("fileName:%s\n", fileName.c_str());
2412         client.fileReceiveBackground(jid, iqId, streamId, fileName, size, hash);
2413         }
2418 //##################
2419 //# CALLBACKS
2420 //##################
2421 void PedroGui::connectCallback()
2423     ConnectDialog dialog(*this);
2424     int result = dialog.run();
2425     dialog.hide();
2426     if (result == Gtk::RESPONSE_OK)
2427         {
2428         client.setHost(dialog.getHost());
2429         client.setPort(dialog.getPort());
2430         client.setUsername(dialog.getUser());
2431         client.setPassword(dialog.getPass());
2432         client.setResource(dialog.getResource());
2433         client.setDoRegister(dialog.getRegister());
2434         client.connect();
2435         }
2440 void PedroGui::chatCallback()
2442     ChatDialog dialog(*this);
2443     int result = dialog.run();
2444     dialog.hide();
2445     if (result == Gtk::RESPONSE_OK)
2446         {
2447         client.message(dialog.getUser(), dialog.getText());
2448         }
2453 void PedroGui::groupChatCallback()
2455     GroupChatDialog dialog(*this);
2456     int result = dialog.run();
2457     dialog.hide();
2458     if (result != Gtk::RESPONSE_OK)
2459         return;
2460     DOMString groupJid = dialog.getGroup();
2461     groupJid.append("@");
2462     groupJid.append(dialog.getHost());
2463     if (client.groupChatExists(groupJid))
2464         {
2465         error("Group chat %s already exists", groupJid.c_str());
2466         return;
2467         }
2468     groupChatCreate(groupJid, dialog.getNick());
2469     client.groupChatJoin(groupJid, dialog.getNick(), dialog.getPass() );
2470     config.setMucGroup(dialog.getGroup());
2471     config.setMucHost(dialog.getHost());
2472     config.setMucNick(dialog.getNick());
2473     config.setMucPassword(dialog.getPass());
2474  
2475     configSave();
2479 void PedroGui::disconnectCallback()
2481     client.disconnect();
2485 void PedroGui::quitCallback()
2487     Gtk::Main::quit();
2491 void PedroGui::fontCallback()
2493     Gtk::FontSelectionDialog dlg;
2494     int ret = dlg.run();
2495     if (ret == Gtk::RESPONSE_OK)
2496         {
2497         Glib::ustring fontName = dlg.get_font_name();
2498         Pango::FontDescription fontDesc(fontName);
2499         modify_font(fontDesc);
2500         }
2503 void PedroGui::colorCallback()
2505     Gtk::ColorSelectionDialog dlg;
2506     int ret = dlg.run();
2507     if (ret == Gtk::RESPONSE_OK)
2508         {
2509         Gdk::Color col = dlg.get_colorsel()->get_current_color();
2510         modify_bg(Gtk::STATE_NORMAL, col);
2511         }
2514 void PedroGui::regPassCallback()
2516     PasswordDialog dlg(*this);
2517     int ret = dlg.run();
2518     if (ret == Gtk::RESPONSE_OK)
2519         {
2520         DOMString newpass = dlg.getNewPass();
2521         client.inBandRegistrationChangePassword(newpass);
2522         }
2526 void PedroGui::regCancelCallback()
2528     Gtk::MessageDialog dlg(*this, "Do you want to cancel your registration on the server?",
2529         false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true);
2530     int ret = dlg.run();
2531     if (ret == Gtk::RESPONSE_YES)
2532         {
2533         client.inBandRegistrationCancel();
2534         }
2539 void PedroGui::sendFileCallback()
2541     doSendFile("");
2546 void PedroGui::aboutCallback()
2548     Gtk::AboutDialog dlg;
2549     std::vector<Glib::ustring>authors;
2550     authors.push_back("Bob Jamison");
2551     dlg.set_authors(authors);
2552     DOMString comments = "A simple XMPP gui client  ";
2553     comments.append("Based on the Pedro XMPP client");
2554     dlg.set_comments(comments);
2555     dlg.set_version("1.0");
2556     dlg.run();
2561 void PedroGui::actionEnable(const DOMString &name, bool val)
2563     DOMString path = "/ui/MenuBar/";
2564     path.append(name);
2565     Glib::RefPtr<Gtk::Action> action = uiManager->get_action(path);
2566     if (!action)
2567         {
2568         path = "/ui/MenuBar/MenuFile/";
2569         path.append(name);
2570         action = uiManager->get_action(path);
2571         }
2572     if (!action)
2573         {
2574         path = "/ui/MenuBar/MenuEdit/";
2575         path.append(name);
2576         action = uiManager->get_action(path);
2577         }
2578     if (!action)
2579         {
2580         path = "/ui/MenuBar/MenuRegister/";
2581         path.append(name);
2582         action = uiManager->get_action(path);
2583         }
2584     if (!action)
2585         {
2586         path = "/ui/MenuBar/MenuTransfer/";
2587         path.append(name);
2588         action = uiManager->get_action(path);
2589         }
2590     if (!action)
2591         {
2592         path = "/ui/MenuBar/MenuHelp/";
2593         path.append(name);
2594         action = uiManager->get_action(path);
2595         }
2596     if (!action)
2597         return;
2598     action->set_sensitive(val);
2602 bool PedroGui::configLoad()
2604     if (!config.readFile("pedro.ini"))
2605         return false;
2606     return true;
2610 bool PedroGui::configSave()
2612     if (!config.writeFile("pedro.ini"))
2613         return false;
2614     return true;
2620 bool PedroGui::doSetup()
2622     configLoad();
2624     set_title("Pedro XMPP Client");
2625     set_size_request(500, 300);
2626     add(mainBox);
2628     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
2630     //### FILE MENU
2631     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
2633     actionGroup->add( Gtk::Action::create("Connect",
2634                                   Gtk::Stock::CONNECT, "Connect"),
2635     sigc::mem_fun(*this, &PedroGui::connectCallback) );
2637     actionGroup->add( Gtk::Action::create("Chat",
2638                                   Gtk::Stock::CONNECT, "Chat"),
2639     sigc::mem_fun(*this, &PedroGui::chatCallback) );
2641     actionGroup->add( Gtk::Action::create("GroupChat",
2642                                   Gtk::Stock::CONNECT, "Group Chat"),
2643     sigc::mem_fun(*this, &PedroGui::groupChatCallback) );
2645     actionGroup->add( Gtk::Action::create("Disconnect",
2646                                   Gtk::Stock::DISCONNECT, "Disconnect"),
2647     sigc::mem_fun(*this, &PedroGui::disconnectCallback) );
2649     actionGroup->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
2650     sigc::mem_fun(*this, &PedroGui::quitCallback) );
2652     //### EDIT MENU
2653     actionGroup->add( Gtk::Action::create("MenuEdit", "_Edit") );
2654     actionGroup->add( Gtk::Action::create("SelectFont",
2655                                   Gtk::Stock::SELECT_FONT, "Select Font"),
2656     sigc::mem_fun(*this, &PedroGui::fontCallback) );
2657     actionGroup->add( Gtk::Action::create("SelectColor",
2658                                   Gtk::Stock::SELECT_COLOR, "Select Color"),
2659     sigc::mem_fun(*this, &PedroGui::colorCallback) );
2661     //### REGISTER MENU
2662     actionGroup->add( Gtk::Action::create("MenuRegister", "_Registration") );
2663     actionGroup->add( Gtk::Action::create("RegPass",
2664                                   Gtk::Stock::DIALOG_AUTHENTICATION, "Change Password"),
2665     sigc::mem_fun(*this, &PedroGui::regPassCallback) );
2666     actionGroup->add( Gtk::Action::create("RegCancel",
2667                                   Gtk::Stock::CANCEL, "Cancel Registration"),
2668     sigc::mem_fun(*this, &PedroGui::regCancelCallback) );
2670     //### TRANSFER MENU
2671     actionGroup->add( Gtk::Action::create("MenuTransfer", "_Transfer") );
2672     actionGroup->add( Gtk::Action::create("SendFile",
2673                                   Gtk::Stock::NETWORK, "Send File"),
2674     sigc::mem_fun(*this, &PedroGui::sendFileCallback) );
2676     //### HELP MENU
2677     actionGroup->add( Gtk::Action::create("MenuHelp", "_Help") );
2678     actionGroup->add( Gtk::Action::create("About",
2679                                   Gtk::Stock::ABOUT, "About Pedro"),
2680     sigc::mem_fun(*this, &PedroGui::aboutCallback) );
2682     uiManager = Gtk::UIManager::create();
2684     uiManager->insert_action_group(actionGroup, 0);
2685     add_accel_group(uiManager->get_accel_group());
2687     Glib::ustring ui_info =
2688         "<ui>"
2689         "  <menubar name='MenuBar'>"
2690         "    <menu action='MenuFile'>"
2691         "      <menuitem action='Connect'/>"
2692         "      <separator/>"
2693         "      <menuitem action='Chat'/>"
2694         "      <menuitem action='GroupChat'/>"
2695         "      <separator/>"
2696         "      <menuitem action='Disconnect'/>"
2697         "      <menuitem action='Quit'/>"
2698         "    </menu>"
2699         "    <menu action='MenuEdit'>"
2700         "      <menuitem action='SelectFont'/>"
2701         "      <menuitem action='SelectColor'/>"
2702         "    </menu>"
2703         "    <menu action='MenuRegister'>"
2704         "      <menuitem action='RegPass'/>"
2705         "      <menuitem action='RegCancel'/>"
2706         "    </menu>"
2707         "    <menu action='MenuTransfer'>"
2708         "      <menuitem action='SendFile'/>"
2709         "    </menu>"
2710         "    <menu action='MenuHelp'>"
2711         "      <menuitem action='About'/>"
2712         "    </menu>"
2713         "  </menubar>"
2714         "</ui>";
2716     uiManager->add_ui_from_string(ui_info);
2717     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
2718     menuBarBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);
2720     padlockDisable();
2721     menuBarBox.pack_end(padlockIcon, Gtk::PACK_SHRINK);
2723     mainBox.pack_start(menuBarBox, Gtk::PACK_SHRINK);
2725     actionEnable("Connect",    true);
2726     actionEnable("Chat",       false);
2727     actionEnable("GroupChat",  false);
2728     actionEnable("Disconnect", false);
2729     actionEnable("RegPass",    false);
2730     actionEnable("RegCancel",  false);
2732     mainBox.pack_start(vPaned);
2733     vPaned.add1(roster);
2734     vPaned.add2(messageList);
2735     roster.setParent(this);
2737     show_all_children();
2739     //# Start a timer to check the queue every nn milliseconds
2740     Glib::signal_timeout().connect(
2741            sigc::mem_fun(*this, &PedroGui::checkEventQueue), 20 );
2743     //client.addXmppEventListener(*this);
2744     client.eventQueueEnable(true);
2746     return true;
2750 } // namespace Pedro
2754 //########################################################################
2755 //# E N D    O F     F I L E
2756 //########################################################################