Code

Add a configuration record. Modify the GUI later.
[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 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         }
1063     messageList.postMessage("*", presStr);
1064     userList.clear();
1065     std::vector<XmppUser> memberList =
1066          parent.client.groupChatGetUserList(groupJid);
1067     for (unsigned int i=0 ; i<memberList.size() ; i++)
1068         {
1069         XmppUser user = memberList[i];
1070         userList.addUser(user.nick, user.show);
1071         }
1072     return true;
1076 void GroupChatWindow::doChat(const DOMString &nick)
1078     printf("##Chat with %s\n", nick.c_str());
1079     DOMString fullJid = groupJid;
1080     fullJid.append("/");
1081     fullJid.append(nick);
1082     parent.doChat(fullJid);
1085 void GroupChatWindow::doSendFile(const DOMString &nick)
1087     printf("##Send file to %s\n", nick.c_str());
1088     DOMString fullJid = groupJid;
1089     fullJid.append("/");
1090     fullJid.append(nick);
1091     parent.doSendFile(fullJid);
1097 //#########################################################################
1098 //# C O N N E C T    D I A L O G
1099 //#########################################################################
1102 void ConnectDialog::okCallback()
1104     response(Gtk::RESPONSE_OK);
1105     hide();
1108 void ConnectDialog::cancelCallback()
1110     response(Gtk::RESPONSE_CANCEL);
1111     hide();
1115 bool ConnectDialog::doSetup()
1117     set_title("Connect");
1118     set_size_request(300,200);
1120     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1121     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1122     actionGroup->add( Gtk::Action::create("Connect", Gtk::Stock::CONNECT, "Connect"),
1123     sigc::mem_fun(*this, &ConnectDialog::okCallback) );
1124     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1125     sigc::mem_fun(*this, &ConnectDialog::cancelCallback) );
1128     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1130     uiManager->insert_action_group(actionGroup, 0);
1131     add_accel_group(uiManager->get_accel_group());
1133     Glib::ustring ui_info =
1134         "<ui>"
1135         "  <menubar name='MenuBar'>"
1136         "    <menu action='MenuFile'>"
1137         "      <menuitem action='Connect'/>"
1138         "      <separator/>"
1139         "      <menuitem action='Cancel'/>"
1140         "    </menu>"
1141         "  </menubar>"
1142         "</ui>";
1144     uiManager->add_ui_from_string(ui_info);
1145     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1146     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1148     table.resize(6, 2);
1149     get_vbox()->pack_start(table);
1151     parent.client.setHost("broadway.dynalias.com");
1152     parent.client.setPort(5222);
1153     parent.client.setUsername("");
1154     parent.client.setPassword("");
1155     parent.client.setResource("pedroXmpp");
1157     hostLabel.set_text("Host");
1158     table.attach(hostLabel, 0, 1, 0, 1);
1159     hostField.set_text(parent.client.getHost());
1160     table.attach(hostField, 1, 2, 0, 1);
1162     portLabel.set_text("Port");
1163     table.attach(portLabel, 0, 1, 1, 2);
1164     portSpinner.set_digits(0);
1165     portSpinner.set_range(1, 65000);
1166     portSpinner.set_value(parent.client.getPort());
1167     table.attach(portSpinner, 1, 2, 1, 2);
1169     userLabel.set_text("Username");
1170     table.attach(userLabel, 0, 1, 2, 3);
1171     userField.set_text(parent.client.getUsername());
1172     table.attach(userField, 1, 2, 2, 3);
1174     passLabel.set_text("Password");
1175     table.attach(passLabel, 0, 1, 3, 4);
1176     passField.set_visibility(false);
1177     passField.set_text(parent.client.getPassword());
1178     passField.signal_activate().connect(
1179            sigc::mem_fun(*this, &ConnectDialog::okCallback) );
1180     table.attach(passField, 1, 2, 3, 4);
1182     resourceLabel.set_text("Resource");
1183     table.attach(resourceLabel, 0, 1, 4, 5);
1184     resourceField.set_text(parent.client.getResource());
1185     table.attach(resourceField, 1, 2, 4, 5);
1187     registerLabel.set_text("Register");
1188     table.attach(registerLabel, 0, 1, 5, 6);
1189     registerButton.set_active(false);
1190     table.attach(registerButton, 1, 2, 5, 6);
1192     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1193     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1195     show_all_children();
1197     return true;
1203 //#########################################################################
1204 //# P A S S W O R D      D I A L O G
1205 //#########################################################################
1208 void PasswordDialog::okCallback()
1210     Glib::ustring pass     = passField.get_text();
1211     Glib::ustring newpass  = newField.get_text();
1212     Glib::ustring confpass = confField.get_text();
1213     if ((pass.size()     < 5 || pass.size()    > 12 ) ||
1214         (newpass.size()  < 5 || newpass.size() > 12 ) ||
1215         (confpass.size() < 5 || confpass.size()> 12 ))
1216         {
1217         Gtk::MessageDialog dlg(*this, "Password must be 5 to 12 characters",
1218             false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
1219         dlg.run();
1220         }
1221     else if (newpass != confpass)
1222         {
1223         Gtk::MessageDialog dlg(*this, "New password and confirmation do not match",
1224             false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
1225         dlg.run();
1226         }
1227     else
1228         {
1229         //response(Gtk::RESPONSE_OK);
1230         hide();
1231         }
1234 void PasswordDialog::cancelCallback()
1236     //response(Gtk::RESPONSE_CANCEL);
1237     hide();
1240 void PasswordDialog::on_response(int response_id)
1242     if (response_id == Gtk::RESPONSE_OK)
1243         okCallback();
1244     else
1245         cancelCallback();
1248 bool PasswordDialog::doSetup()
1250     set_title("Change Password");
1251     set_size_request(300,200);
1253     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1254     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1255     actionGroup->add( Gtk::Action::create("Change", Gtk::Stock::OK, "Change Password"),
1256     sigc::mem_fun(*this, &PasswordDialog::okCallback) );
1257     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1258     sigc::mem_fun(*this, &PasswordDialog::cancelCallback) );
1261     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1263     uiManager->insert_action_group(actionGroup, 0);
1264     add_accel_group(uiManager->get_accel_group());
1266     Glib::ustring ui_info =
1267         "<ui>"
1268         "  <menubar name='MenuBar'>"
1269         "    <menu action='MenuFile'>"
1270         "      <menuitem action='Change'/>"
1271         "      <separator/>"
1272         "      <menuitem action='Cancel'/>"
1273         "    </menu>"
1274         "  </menubar>"
1275         "</ui>";
1277     uiManager->add_ui_from_string(ui_info);
1278     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1279     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1281     table.resize(3, 2);
1282     get_vbox()->pack_start(table);
1284     passLabel.set_text("Current Password");
1285     table.attach(passLabel, 0, 1, 0, 1);
1286     passField.set_visibility(false);
1287     passField.set_text(parent.client.getPassword());
1288     table.attach(passField, 1, 2, 0, 1);
1290     newLabel.set_text("New Password");
1291     table.attach(newLabel, 0, 1, 1, 2);
1292     newField.set_visibility(false);
1293     table.attach(newField, 1, 2, 1, 2);
1295     confLabel.set_text("Confirm New Password");
1296     table.attach(confLabel, 0, 1, 2, 3);
1297     confField.set_visibility(false);
1298     confField.signal_activate().connect(
1299            sigc::mem_fun(*this, &PasswordDialog::okCallback) );
1300     table.attach(confField, 1, 2, 2, 3);
1302     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1303     add_button(Gtk::Stock::OK,     Gtk::RESPONSE_OK);
1305     show_all_children();
1307     return true;
1310 //#########################################################################
1311 //# C H A T    D I A L O G
1312 //#########################################################################
1315 void ChatDialog::okCallback()
1317     response(Gtk::RESPONSE_OK);
1318     hide();
1321 void ChatDialog::cancelCallback()
1323     response(Gtk::RESPONSE_CANCEL);
1324     hide();
1328 bool ChatDialog::doSetup()
1330     set_title("Chat with User");
1331     set_size_request(300,200);
1333     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1334     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1335     actionGroup->add( Gtk::Action::create("Chat", Gtk::Stock::CONNECT, "Chat"),
1336     sigc::mem_fun(*this, &ChatDialog::okCallback) );
1337     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1338     sigc::mem_fun(*this, &ChatDialog::cancelCallback) );
1341     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1343     uiManager->insert_action_group(actionGroup, 0);
1344     add_accel_group(uiManager->get_accel_group());
1346     Glib::ustring ui_info =
1347         "<ui>"
1348         "  <menubar name='MenuBar'>"
1349         "    <menu action='MenuFile'>"
1350         "      <menuitem action='Chat'/>"
1351         "      <separator/>"
1352         "      <menuitem action='Cancel'/>"
1353         "    </menu>"
1354         "  </menubar>"
1355         "</ui>";
1357     uiManager->add_ui_from_string(ui_info);
1358     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1359     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1361     table.resize(2, 2);
1362     get_vbox()->pack_start(table);
1364     userLabel.set_text("User");
1365     table.attach(userLabel, 0, 1, 0, 1);
1366     //userField.set_text("");
1367     table.attach(userField, 1, 2, 0, 1);
1369     //userField.set_text("");
1370     table.attach(textField, 0, 2, 1, 2);
1372     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1373     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1375     show_all_children();
1377     return true;
1380 //#########################################################################
1381 //# G R O U P    C H A T   D I A L O G
1382 //#########################################################################
1385 void GroupChatDialog::okCallback()
1387     response(Gtk::RESPONSE_OK);
1388     hide();
1391 void GroupChatDialog::cancelCallback()
1393     response(Gtk::RESPONSE_CANCEL);
1394     hide();
1398 bool GroupChatDialog::doSetup()
1400     set_title("Join Group Chat");
1401     set_size_request(300,200);
1403     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1404     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1405     actionGroup->add( Gtk::Action::create("Join", Gtk::Stock::CONNECT, "Join Group"),
1406     sigc::mem_fun(*this, &GroupChatDialog::okCallback) );
1407     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1408     sigc::mem_fun(*this, &GroupChatDialog::cancelCallback) );
1411     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1413     uiManager->insert_action_group(actionGroup, 0);
1414     add_accel_group(uiManager->get_accel_group());
1416     Glib::ustring ui_info =
1417         "<ui>"
1418         "  <menubar name='MenuBar'>"
1419         "    <menu action='MenuFile'>"
1420         "      <menuitem action='Join'/>"
1421         "      <separator/>"
1422         "      <menuitem action='Cancel'/>"
1423         "    </menu>"
1424         "  </menubar>"
1425         "</ui>";
1427     uiManager->add_ui_from_string(ui_info);
1428     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1429     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1431     table.resize(4, 2);
1432     get_vbox()->pack_start(table);
1434     groupLabel.set_text("Group");
1435     table.attach(groupLabel, 0, 1, 0, 1);
1436     groupField.set_text("inkscape");
1437     table.attach(groupField, 1, 2, 0, 1);
1439     hostLabel.set_text("Host");
1440     table.attach(hostLabel, 0, 1, 1, 2);
1441     hostField.set_text("conference.gristle.org");
1442     table.attach(hostField, 1, 2, 1, 2);
1444     nickLabel.set_text("Alt Name");
1445     table.attach(nickLabel, 0, 1, 2, 3);
1446     table.attach(nickField, 1, 2, 2, 3);
1448     passLabel.set_text("Password");
1449     table.attach(passLabel, 0, 1, 3, 4);
1450     passField.set_visibility(false);
1451     //passField.set_text("");
1452     table.attach(passField, 1, 2, 3, 4);
1455     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1456     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1458     show_all_children();
1460     return true;
1463 //#########################################################################
1464 //# F I L E    S E N D   D I A L O G
1465 //#########################################################################
1468 void FileSendDialog::okCallback()
1470     response(Gtk::RESPONSE_OK);
1471     hide();
1474 void FileSendDialog::cancelCallback()
1476     response(Gtk::RESPONSE_CANCEL);
1477     hide();
1481 void FileSendDialog::buttonCallback()
1483     Gtk::FileChooserDialog dlg("Select a file to send",
1484                       Gtk::FILE_CHOOSER_ACTION_OPEN);
1485     dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1486     dlg.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1487     int ret = dlg.run();
1488     if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT)
1489         {
1490         fileName = dlg.get_filename();
1491         fileNameField.set_text(fileName);
1492         }
1495 bool FileSendDialog::doSetup()
1497     set_title("Send file to user");
1498     set_size_request(400,150);
1500     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1501     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1502     actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"),
1503     sigc::mem_fun(*this, &FileSendDialog::okCallback) );
1504     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1505     sigc::mem_fun(*this, &FileSendDialog::cancelCallback) );
1508     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1510     uiManager->insert_action_group(actionGroup, 0);
1511     add_accel_group(uiManager->get_accel_group());
1513     Glib::ustring ui_info =
1514         "<ui>"
1515         "  <menubar name='MenuBar'>"
1516         "    <menu action='MenuFile'>"
1517         "      <menuitem action='Send'/>"
1518         "      <separator/>"
1519         "      <menuitem action='Cancel'/>"
1520         "    </menu>"
1521         "  </menubar>"
1522         "</ui>";
1524     uiManager->add_ui_from_string(ui_info);
1525     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1526     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1528     table.resize(2, 2);
1529     get_vbox()->pack_start(table);
1531     jidLabel.set_text("User ID");
1532     table.attach(jidLabel, 0, 1, 0, 1);
1533     jidField.set_text("inkscape");
1534     table.attach(jidField, 1, 2, 0, 1);
1536     selectFileButton.set_label("Select");
1537     selectFileButton.signal_clicked().connect(
1538            sigc::mem_fun(*this, &FileSendDialog::buttonCallback) );
1539     table.attach(selectFileButton, 0, 1, 1, 2);
1541     fileName = "";
1542     fileNameField.set_text("No file selected");
1543     fileNameField.set_editable(false);
1544     table.attach(fileNameField, 1, 2, 1, 2);
1546     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1547     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1549     show_all_children();
1551     return true;
1555 //#########################################################################
1556 //# F I L E    R E C E I V E   D I A L O G
1557 //#########################################################################
1560 void FileReceiveDialog::okCallback()
1562     response(Gtk::RESPONSE_OK);
1563     hide();
1566 void FileReceiveDialog::cancelCallback()
1568     response(Gtk::RESPONSE_CANCEL);
1569     hide();
1572 void FileReceiveDialog::buttonCallback()
1574     Gtk::FileChooserDialog dlg("Select a file to save",
1575                       Gtk::FILE_CHOOSER_ACTION_SAVE);
1576     dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1577     dlg.add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1578     int ret = dlg.run();
1579     if (ret == Gtk::RESPONSE_OK || ret == Gtk::RESPONSE_ACCEPT)
1580         {
1581         fileName = dlg.get_filename();
1582         fileNameField.set_text(fileName);
1583         }
1587 bool FileReceiveDialog::doSetup()
1589     set_title("File being sent by user");
1590     set_size_request(450,250);
1592     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
1593     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
1594     actionGroup->add( Gtk::Action::create("Send", Gtk::Stock::NETWORK, "Send File"),
1595     sigc::mem_fun(*this, &FileReceiveDialog::okCallback) );
1596     actionGroup->add( Gtk::Action::create("Cancel",  Gtk::Stock::CANCEL, "Cancel"),
1597     sigc::mem_fun(*this, &FileReceiveDialog::cancelCallback) );
1600     Glib::RefPtr<Gtk::UIManager> uiManager = Gtk::UIManager::create();
1602     uiManager->insert_action_group(actionGroup, 0);
1603     add_accel_group(uiManager->get_accel_group());
1605     Glib::ustring ui_info =
1606         "<ui>"
1607         "  <menubar name='MenuBar'>"
1608         "    <menu action='MenuFile'>"
1609         "      <menuitem action='Send'/>"
1610         "      <separator/>"
1611         "      <menuitem action='Cancel'/>"
1612         "    </menu>"
1613         "  </menubar>"
1614         "</ui>";
1616     uiManager->add_ui_from_string(ui_info);
1617     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
1618     get_vbox()->pack_start(*pMenuBar, Gtk::PACK_SHRINK);
1620     table.resize(6, 2);
1621     get_vbox()->pack_start(table);
1623     jidLabel.set_text("User ID");
1624     table.attach(jidLabel, 0, 1, 0, 1);
1625     jidField.set_text(jid);
1626     jidField.set_editable(false);
1627     table.attach(jidField, 1, 2, 0, 1);
1629     offeredLabel.set_text("File Offered");
1630     table.attach(offeredLabel, 0, 1, 1, 2);
1631     offeredField.set_text(offeredName);
1632     offeredField.set_editable(false);
1633     table.attach(offeredField, 1, 2, 1, 2);
1635     descLabel.set_text("Description");
1636     table.attach(descLabel, 0, 1, 2, 3);
1637     descField.set_text(desc);
1638     descField.set_editable(false);
1639     table.attach(descField, 1, 2, 2, 3);
1641     char buf[32];
1642     snprintf(buf, 31, "%ld", fileSize);
1643     sizeLabel.set_text("Size");
1644     table.attach(sizeLabel, 0, 1, 3, 4);
1645     sizeField.set_text(buf);
1646     sizeField.set_editable(false);
1647     table.attach(sizeField, 1, 2, 3, 4);
1649     hashLabel.set_text("MD5 Hash");
1650     table.attach(hashLabel, 0, 1, 4, 5);
1651     hashField.set_text(hash);
1652     hashField.set_editable(false);
1653     table.attach(hashField, 1, 2, 4, 5);
1655     selectFileButton.set_label("Select");
1656     selectFileButton.signal_clicked().connect(
1657            sigc::mem_fun(*this, &FileReceiveDialog::buttonCallback) );
1658     table.attach(selectFileButton, 0, 1, 5, 6);
1660     fileName = "";
1661     fileNameField.set_text("No file selected");
1662     fileNameField.set_editable(false);
1663     table.attach(fileNameField, 1, 2, 5, 6);
1666     add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1667     add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_OK);
1669     show_all_children();
1671     return true;
1675 //#########################################################################
1676 //# M A I N    W I N D O W
1677 //#########################################################################
1679 PedroGui::PedroGui()
1681     doSetup();
1684 PedroGui::~PedroGui()
1686     chatDeleteAll();
1687     groupChatDeleteAll();
1691 void PedroGui::error(const char *fmt, ...)
1693     va_list args;
1694     va_start(args, fmt);
1695     vsnprintf(writeBuf, writeBufLen, fmt, args);
1696     va_end(args) ;
1698     Gtk::MessageDialog dlg(writeBuf,
1699                            false,
1700                            Gtk::MESSAGE_ERROR,
1701                            Gtk::BUTTONS_OK,
1702                            true);
1703     dlg.run();
1706 void PedroGui::status(const char *fmt, ...)
1708     va_list args;
1709     va_start(args, fmt);
1710     vsnprintf(writeBuf, writeBufLen, fmt, args);
1711     va_end(args) ;
1712     messageList.postMessage("STATUS", writeBuf);
1715 //################################
1716 //# CHAT WINDOW MANAGEMENT
1717 //################################
1718 bool PedroGui::chatCreate(const DOMString &userJid)
1720     std::vector<ChatWindow *>::iterator iter;
1721     for (iter=chats.begin() ; iter != chats.end() ; iter++)
1722         {
1723         if (userJid == (*iter)->getJid())
1724             return false;
1725         }
1726     ChatWindow *chat = new ChatWindow(*this, userJid);
1727     chat->show();
1728     chats.push_back(chat);
1729     return true;
1732 bool PedroGui::chatDelete(const DOMString &userJid)
1734     std::vector<ChatWindow *>::iterator iter;
1735     for (iter=chats.begin() ; iter != chats.end() ; )
1736         {
1737         if (userJid == (*iter)->getJid())
1738             {
1739             delete(*iter);
1740             iter = chats.erase(iter);
1741             }
1742         else
1743             iter++;
1744         }
1745     return true;
1748 bool PedroGui::chatDeleteAll()
1750     std::vector<ChatWindow *>::iterator iter;
1751     for (iter=chats.begin() ; iter != chats.end() ; )
1752         {
1753         delete(*iter);
1754         iter = chats.erase(iter);
1755         }
1756     return true;
1759 bool PedroGui::chatMessage(const DOMString &from, const DOMString &data)
1761     std::vector<ChatWindow *>::iterator iter;
1762     for (iter=chats.begin() ; iter != chats.end() ; iter++)
1763         {
1764         if (from == (*iter)->getJid())
1765             {
1766             (*iter)->postMessage(data);
1767             return true;
1768             }
1769         }
1770     ChatWindow *chat = new ChatWindow(*this, from);
1771     chat->show();
1772     chats.push_back(chat);
1773     chat->postMessage(data);
1774     return true;
1777 //################################
1778 //# GROUP CHAT WINDOW MANAGEMENT
1779 //################################
1780 bool PedroGui::groupChatCreate(const DOMString &groupJid, const DOMString &nick)
1782     std::vector<GroupChatWindow *>::iterator iter;
1783     for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++)
1784         {
1785         if (groupJid == (*iter)->getGroupJid())
1786             return false;
1787         }
1788     GroupChatWindow *chat = new GroupChatWindow(*this, groupJid, nick);
1789     chat->show();
1790     groupChats.push_back(chat);
1791     return true;
1795 bool PedroGui::groupChatDelete(const DOMString &groupJid, const DOMString &nick)
1797     std::vector<GroupChatWindow *>::iterator iter;
1798     for (iter=groupChats.begin() ; iter != groupChats.end() ;)
1799         {
1800         if (groupJid == (*iter)->getGroupJid() &&
1801             nick     == (*iter)->getNick())
1802             {
1803             delete(*iter);
1804             iter = groupChats.erase(iter);
1805             }
1806         else
1807             iter++;
1808         }
1809     return true;
1813 bool PedroGui::groupChatDeleteAll()
1815     std::vector<GroupChatWindow *>::iterator iter;
1816     for (iter=groupChats.begin() ; iter != groupChats.end() ; )
1817         {
1818         delete(*iter);
1819         iter = groupChats.erase(iter);
1820         }
1821     return true;
1825 bool PedroGui::groupChatMessage(const DOMString &groupJid,
1826               const DOMString &from, const DOMString &data)
1828     std::vector<GroupChatWindow *>::iterator iter;
1829     for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++)
1830         {
1831         if (groupJid == (*iter)->getGroupJid())
1832             {
1833             (*iter)->receiveMessage(from, data);
1834             }
1835         }
1836     return true;
1839 bool PedroGui::groupChatPresence(const DOMString &groupJid,
1840                       const DOMString &nick, bool presence,
1841                       const DOMString &show,
1842                       const DOMString &status)
1844     std::vector<GroupChatWindow *>::iterator iter;
1845     for (iter=groupChats.begin() ; iter != groupChats.end() ; iter++)
1846         {
1847         if (groupJid == (*iter)->getGroupJid())
1848             {
1849             (*iter)->receivePresence(nick, presence, show, status);
1850             }
1851         }
1852     return true;
1855 //################################
1856 //# EVENTS
1857 //################################
1859 /**
1860  *
1861  */
1862 void PedroGui::padlockEnable()
1864     padlockIcon.set(Gtk::Stock::DIALOG_AUTHENTICATION,
1865                Gtk::ICON_SIZE_MENU);
1868 /**
1869  *
1870  */
1871 void PedroGui::padlockDisable()
1873     padlockIcon.clear();
1877 /**
1878  *
1879  */
1880 void PedroGui::handleConnectEvent()
1882      status("##### CONNECTED");
1883      actionEnable("Connect",    false);
1884      actionEnable("Chat",       true);
1885      actionEnable("GroupChat",  true);
1886      actionEnable("Disconnect", true);
1887      actionEnable("RegPass",    true);
1888      actionEnable("RegCancel",  true);
1889      DOMString title = "Pedro - ";
1890      title.append(client.getJid());
1891      set_title(title);
1895 /**
1896  *
1897  */
1898 void PedroGui::handleDisconnectEvent()
1900      status("##### DISCONNECTED");
1901      actionEnable("Connect",    true);
1902      actionEnable("Chat",       false);
1903      actionEnable("GroupChat",  false);
1904      actionEnable("Disconnect", false);
1905      actionEnable("RegPass",    false);
1906      actionEnable("RegCancel",  false);
1907      padlockDisable();
1908      DOMString title = "Pedro";
1909      set_title(title);
1910      chatDeleteAll();
1911      groupChatDeleteAll();
1915 /**
1916  *
1917  */
1918 void PedroGui::doEvent(const XmppEvent &event)
1921     int typ = event.getType();
1922     switch (typ)
1923         {
1924         case XmppEvent::EVENT_STATUS:
1925             {
1926             //printf("##### STATUS: %s\n", event.getData().c_str());
1927             status(event.getData().c_str());
1928             break;
1929             }
1930         case XmppEvent::EVENT_ERROR:
1931             {
1932             //printf("##### ERROR: %s\n", event.getData().c_str());
1933             error(event.getData().c_str());
1934             padlockDisable();
1935             break;
1936             }
1937         case XmppEvent::EVENT_SSL_STARTED:
1938             {
1939             padlockEnable();
1940             break;
1941             }
1942         case XmppEvent::EVENT_CONNECTED:
1943             {
1944             handleConnectEvent();
1945             break;
1946             }
1947         case XmppEvent::EVENT_DISCONNECTED:
1948             {
1949             handleDisconnectEvent();
1950             break;
1951             }
1952         case XmppEvent::EVENT_MESSAGE:
1953             {
1954             status("##### MESSAGE: %s\n", event.getFrom().c_str());
1955             chatMessage(event.getFrom(), event.getData());
1956             break;
1957             }
1958         case XmppEvent::EVENT_PRESENCE:
1959             {
1960             status("##### PRESENCE: %s\n", event.getFrom().c_str());
1961             roster.refresh();
1962             break;
1963             }
1964         case XmppEvent::EVENT_ROSTER:
1965             {
1966             status("##### ROSTER\n");
1967             roster.refresh();
1968             break;
1969             }
1970         case XmppEvent::EVENT_MUC_JOIN:
1971             {
1972             status("##### GROUP JOINED: %s\n", event.getGroup().c_str());
1973             break;
1974             }
1975         case XmppEvent::EVENT_MUC_MESSAGE:
1976             {
1977             //printf("##### MUC_MESSAGE: %s\n", event.getGroup().c_str());
1978             groupChatMessage(event.getGroup(),
1979                     event.getFrom(), event.getData());
1980             break;
1981             }
1982         case XmppEvent::EVENT_MUC_PRESENCE:
1983             {
1984             //printf("##### MUC_USER LIST: %s\n", event.getFrom().c_str());
1985             groupChatPresence(event.getGroup(),
1986                               event.getFrom(),
1987                               event.getPresence(),
1988                               event.getShow(),
1989                               event.getStatus());
1990             break;
1991             }
1992         case XmppEvent::EVENT_MUC_LEAVE:
1993             {
1994             status("##### GROUP LEFT: %s\n", event.getGroup().c_str());
1995             groupChatDelete(event.getGroup(), event.getFrom());
1996             break;
1997             }
1998         case XmppEvent::EVENT_FILE_RECEIVE:
1999             {
2000             status("##### FILE RECEIVE: %s\n", event.getFileName().c_str());
2001             doReceiveFile(event.getFrom(), event.getIqId(), event.getStreamId(),
2002                        event.getFileName(), event.getFileDesc(),
2003                        event.getFileSize(), event.getFileHash());
2004             break;
2005             }
2006         case XmppEvent::EVENT_REGISTRATION_NEW:
2007             {
2008             status("##### REGISTERED: %s at %s\n",
2009                        event.getTo().c_str(), event.getFrom().c_str());
2010             break;
2011             }
2012         case XmppEvent::EVENT_REGISTRATION_CHANGE_PASS:
2013             {
2014             status("##### PASSWORD CHANGED: %s at %s\n",
2015                        event.getTo().c_str(), event.getFrom().c_str());
2016             break;
2017             }
2018         case XmppEvent::EVENT_REGISTRATION_CANCEL:
2019             {
2020             //client.disconnect();
2021             status("##### REGISTERATION CANCELLED: %s at %s\n",
2022                        event.getTo().c_str(), event.getFrom().c_str());
2023             break;
2024             }
2025         default:
2026             {
2027             printf("unknown event type: %d\n", typ);
2028             break;
2029             }
2030         }
2034 /**
2035  *
2036  */
2037 bool PedroGui::checkEventQueue()
2039     while (client.eventQueueAvailable() > 0)
2040         {
2041         XmppEvent evt = client.eventQueuePop();
2042         doEvent(evt);
2043         }
2045     while( Gtk::Main::events_pending() )
2046         Gtk::Main::iteration();
2048     return true;
2052 //##################
2053 //# COMMANDS
2054 //##################
2055 void PedroGui::doChat(const DOMString &jid)
2057     if (jid.size()>0)
2058         {
2059         chatCreate(jid);
2060         return;
2061         }
2063     FileSendDialog dlg(*this);
2064     int ret = dlg.run();
2065     if (ret == Gtk::RESPONSE_OK)
2066         {
2067         chatCreate(dlg.getJid());
2068         }
2072 void PedroGui::doSendFile(const DOMString &jid)
2074     FileSendDialog dlg(*this);
2075     if (jid.size()>0)
2076         dlg.setJid(jid);
2077     int ret = dlg.run();
2078     if (ret == Gtk::RESPONSE_OK)
2079         {
2080         DOMString fileName = dlg.getFileName();
2081         printf("fileName:%s\n", fileName.c_str());
2082         DOMString offeredName = "";
2083         DOMString desc = "";
2084         client.fileSendBackground(jid, offeredName, fileName, desc);
2085         }
2089 void PedroGui::doReceiveFile(
2090                       const DOMString &jid,
2091                       const DOMString &iqId,
2092                       const DOMString &streamId,
2093                       const DOMString &offeredName,
2094                       const DOMString &desc,
2095                       long  size,
2096                       const DOMString &hash
2097                       )
2100     FileReceiveDialog dlg(*this, jid, iqId, streamId,
2101                           offeredName, desc, size, hash);
2102     int ret = dlg.run();
2103     if (ret == Gtk::RESPONSE_OK)
2104         {
2105         DOMString fileName = dlg.getFileName();
2106         printf("fileName:%s\n", fileName.c_str());
2107         client.fileReceiveBackground(jid, iqId, streamId, fileName, size, hash);
2108         }
2113 //##################
2114 //# CALLBACKS
2115 //##################
2116 void PedroGui::connectCallback()
2118     ConnectDialog dialog(*this);
2119     int result = dialog.run();
2120     dialog.hide();
2121     if (result == Gtk::RESPONSE_OK)
2122         {
2123         client.setHost(dialog.getHost());
2124         client.setPort(dialog.getPort());
2125         client.setUsername(dialog.getUser());
2126         client.setPassword(dialog.getPass());
2127         client.setResource(dialog.getResource());
2128         client.setDoRegister(dialog.getRegister());
2129         client.connect();
2130         }
2135 void PedroGui::chatCallback()
2137     ChatDialog dialog(*this);
2138     int result = dialog.run();
2139     dialog.hide();
2140     if (result == Gtk::RESPONSE_OK)
2141         {
2142         client.message(dialog.getUser(), dialog.getText());
2143         }
2148 void PedroGui::groupChatCallback()
2150     GroupChatDialog dialog(*this);
2151     int result = dialog.run();
2152     dialog.hide();
2153     if (result != Gtk::RESPONSE_OK)
2154         return;
2155     DOMString groupJid = dialog.getGroup();
2156     groupJid.append("@");
2157     groupJid.append(dialog.getHost());
2158     if (client.groupChatExists(groupJid))
2159         {
2160         error("Group chat %s already exists", groupJid.c_str());
2161         return;
2162         }
2163     groupChatCreate(groupJid, dialog.getNick());
2164     client.groupChatJoin(groupJid, dialog.getNick(), dialog.getPass() );
2168 void PedroGui::disconnectCallback()
2170     client.disconnect();
2174 void PedroGui::quitCallback()
2176     Gtk::Main::quit();
2180 void PedroGui::fontCallback()
2182     Gtk::FontSelectionDialog dlg;
2183     int ret = dlg.run();
2184     if (ret == Gtk::RESPONSE_OK)
2185         {
2186         Glib::ustring fontName = dlg.get_font_name();
2187         Pango::FontDescription fontDesc(fontName);
2188         modify_font(fontDesc);
2189         }
2192 void PedroGui::colorCallback()
2194     Gtk::ColorSelectionDialog dlg;
2195     int ret = dlg.run();
2196     if (ret == Gtk::RESPONSE_OK)
2197         {
2198         Gdk::Color col = dlg.get_colorsel()->get_current_color();
2199         modify_bg(Gtk::STATE_NORMAL, col);
2200         }
2203 void PedroGui::regPassCallback()
2205     PasswordDialog dlg(*this);
2206     int ret = dlg.run();
2207     if (ret == Gtk::RESPONSE_OK)
2208         {
2209         DOMString newpass = dlg.getNewPass();
2210         client.inBandRegistrationChangePassword(newpass);
2211         }
2215 void PedroGui::regCancelCallback()
2217     Gtk::MessageDialog dlg(*this, "Do you want to cancel your registration on the server?",
2218         false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true);
2219     int ret = dlg.run();
2220     if (ret == Gtk::RESPONSE_YES)
2221         {
2222         client.inBandRegistrationCancel();
2223         }
2228 void PedroGui::sendFileCallback()
2230     doSendFile("");
2235 void PedroGui::aboutCallback()
2237     Gtk::AboutDialog dlg;
2238     std::vector<Glib::ustring>authors;
2239     authors.push_back("Bob Jamison");
2240     dlg.set_authors(authors);
2241     DOMString comments = "A simple XMPP gui client  ";
2242     comments.append("Based on the Pedro XMPP client");
2243     dlg.set_comments(comments);
2244     dlg.set_version("1.0");
2245     dlg.run();
2250 void PedroGui::actionEnable(const DOMString &name, bool val)
2252     DOMString path = "/ui/MenuBar/";
2253     path.append(name);
2254     Glib::RefPtr<Gtk::Action> action = uiManager->get_action(path);
2255     if (!action)
2256         {
2257         path = "/ui/MenuBar/MenuFile/";
2258         path.append(name);
2259         action = uiManager->get_action(path);
2260         }
2261     if (!action)
2262         {
2263         path = "/ui/MenuBar/MenuEdit/";
2264         path.append(name);
2265         action = uiManager->get_action(path);
2266         }
2267     if (!action)
2268         {
2269         path = "/ui/MenuBar/MenuRegister/";
2270         path.append(name);
2271         action = uiManager->get_action(path);
2272         }
2273     if (!action)
2274         {
2275         path = "/ui/MenuBar/MenuTransfer/";
2276         path.append(name);
2277         action = uiManager->get_action(path);
2278         }
2279     if (!action)
2280         {
2281         path = "/ui/MenuBar/MenuHelp/";
2282         path.append(name);
2283         action = uiManager->get_action(path);
2284         }
2285     if (!action)
2286         return;
2287     action->set_sensitive(val);
2293 bool PedroGui::doSetup()
2295     set_title("Pedro XMPP Client");
2296     set_size_request(500, 300);
2297     add(mainBox);
2299     Glib::RefPtr<Gtk::ActionGroup> actionGroup = Gtk::ActionGroup::create();
2301     //### FILE MENU
2302     actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
2304     actionGroup->add( Gtk::Action::create("Connect",
2305                                   Gtk::Stock::CONNECT, "Connect"),
2306     sigc::mem_fun(*this, &PedroGui::connectCallback) );
2308     actionGroup->add( Gtk::Action::create("Chat",
2309                                   Gtk::Stock::CONNECT, "Chat"),
2310     sigc::mem_fun(*this, &PedroGui::chatCallback) );
2312     actionGroup->add( Gtk::Action::create("GroupChat",
2313                                   Gtk::Stock::CONNECT, "Group Chat"),
2314     sigc::mem_fun(*this, &PedroGui::groupChatCallback) );
2316     actionGroup->add( Gtk::Action::create("Disconnect",
2317                                   Gtk::Stock::DISCONNECT, "Disconnect"),
2318     sigc::mem_fun(*this, &PedroGui::disconnectCallback) );
2320     actionGroup->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
2321     sigc::mem_fun(*this, &PedroGui::quitCallback) );
2323     //### EDIT MENU
2324     actionGroup->add( Gtk::Action::create("MenuEdit", "_Edit") );
2325     actionGroup->add( Gtk::Action::create("SelectFont",
2326                                   Gtk::Stock::SELECT_FONT, "Select Font"),
2327     sigc::mem_fun(*this, &PedroGui::fontCallback) );
2328     actionGroup->add( Gtk::Action::create("SelectColor",
2329                                   Gtk::Stock::SELECT_COLOR, "Select Color"),
2330     sigc::mem_fun(*this, &PedroGui::colorCallback) );
2332     //### REGISTER MENU
2333     actionGroup->add( Gtk::Action::create("MenuRegister", "_Registration") );
2334     actionGroup->add( Gtk::Action::create("RegPass",
2335                                   Gtk::Stock::DIALOG_AUTHENTICATION, "Change Password"),
2336     sigc::mem_fun(*this, &PedroGui::regPassCallback) );
2337     actionGroup->add( Gtk::Action::create("RegCancel",
2338                                   Gtk::Stock::CANCEL, "Cancel Registration"),
2339     sigc::mem_fun(*this, &PedroGui::regCancelCallback) );
2341     //### TRANSFER MENU
2342     actionGroup->add( Gtk::Action::create("MenuTransfer", "_Transfer") );
2343     actionGroup->add( Gtk::Action::create("SendFile",
2344                                   Gtk::Stock::NETWORK, "Send File"),
2345     sigc::mem_fun(*this, &PedroGui::sendFileCallback) );
2347     //### HELP MENU
2348     actionGroup->add( Gtk::Action::create("MenuHelp", "_Help") );
2349     actionGroup->add( Gtk::Action::create("About",
2350                                   Gtk::Stock::ABOUT, "About Pedro"),
2351     sigc::mem_fun(*this, &PedroGui::aboutCallback) );
2353     uiManager = Gtk::UIManager::create();
2355     uiManager->insert_action_group(actionGroup, 0);
2356     add_accel_group(uiManager->get_accel_group());
2358     Glib::ustring ui_info =
2359         "<ui>"
2360         "  <menubar name='MenuBar'>"
2361         "    <menu action='MenuFile'>"
2362         "      <menuitem action='Connect'/>"
2363         "      <separator/>"
2364         "      <menuitem action='Chat'/>"
2365         "      <menuitem action='GroupChat'/>"
2366         "      <separator/>"
2367         "      <menuitem action='Disconnect'/>"
2368         "      <menuitem action='Quit'/>"
2369         "    </menu>"
2370         "    <menu action='MenuEdit'>"
2371         "      <menuitem action='SelectFont'/>"
2372         "      <menuitem action='SelectColor'/>"
2373         "    </menu>"
2374         "    <menu action='MenuRegister'>"
2375         "      <menuitem action='RegPass'/>"
2376         "      <menuitem action='RegCancel'/>"
2377         "    </menu>"
2378         "    <menu action='MenuTransfer'>"
2379         "      <menuitem action='SendFile'/>"
2380         "    </menu>"
2381         "    <menu action='MenuHelp'>"
2382         "      <menuitem action='About'/>"
2383         "    </menu>"
2384         "  </menubar>"
2385         "</ui>";
2387     uiManager->add_ui_from_string(ui_info);
2388     Gtk::Widget* pMenuBar = uiManager->get_widget("/MenuBar");
2389     menuBarBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);
2391     padlockDisable();
2392     menuBarBox.pack_end(padlockIcon, Gtk::PACK_SHRINK);
2394     mainBox.pack_start(menuBarBox, Gtk::PACK_SHRINK);
2396     actionEnable("Connect",    true);
2397     actionEnable("Chat",       false);
2398     actionEnable("GroupChat",  false);
2399     actionEnable("Disconnect", false);
2400     actionEnable("RegPass",    false);
2401     actionEnable("RegCancel",  false);
2403     mainBox.pack_start(vPaned);
2404     vPaned.add1(roster);
2405     vPaned.add2(messageList);
2406     roster.setParent(this);
2408     show_all_children();
2410     //# Start a timer to check the queue every nn milliseconds
2411     Glib::signal_timeout().connect(
2412            sigc::mem_fun(*this, &PedroGui::checkEventQueue), 20 );
2414     config.readFile("pedro.ini");
2416     //client.addXmppEventListener(*this);
2417     client.eventQueueEnable(true);
2419     return true;
2423 } // namespace Pedro
2427 //########################################################################
2428 //# E N D    O F     F I L E
2429 //########################################################################