fuse_image_list_widget.h

00001
00002 /***************************************************************************
00003  *  fuse_image_list_widget.h - Fuse image list widget
00004  *
00005  *  Created: Mon Mar 24 21:01:16 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022
00023 #ifndef __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_
00024 #define __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_
00025 
00026 #include <fvutils/net/fuse_client_handler.h>
00027 #include <fvutils/net/fuse_client.h>
00028
00029 #include <core/utils/lock_queue.h>
00030 #include <core/utils/lock_list.h>
00031 #include <core/threading/mutex.h>
00032
00033 #include <gtkmm.h>
00034
00035 class FuseImageListWidget : FuseClientHandler, public Gtk::TreeView
00036 {
00037  public:
00038   FuseImageListWidget();
00039   virtual ~FuseImageListWidget();
00040
00041   void add_fountain_service( const char* name,
00042                              const char* host_name,
00043                              uint32_t port );
00044   void remove_fountain_service(const char* name);
00045
00046   void set_toggle_compression_chk(Gtk::CheckButton* chk);
00047   void set_auto_update_chk(Gtk::CheckButton* chk);
00048   void set_image_list_trv(Gtk::TreeView* trv);
00049   Glib::Dispatcher& image_selected();
00050
00051   bool auto_update();
00052   void set_auto_update(bool active, unsigned int interval_sec = 5);
00053
00054   bool get_selected_image( std::string& host_name, unsigned short& port,
00055                            std::string& image_id, bool& compression );
00056
00057   // Fuse client handler
00058   void fuse_invalid_server_version( uint32_t local_version,
00059                                     uint32_t remote_version ) throw();
00060   void fuse_connection_established() throw();
00061   void fuse_connection_died() throw();
00062   void fuse_inbound_received(FuseNetworkMessage *m) throw();
00063
00064  private:
00065   class ImageRecord : public Gtk::TreeModelColumnRecord
00066     {
00067     public:
00068       ImageRecord()
00069         {
00070           add(display_text);
00071           add(service_name);
00072           add(host_name);
00073           add(port);
00074           add(colorspace);
00075           add(image_id);
00076           add(width);
00077           add(height);
00078           add(buffer_size);
00079         }
00080
00081       Gtk::TreeModelColumn<Glib::ustring> display_text;
00082       Gtk::TreeModelColumn<Glib::ustring> service_name;
00083       Gtk::TreeModelColumn<Glib::ustring> host_name;
00084       Gtk::TreeModelColumn<unsigned int> port;
00085       Gtk::TreeModelColumn<Glib::ustring> image_id;
00086       Gtk::TreeModelColumn<unsigned int> colorspace;
00087       Gtk::TreeModelColumn<unsigned int> width;
00088       Gtk::TreeModelColumn<unsigned int> height;
00089       Gtk::TreeModelColumn<unsigned int> buffer_size;
00090     };
00091
00092   struct ClientData
00093   {
00094     FuseClient* client;
00095     std::string service_name;
00096     std::string host_name;
00097     uint16_t port;
00098     bool active;
00099   };
00100
00101   bool on_image_event(GdkEvent *event);
00102   void on_add_host_manually();
00103   void on_image_selected();
00104   void on_auto_update_toggled();
00105   void on_compression_toggled();
00106   void get_image_list();
00107   void delete_clients();
00108   void update_image_list();
00109   bool on_update_timeout();
00110
00111   fawkes::LockList<ClientData> m_new_clients;
00112   fawkes::LockQueue<FuseClient*> m_delete_clients;
00113
00114   ClientData m_cur_client;
00115
00116   Gtk::Menu* m_popup_menu;
00117   Gtk::CheckButton* m_chk_auto_update;
00118   Gtk::CheckButton* m_chk_compression;
00119   Gtk::TreeView* m_trv_image_list;
00120   Glib::RefPtr<Gtk::TreeStore> m_image_list;
00121   fawkes::Mutex m_img_list_mutex;
00122
00123   ImageRecord m_image_record;
00124
00125   Glib::Dispatcher m_signal_get_image_list;
00126   Glib::Dispatcher m_signal_delete_clients;
00127   Glib::Dispatcher m_signal_image_selected;
00128   Glib::Dispatcher m_signal_update_image_l;
00129
00130   bool             m_auto_update;
00131   unsigned int     m_interval_sec;
00132   sigc::connection m_timeout_conn;
00133
00134   Glib::ustring m_cur_image_id;
00135 };
00136
00137 #endif /* __FIREVISION_FVWIDGETS_FUSE_IMAGE_LIST_WIDGET_H_ */