Fawkes API  Fawkes Development Version
service_chooser_dialog.h
1 
2 /***************************************************************************
3  * service_chooser_dialog.cpp - Dialog for choosing a network service
4  *
5  * Created: Sun Oct 12 17:06:06 2008 (split from lasergui_hildon.cpp)
6  * Copyright 2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program 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
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __LIBS_GUI_UTILS_SERVICE_CHOOSER_DIALOG_H_
25 #define __LIBS_GUI_UTILS_SERVICE_CHOOSER_DIALOG_H_
26 
27 #include <gui_utils/service_model.h>
28 
29 #include <gtkmm/dialog.h>
30 #include <gtkmm/treeview.h>
31 #include <gtkmm/entry.h>
32 #include <gtkmm/expander.h>
33 #include <gtkmm/scrolledwindow.h>
34 #ifdef HAVE_GCONFMM
35 # include <gconfmm.h>
36 #endif
37 
38 #include <sys/types.h>
39 #include <sys/socket.h>
40 
41 namespace fawkes {
42 
43 class FawkesNetworkClient;
44 class ServiceModel;
45 
47  : public Gtk::Dialog
48 {
49  public:
50  ServiceChooserDialog(Gtk::Window &parent,
51  FawkesNetworkClient *client,
52  Glib::ustring title = "Select Service",
53  const char *service = "_fawkes._tcp");
54 
55  ServiceChooserDialog(Gtk::Window &parent,
56  Glib::ustring title = "Select Service",
57  const char *service = "_fawkes._tcp");
58 
59  virtual ~ServiceChooserDialog();
60 
61  void get_selected_service(Glib::ustring &name, Glib::ustring &hostname,
62  unsigned short int &port);
63  void get_selected_service(Glib::ustring &hostname, struct sockaddr_storage &sockaddr);
64 
65  void get_raw_address(struct sockaddr *addr, socklen_t addr_size);
66 
67  void run_and_connect();
68 
69  protected:
70  virtual void on_expander_changed();
71 
72  private:
73  void ctor();
75 
76  Gtk::Window &__parent;
77  Gtk::TreeView __treeview;
78  Gtk::Entry __entry;
79  Gtk::Expander __expander;
80  Gtk::ScrolledWindow __scrollwin;
81 #ifdef HAVE_GCONFMM
82  Glib::RefPtr<Gnome::Conf::Client> __gconf;
83 #endif
84 
85  ServiceModel *__service_model;
86 };
87 
88 } // end of namespace fawkes
89 
90 #endif
Abstract base class for widgets that allow to view the detected services of a certain type...
Definition: service_model.h:34
virtual void on_expander_changed()
Signal handler for expander event.
Simple Fawkes network client.
Definition: client.h:52
Fawkes library namespace.
ServiceChooserDialog(Gtk::Window &parent, FawkesNetworkClient *client, Glib::ustring title="Select Service", const char *service="_fawkes._tcp")
Constructor.
void run_and_connect()
Run dialog and try to connect.
void get_raw_address(struct sockaddr *addr, socklen_t addr_size)
Get raw address.
virtual ~ServiceChooserDialog()
Destructor.
void get_selected_service(Glib::ustring &name, Glib::ustring &hostname, unsigned short int &port)
Get selected service.