4
* Simple demo GUI for the Pedro mini-XMPP client.
9
* Copyright (C) 2005 Bob Jamison
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public
13
* License as published by the Free Software Foundation; either
14
* version 2.1 of the License, or (at your option) any later version.
16
* This library is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this library; if not, write to the Free Software
23
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
#include "pedro/pedroxmpp.h"
31
#include "pedro/pedroconfig.h"
39
class GroupChatWindow;
41
//#########################################################################
43
//#########################################################################
44
class Roster : public Gtk::ScrolledWindow
55
* Clear all roster items from the list
60
* Regenerate the roster
62
virtual void refresh();
65
void setParent(PedroGui *val)
70
class CustomTreeView : public Gtk::TreeView
75
virtual ~CustomTreeView()
78
bool on_button_press_event(GdkEventButton* event)
80
Gtk::TreeView::on_button_press_event(event);
82
parent->buttonPressCallback(event);
85
void setParent(Roster *val)
92
void doubleClickCallback(const Gtk::TreeModel::Path &path,
93
Gtk::TreeViewColumn *col);
95
void sendFileCallback();
98
bool buttonPressCallback(GdkEventButton* event);
102
Glib::RefPtr<Gdk::Pixbuf> pixbuf_available;
103
Glib::RefPtr<Gdk::Pixbuf> pixbuf_away;
104
Glib::RefPtr<Gdk::Pixbuf> pixbuf_chat;
105
Glib::RefPtr<Gdk::Pixbuf> pixbuf_dnd;
106
Glib::RefPtr<Gdk::Pixbuf> pixbuf_error;
107
Glib::RefPtr<Gdk::Pixbuf> pixbuf_offline;
108
Glib::RefPtr<Gdk::Pixbuf> pixbuf_xa;
110
class RosterColumns : public Gtk::TreeModel::ColumnRecord
116
add(statusColumn); add(userColumn);
117
add(nameColumn); add(subColumn);
120
Gtk::TreeModelColumn<Glib::ustring> groupColumn;
121
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > statusColumn;
122
Gtk::TreeModelColumn<Glib::ustring> userColumn;
123
Gtk::TreeModelColumn<Glib::ustring> nameColumn;
124
Gtk::TreeModelColumn<Glib::ustring> subColumn;
127
RosterColumns rosterColumns;
129
Glib::RefPtr<Gtk::UIManager> uiManager;
131
Glib::RefPtr<Gtk::TreeStore> treeStore;
132
CustomTreeView rosterView;
137
//#########################################################################
138
//# M E S S A G E L I S T
139
//#########################################################################
140
class MessageList : public Gtk::ScrolledWindow
147
virtual ~MessageList()
151
* Clear all messages from the list
153
virtual void clear();
156
* Post a message to the list
158
virtual void postMessage(const DOMString &from, const DOMString &msg);
164
Gtk::TextView messageList;
165
Glib::RefPtr<Gtk::TextBuffer> messageListBuffer;
169
//#########################################################################
171
//#########################################################################
172
class UserList : public Gtk::ScrolledWindow
183
* Clear all messages from the list
185
virtual void clear();
188
* Post a message to the list
190
virtual void addUser(const DOMString &user, const DOMString &show);
193
void setParent(GroupChatWindow *val)
198
class CustomTreeView : public Gtk::TreeView
203
virtual ~CustomTreeView()
206
bool on_button_press_event(GdkEventButton* event)
208
Gtk::TreeView::on_button_press_event(event);
210
parent->buttonPressCallback(event);
213
void setParent(UserList *val)
220
void doubleClickCallback(const Gtk::TreeModel::Path &path,
221
Gtk::TreeViewColumn *col);
223
void sendFileCallback();
225
void shareCallback();
226
bool buttonPressCallback(GdkEventButton* event);
230
Glib::RefPtr<Gdk::Pixbuf> pixbuf_available;
231
Glib::RefPtr<Gdk::Pixbuf> pixbuf_away;
232
Glib::RefPtr<Gdk::Pixbuf> pixbuf_chat;
233
Glib::RefPtr<Gdk::Pixbuf> pixbuf_dnd;
234
Glib::RefPtr<Gdk::Pixbuf> pixbuf_error;
235
Glib::RefPtr<Gdk::Pixbuf> pixbuf_offline;
236
Glib::RefPtr<Gdk::Pixbuf> pixbuf_xa;
238
class UserListColumns : public Gtk::TreeModel::ColumnRecord
242
{ add(statusColumn); add(userColumn); }
244
Gtk::TreeModelColumn<Glib::ustring> userColumn;
245
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > statusColumn;
248
UserListColumns userListColumns;
250
Glib::RefPtr<Gtk::UIManager> uiManager;
252
Glib::RefPtr<Gtk::ListStore> userListStore;
253
CustomTreeView userList;
255
GroupChatWindow *parent;
259
//#########################################################################
260
//# C H A T W I N D O W
261
//#########################################################################
262
class ChatWindow : public Gtk::Window
266
ChatWindow(PedroGui &par, const DOMString jid);
268
virtual ~ChatWindow();
270
virtual DOMString getJid()
273
virtual void setJid(const DOMString &val)
276
virtual bool postMessage(const DOMString &data);
282
void leaveCallback();
284
void shareCallback();
285
void textEnterCallback();
292
MessageList messageList;
300
//#########################################################################
301
//# G R O U P C H A T W I N D O W
302
//#########################################################################
303
class GroupChatWindow : public Gtk::Window
307
GroupChatWindow(PedroGui &par, const DOMString &groupJid,
308
const DOMString &nick);
310
virtual ~GroupChatWindow();
313
virtual DOMString getGroupJid()
316
virtual void setGroupJid(const DOMString &val)
319
virtual DOMString getNick()
322
virtual void setNick(const DOMString &val)
325
virtual bool receiveMessage(const DOMString &from,
326
const DOMString &data);
328
virtual bool receivePresence(const DOMString &nick,
330
const DOMString &show,
331
const DOMString &status);
333
virtual void doSendFile(const DOMString &nick);
335
virtual void doChat(const DOMString &nick);
336
virtual void doShare(const DOMString &nick);
341
void textEnterCallback();
342
void leaveCallback();
344
void shareCallback();
352
MessageList messageList;
366
//#########################################################################
367
//# C O N F I G D I A L O G
368
//#########################################################################
370
class ConfigDialog : public Gtk::Dialog
374
ConfigDialog (PedroGui &par) : parent(par)
377
virtual ~ConfigDialog ()
381
{ return passField.get_text(); }
382
DOMString getNewPass()
383
{ return newField.get_text(); }
384
DOMString getConfirm()
385
{ return confField.get_text(); }
389
//Overloaded from Gtk::Dialog
390
virtual void on_response(int response_id);
395
void cancelCallback();
401
Gtk::Label passLabel;
402
Gtk::Entry passField;
405
Gtk::Label confLabel;
406
Gtk::Entry confField;
412
//#########################################################################
413
//# P A S S W O R D D I A L O G
414
//#########################################################################
415
class PasswordDialog : public Gtk::Dialog
419
PasswordDialog (PedroGui &par) : parent(par)
422
virtual ~PasswordDialog ()
426
{ return passField.get_text(); }
427
DOMString getNewPass()
428
{ return newField.get_text(); }
429
DOMString getConfirm()
430
{ return confField.get_text(); }
434
//Overloaded from Gtk::Dialog
435
virtual void on_response(int response_id);
440
void cancelCallback();
446
Gtk::Label passLabel;
447
Gtk::Entry passField;
450
Gtk::Label confLabel;
451
Gtk::Entry confField;
458
//#########################################################################
459
//# C H A T D I A L O G
460
//#########################################################################
461
class ChatDialog : public Gtk::Dialog
465
ChatDialog(PedroGui &par) : parent(par)
468
virtual ~ChatDialog()
472
{ return userField.get_text(); }
475
{ return textField.get_text(); }
480
void cancelCallback();
486
Gtk::Label userLabel;
487
Gtk::Entry userField;
488
Gtk::Entry textField;
495
//#########################################################################
496
//# G R O U P C H A T D I A L O G
497
//#########################################################################
499
class GroupChatDialog : public Gtk::Dialog
503
GroupChatDialog(PedroGui &par) : parent(par)
506
virtual ~GroupChatDialog()
510
{ return groupField.get_text(); }
512
{ return hostField.get_text(); }
514
{ return passField.get_text(); }
516
{ return nickField.get_text(); }
521
void cancelCallback();
527
Gtk::Label groupLabel;
528
Gtk::Entry groupField;
529
Gtk::Label hostLabel;
530
Gtk::Entry hostField;
531
Gtk::Label passLabel;
532
Gtk::Entry passField;
533
Gtk::Label nickLabel;
534
Gtk::Entry nickField;
540
//#########################################################################
541
//# C O N N E C T D I A L O G
542
//#########################################################################
543
class ConnectDialog : public Gtk::Dialog
547
ConnectDialog (PedroGui &par) : parent(par)
550
virtual ~ConnectDialog ()
554
{ return hostField.get_text(); }
555
void setHost(const DOMString &val)
556
{ hostField.set_text(val); }
558
{ return (int)portSpinner.get_value(); }
559
void setPort(int val)
560
{ portSpinner.set_value(val); }
562
{ return userField.get_text(); }
563
void setUser(const DOMString &val)
564
{ userField.set_text(val); }
566
{ return passField.get_text(); }
567
void setPass(const DOMString &val)
568
{ passField.set_text(val); }
569
DOMString getResource()
570
{ return resourceField.get_text(); }
571
void setResource(const DOMString &val)
572
{ resourceField.set_text(val); }
574
{ return registerButton.get_active(); }
577
* Regenerate the account list
579
virtual void refresh();
585
void cancelCallback();
586
void doubleClickCallback(
587
const Gtk::TreeModel::Path &path,
588
Gtk::TreeViewColumn *col);
589
void selectedCallback();
595
Gtk::Label hostLabel;
596
Gtk::Entry hostField;
597
Gtk::Label portLabel;
598
Gtk::SpinButton portSpinner;
599
Gtk::Label userLabel;
600
Gtk::Entry userField;
601
Gtk::Label passLabel;
602
Gtk::Entry passField;
603
Gtk::Label resourceLabel;
604
Gtk::Entry resourceField;
605
Gtk::Label registerLabel;
606
Gtk::CheckButton registerButton;
608
Glib::RefPtr<Gtk::UIManager> uiManager;
613
void buttonPressCallback(GdkEventButton* event);
615
Gtk::ScrolledWindow accountScroll;
617
void connectCallback();
619
void modifyCallback();
621
void deleteCallback();
624
class AccountColumns : public Gtk::TreeModel::ColumnRecord
633
Gtk::TreeModelColumn<Glib::ustring> nameColumn;
634
Gtk::TreeModelColumn<Glib::ustring> hostColumn;
637
AccountColumns accountColumns;
639
Glib::RefPtr<Gtk::UIManager> accountUiManager;
641
Glib::RefPtr<Gtk::ListStore> accountListStore;
642
Gtk::TreeView accountView;
651
//#########################################################################
652
//# F I L E S E N D D I A L O G
653
//#########################################################################
655
class FileSendDialog : public Gtk::Dialog
659
FileSendDialog(PedroGui &par) : parent(par)
662
virtual ~FileSendDialog()
665
DOMString getFileName()
668
{ return jidField.get_text(); }
669
void setJid(const DOMString &val)
670
{ return jidField.set_text(val); }
675
void cancelCallback();
676
void buttonCallback();
686
Gtk::Entry fileNameField;
688
Gtk::Button selectFileButton;
693
//#########################################################################
694
//# F I L E R E C E I V E D I A L O G
695
//#########################################################################
697
class FileReceiveDialog : public Gtk::Dialog
701
FileReceiveDialog(PedroGui &par,
702
const DOMString &jidArg,
703
const DOMString &iqIdArg,
704
const DOMString &streamIdArg,
705
const DOMString &offeredNameArg,
706
const DOMString &descArg,
708
const DOMString &hashArg
713
streamId = streamIdArg;
714
offeredName = offeredNameArg;
721
virtual ~FileReceiveDialog()
728
DOMString getStreamId()
730
DOMString getOfferedName()
731
{ return offeredName; }
732
DOMString getFileName()
734
DOMString getDescription()
744
void cancelCallback();
745
void buttonCallback();
753
Gtk::Label offeredLabel;
754
Gtk::Entry offeredField;
755
Gtk::Label descLabel;
756
Gtk::Entry descField;
757
Gtk::Label sizeLabel;
758
Gtk::Entry sizeField;
759
Gtk::Label hashLabel;
760
Gtk::Entry hashField;
762
Gtk::Entry fileNameField;
764
Gtk::Button selectFileButton;
769
DOMString offeredName;
781
//#########################################################################
782
//# M A I N W I N D O W
783
//#########################################################################
785
class PedroGui : public Gtk::Window
793
//Let everyone share these
798
virtual void error(const char *fmt, ...) G_GNUC_PRINTF(2,3);
800
virtual void status(const char *fmt, ...) G_GNUC_PRINTF(2,3);
804
void handleConnectEvent();
806
void handleDisconnectEvent();
811
virtual void doEvent(const XmppEvent &event);
816
bool checkEventQueue();
819
bool chatCreate(const DOMString &userJid);
820
bool chatDelete(const DOMString &userJid);
821
bool chatDeleteAll();
822
bool chatMessage(const DOMString &jid, const DOMString &data);
824
bool groupChatCreate(const DOMString &groupJid,
825
const DOMString &nick);
826
bool groupChatDelete(const DOMString &groupJid,
827
const DOMString &nick);
828
bool groupChatDeleteAll();
829
bool groupChatMessage(const DOMString &groupJid,
830
const DOMString &from, const DOMString &data);
831
bool groupChatPresence(const DOMString &groupJid,
832
const DOMString &nick,
834
const DOMString &show,
835
const DOMString &status);
837
void doChat(const DOMString &jid);
838
void doSendFile(const DOMString &jid);
839
void doReceiveFile(const DOMString &jid,
840
const DOMString &iqId,
841
const DOMString &streamId,
842
const DOMString &offeredName,
843
const DOMString &desc,
845
const DOMString &hash);
847
void doShare(const DOMString &jid);
848
void doGroupShare(const DOMString &groupJid);
851
void connectCallback();
853
void groupChatCallback();
854
void disconnectCallback();
859
void colorCallback();
862
void sendFileCallback();
864
//# Registration menu
865
void regPassCallback();
866
void regCancelCallback();
869
void aboutCallback();
871
//# Configuration file
882
Gtk::HBox menuBarBox;
884
Gtk::Image padlockIcon;
885
void padlockEnable();
886
void padlockDisable();
889
Pango::FontDescription fontDesc;
890
Gdk::Color foregroundColor;
891
Gdk::Color backgroundColor;
894
MessageList messageList;
897
Glib::RefPtr<Gtk::UIManager> uiManager;
898
void actionEnable(const DOMString &name, bool val);
900
std::vector<ChatWindow *>chats;
902
std::vector<GroupChatWindow *>groupChats;
908
#endif /* __PEDROGUI_H__ */
909
//#########################################################################
910
//# E N D O F F I L E
911
//#########################################################################