libgnomevfsmm  2.26.0
dns-sd.h
Go to the documentation of this file.
1 /* Copyright 2003 gnome-vfsmm Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free
15  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  */
17 
18 #ifndef _LIBGNOMEVFSMM_DNS_SD_H
19 #define _LIBGNOMEVFSMM_DNS_SD_H
20 
21 //#include <libgnomevfsmm/async-handle.h>
22 #include <libgnomevfsmm/enums.h> //For Result
23 #include <glibmm.h>
24 #include <libgnomevfs/gnome-vfs-dns-sd.h>
25 
26 
27 
28 namespace Gnome
29 {
30 
31 namespace Vfs
32 {
33 
34 //Forward declaration
35 class exception;
36 
37 namespace DnsSd
38 {
39 
40 //TODO: Hide the C structs?
41 typedef struct GnomeVFSDNSSDBrowseHandle BrowseHandle;
42 typedef struct GnomeVFSDNSSDResolveHandle ResolveHandle;
43 
44 
45 class Service
46 {
47 public:
48  Glib::ustring name;
49  Glib::ustring type;
50  Glib::ustring domain;
51 };
52 
56 typedef sigc::slot<void, BrowseHandle*, GnomeVFSDNSSDServiceStatus, const Service&> BrowseSlot;
57 
58 //The return value should only be used to call stop_browse().
59 #ifdef GLIBMM_EXCEPTIONS_ENABLED
60 BrowseHandle* browse(const Glib::ustring& domain, const Glib::ustring& type, const BrowseSlot& slot);
61 #else
62 BrowseHandle* browse(const Glib::ustring& domain, const Glib::ustring& type, const BrowseSlot& slot, std::auto_ptr<Gnome::Vfs::exception>& error);
63 #endif //GLIBMM_EXCEPTIONS_ENABLED
64 
65 #ifdef GLIBMM_EXCEPTIONS_ENABLED
66 void stop_browse(BrowseHandle* handle);
67 #else
68 void stop_browse(BrowseHandle* handle, std::auto_ptr<Gnome::Vfs::exception>& error);
69 #endif //GLIBMM_EXCEPTIONS_ENABLED
70 
71 typedef std::map<Glib::ustring, Glib::ustring> ServiceOptions;
72 
77 typedef sigc::slot<void, ResolveHandle*, Result, const Service&, const Glib::ustring&, int,
79 
80 //The return value should only be used to call cancel_resolve().
81 #ifdef GLIBMM_EXCEPTIONS_ENABLED
82 ResolveHandle* resolve(const Glib::ustring& name, const Glib::ustring& type, const Glib::ustring& domain,
83  int timeout, const ResolveSlot& slot);
84 #else
85 ResolveHandle* resolve(const Glib::ustring& name, const Glib::ustring& type, const Glib::ustring& domain,
86  int timeout, const ResolveSlot& slot, std::auto_ptr<Gnome::Vfs::exception>& error);
87 #endif //GLIBMM_EXCEPTIONS_ENABLED
88 
89 #ifdef GLIBMM_EXCEPTIONS_ENABLED
90 void cancel_resolve(ResolveHandle* handle);
91 #else
92 void cancel_resolve(ResolveHandle* handle, std::auto_ptr<Gnome::Vfs::exception>& error);
93 #endif //GLIBMM_EXCEPTIONS_ENABLED
94 
95 
96 typedef Glib::ListHandle<Service> ListHandleServices;
97 
98 //TODO: Use a generic Glib *Handle instead of std::list<Service>?
99 #ifdef GLIBMM_EXCEPTIONS_ENABLED
100 void browse_sync(const Glib::ustring& domain, const Glib::ustring& type, int timeout_msec, std::list<Service>& services);
101 #else
102 void browse_sync(const Glib::ustring& domain, const Glib::ustring& type, int timeout_msec, std::list<Service>& services, std::auto_ptr<Gnome::Vfs::exception>& error);
103 #endif //GLIBMM_EXCEPTIONS_ENABLED
104 
105 
106 #ifdef GLIBMM_EXCEPTIONS_ENABLED
107 void resolve_sync(const Glib::ustring& name, const Glib::ustring& type, const Glib::ustring& domain,
108  int timeout_msec, Glib::ustring& host, int& port, ServiceOptions& options);
109 #else
110 void resolve_sync(const Glib::ustring& name, const Glib::ustring& type, const Glib::ustring& domain,
111  int timeout_msec, Glib::ustring& host, int& port, ServiceOptions& options, std::auto_ptr<Gnome::Vfs::exception>& error);
112 #endif //GLIBMM_EXCEPTIONS_ENABLED
113 
114 typedef Glib::ListHandle<Glib::ustring> ListHandleStrings;
115 
116 #ifdef GLIBMM_EXCEPTIONS_ENABLED
117 ListHandleStrings list_browse_domains_sync(const Glib::ustring& domain, int timeout_msec);
118 #else
119 ListHandleStrings list_browse_domains_sync(const Glib::ustring& domain, int timeout_msec, std::auto_ptr<Gnome::Vfs::exception>& error);
120 #endif //GLIBMM_EXCEPTIONS_ENABLED
121 
123 
124 
125 } // namespace DnsSd
126 
127 } // namespace Vfs
128 
129 } // namespace Gnome
130 
131 #endif