|
Freya
0.0.1
A Gtk3 MPD Client
|
00001 /*********************************************************** 00002 * This file is part of Freya 00003 * - A free MPD Gtk3 MPD Client - 00004 * 00005 * Authors: Christopher Pahl, Christoph Piechula, 00006 * Eduard Schneider 00007 * 00008 * Copyright (C) [2011-2012] 00009 * Hosted at: https://github.com/studentkittens/Freya 00010 * 00011 * __..--''``---....___ _..._ __ 00012 * /// //_.-' .-/"; ` ``<._ ``.''_ `. / // / 00013 * ///_.-' _..--.'_ `( ) ) // // 00014 * / (_..-' // (< _ ;_..__ ; `' / /// 00015 * / // // // `-._,_)' // / ``--...____..-' /// / // 00016 * Ascii-Art by Felix Lee <flee@cse.psu.edu> 00017 * 00018 * Freya is free software: you can redistribute it and/or modify 00019 * it under the terms of the GNU General Public License as published by 00020 * the Free Software Foundation, either version 3 of the License, or 00021 * (at your option) any later version. 00022 * 00023 * Freya is distributed in the hope that it will be useful, 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 * GNU General Public License for more details. 00027 * 00028 * You should have received a copy of the GNU General Public License 00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>. 00030 **************************************************************/ 00031 #ifndef FREYA_AVAHI_BROWSER_HH 00032 #define FREYA_AVAHI_BROWSER_HH 00033 00034 #include "View.hh" 00035 00036 /* Avahi stuff */ 00037 #include <avahi-client/client.h> 00038 #include <avahi-client/lookup.h> 00039 #include <avahi-common/error.h> 00040 #include <avahi-glib/glib-watch.h> 00041 #include <avahi-glib/glib-malloc.h> 00042 00043 namespace Avahi 00044 { 00048 typedef sigc::signal<void,Glib::ustring,Glib::ustring,Glib::ustring, unsigned int> SelectNotify; 00049 00056 class Browser 00057 { 00058 public: 00059 00063 Browser(); 00064 00068 ~Browser(); 00069 00075 Gtk::Window& get_window(); 00076 00082 bool is_connected(); 00083 00091 SelectNotify& signal_selection_done(); 00092 00093 private: 00094 00095 /* CALLBACKS */ 00096 00097 void client_callback(AVAHI_GCC_UNUSED AvahiClient *client, 00098 AvahiClientState state); 00099 00100 static void wrap_client_callback(AVAHI_GCC_UNUSED AvahiClient *client, 00101 AvahiClientState state, 00102 void * self); 00103 00104 /* Argh... Avahi loves huge functions */ 00105 void resolve_callback( 00106 AvahiServiceResolver * resolver, 00107 AVAHI_GCC_UNUSED AvahiIfIndex interface, 00108 AVAHI_GCC_UNUSED AvahiProtocol protocol, 00109 AvahiResolverEvent event, 00110 const char *name, 00111 const char *type, 00112 const char *domain, 00113 const char *host_name, 00114 const AvahiAddress *address, 00115 uint16_t port, 00116 AVAHI_GCC_UNUSED AvahiStringList *txt, 00117 AVAHI_GCC_UNUSED AvahiLookupResultFlags flags); 00118 00119 static void wrap_resolve_callback(AvahiServiceResolver * r, 00120 AvahiIfIndex interface, 00121 AvahiProtocol protocol, 00122 AvahiResolverEvent event, 00123 const char *name, 00124 const char *type, 00125 const char *domain, 00126 const char *host_name, 00127 const AvahiAddress *address, 00128 uint16_t port, 00129 AvahiStringList *txt, 00130 AvahiLookupResultFlags flags, 00131 void * self); 00132 00133 /* Servicebrowser callback.. *sigh* Why am I writing this ton of params..? */ 00134 void service_browser_callback(AvahiServiceBrowser *b, 00135 AvahiIfIndex interface, 00136 AvahiProtocol protocol, 00137 AvahiBrowserEvent event, 00138 const char *name, 00139 const char *type, 00140 const char *domain, 00141 AVAHI_GCC_UNUSED AvahiLookupResultFlags flags); 00142 00143 static void wrap_service_browser_callback(AvahiServiceBrowser *b, 00144 AvahiIfIndex interface, 00145 AvahiProtocol protocol, 00146 AvahiBrowserEvent event, 00147 const char *name, 00148 const char *type, 00149 const char *domain, 00150 AvahiLookupResultFlags flags, 00151 void * userdata); 00152 00153 /* -------------------------------------- */ 00154 00155 void check_client_error(const gchar * prefix_message); 00156 void update_status_label(); 00157 00158 /* -------------------------------------- */ 00159 00160 AvahiClient * client; 00161 AvahiGLibPoll * glib_poll; 00162 View * window; 00163 00164 unsigned server_counter; 00165 }; 00166 } 00167 00168 #endif // FREYA_AVAHI_BROWSER_HH
1.8.0