fuse_transfer_widget.h

00001
00002 /***************************************************************************
00003  *  fuse_transfer_widget.h - Fuse transfer widget
00004  *
00005  *  Created: Wed Mar 19 17:11:01 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_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_
00024 #define __FIREVISION_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_
00025 
00026 #include <fvutils/net/fuse_client_handler.h>
00027 #include <core/utils/lock_queue.h>
00028
00029 #include <gtkmm.h>
00030
00031 class FuseClient;
00032 class YuvColormap;
00033 class ColormapViewerWidget;
00034
00035 class FuseTransferWidget : FuseClientHandler
00036 {
00037  public:
00038   FuseTransferWidget();
00039   virtual ~FuseTransferWidget();
00040
00041   void add_fountain_service( const char* name,
00042                              const char* host_name,
00043                              uint16_t port );
00044   void remove_fountain_service(const char* name);
00045
00046   void set_current_colormap(YuvColormap* colormap);
00047
00048   void set_upload_btn(Gtk::Button* btn_upload);
00049   void set_download_btn(Gtk::Button* btn_download);
00050   void set_local_img(Gtk::Image* img_local);
00051   void set_local_layer_selector(Gtk::Scale* scl);
00052   void set_remote_img(Gtk::Image* img_remote);
00053   void set_remote_layer_selector(Gtk::Scale* scl);
00054   void set_local_lut_list_trv(Gtk::TreeView* lut_list);
00055   void set_remote_lut_list_trv(Gtk::TreeView* lut_list);
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 LutRecord : public Gtk::TreeModelColumnRecord
00066     {
00067     public:
00068       LutRecord()
00069         {
00070           add(filename);
00071           add(service_name);
00072           add(host_name);
00073           add(port);
00074           add(lut_id);
00075           add(width);
00076           add(height);
00077           add(depth);
00078           add(bytes_per_cell);
00079           add(type);
00080         }
00081
00082       typedef enum
00083       {
00084         LUT_COLORMAP,
00085         LUT_MIRROR
00086       } LutType;
00087
00088       Gtk::TreeModelColumn<Glib::ustring> filename;
00089       Gtk::TreeModelColumn<Glib::ustring> service_name;
00090       Gtk::TreeModelColumn<Glib::ustring> host_name;
00091       Gtk::TreeModelColumn<unsigned int> port;
00092       Gtk::TreeModelColumn<Glib::ustring> lut_id;
00093       Gtk::TreeModelColumn<unsigned int> width;
00094       Gtk::TreeModelColumn<unsigned int> height;
00095       Gtk::TreeModelColumn<unsigned int> depth;
00096       Gtk::TreeModelColumn<unsigned int> bytes_per_cell;
00097       Gtk::TreeModelColumn<LutRecord::LutType> type;
00098     };
00099
00100   // signal handler
00101   void update_local_lut_list();
00102   void update_remote_lut_list();
00103   void get_lut_list();
00104   void delete_clients();
00105   void update_local_lut();
00106   void update_remote_lut();
00107   void upload_lut();
00108
00109   void local_lut_selected();
00110   void remote_lut_selected();
00111
00112   struct ClientData
00113   {
00114     FuseClient* client;
00115     std::string service_name;
00116     std::string host_name;
00117     uint16_t port;
00118     bool active;
00119   };
00120
00121   fawkes::LockQueue<ClientData> m_new_clients;
00122   fawkes::LockQueue<FuseClient*> m_delete_clients;
00123
00124   ClientData m_cur_client;
00125
00126   Glib::Dispatcher m_signal_update_local_lut_list;
00127   Glib::Dispatcher m_signal_update_remote_lut_list;
00128   Glib::Dispatcher m_signal_get_lut_list;
00129   Glib::Dispatcher m_signal_delete_client;
00130   Glib::Dispatcher m_signal_update_remote_lut;
00131
00132   ColormapViewerWidget* m_local_colormap_viewer;
00133   ColormapViewerWidget* m_remote_colormap_viewer;
00134
00135   Gtk::Button* m_btn_upload;
00136   Gtk::Button* m_btn_download;
00137   Gtk::Image* m_img_local;
00138   Gtk::Image* m_img_remote;
00139   Gtk::TreeView* m_trv_local_lut_list;
00140   Gtk::TreeView* m_trv_remote_lut_list;
00141
00142   Glib::RefPtr<Gtk::ListStore> m_remote_lut_list;
00143   Glib::RefPtr<Gtk::ListStore> m_local_lut_list;
00144   LutRecord m_lut_record;
00145
00146   YuvColormap* m_current_colormap;
00147   YuvColormap* m_local_colormap;
00148   YuvColormap* m_remote_colormap;
00149 };
00150
00151 #endif /* __FIREVISION_TOOLS_FIRESTATION_FUSE_TRANSFER_WIDGET_H_ */