~kklimonda/ubuntu/natty/glibmm2.4/update

« back to all changes in this revision

Viewing changes to gio/src/resolver.ccg

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-07-28 13:50:53 UTC
  • mfrom: (1.2.37 upstream)
  • Revision ID: james.westby@ubuntu.com-20090728135053-qdapv1ixwn5gddn2
Tags: 2.21.3-0ubuntu1
* New upstream version:
  - Only compile the properties example if properties are enabled.
  - fix release target to use correct tagging scheme
  - Bug 587173 - Fails to install when bootstrapped with Automake 1.11
  - add _IGNORE() for a eject_with_operation() which is hand-written
  - add get_start_stop_type() and Gio::DriveStartStopType enum
  - add overloads for resolver methods without a cancellable object
  - add async versions of Resolver methods
  - Added a simple example showing how to resolve an internet address from a hostname
  - Fix MemoryInputStream::addData 
  - Fix a build error in MemoryInputStream
  - Add Glib::ObjectBase::freeze_notify()/thaw_notify.  Fixes Bug #575533
  - Repair Glib::KeyFile docs with regard to exceptions. Bug# 587766.
  - Wrapped several ISO 8601 related functions.
  - Corrected the ChangeLog to mention changes that I accidentally committed 
    in last month, but which I did want to commit some time.
* debian/rules:
  - updated shver number

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 */
19
19
 
20
20
#include <gio/gio.h>
 
21
#include "slot_async.h"
21
22
 
22
23
namespace Gio
23
24
{
32
33
    g_resolver_set_default(Glib::unwrap(resolver));
33
34
}
34
35
 
 
36
#ifdef GLIBMM_EXCEPTIONS_ENABLED
 
37
Glib::ListHandle< Glib::RefPtr<InetAddress> > Resolver::lookup_by_name(const Glib::ustring& hostname)
 
38
#else
 
39
Glib::ListHandle< Glib::RefPtr<InetAddress> > Resolver::lookup_by_name(const Glib::ustring& hostname, std::auto_ptr<Glib::Error>& error)
 
40
#endif //GLIBMM_EXCEPTIONS_ENABLED
 
41
{
 
42
  GError* gerror = 0;
 
43
  Glib::ListHandle< Glib::RefPtr<InetAddress> > retvalue = Glib::ListHandle< Glib::RefPtr<InetAddress> >(g_resolver_lookup_by_name(gobj(), hostname.c_str(), 0, &(gerror)), Glib::OWNERSHIP_SHALLOW);
 
44
#ifdef GLIBMM_EXCEPTIONS_ENABLED
 
45
  if(gerror)
 
46
    ::Glib::Error::throw_exception(gerror);
 
47
#else
 
48
  if(gerror)
 
49
    error = ::Glib::Error::throw_exception(gerror);
 
50
#endif //GLIBMM_EXCEPTIONS_ENABLED
 
51
 
 
52
  return retvalue;
 
53
 
 
54
}
 
55
 
 
56
#ifdef GLIBMM_EXCEPTIONS_ENABLED
 
57
Glib::ustring Resolver::lookup_by_address(const Glib::RefPtr<InetAddress>& address)
 
58
#else
 
59
Glib::ustring Resolver::lookup_by_address(const Glib::RefPtr<InetAddress>& address, std::auto_ptr<Glib::Error>& error)
 
60
#endif //GLIBMM_EXCEPTIONS_ENABLED
 
61
{
 
62
  GError* gerror = 0;
 
63
  Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_resolver_lookup_by_address(gobj(), const_cast<GInetAddress*>(Glib::unwrap(address)), 0, &(gerror)));
 
64
#ifdef GLIBMM_EXCEPTIONS_ENABLED
 
65
  if(gerror)
 
66
    ::Glib::Error::throw_exception(gerror);
 
67
#else
 
68
  if(gerror)
 
69
    error = ::Glib::Error::throw_exception(gerror);
 
70
#endif //GLIBMM_EXCEPTIONS_ENABLED
 
71
 
 
72
  return retvalue;
 
73
 
 
74
}
 
75
 
 
76
#ifdef GLIBMM_EXCEPTIONS_ENABLED
 
77
ListHandle_SrvTarget Resolver::lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain)
 
78
#else
 
79
ListHandle_SrvTarget Resolver::lookup_service(const Glib::ustring& service, const Glib::ustring& protocol, const Glib::ustring& domain, std::auto_ptr<Glib::Error>& error)
 
80
#endif //GLIBMM_EXCEPTIONS_ENABLED
 
81
{
 
82
  GError* gerror = 0;
 
83
  ListHandle_SrvTarget retvalue = ListHandle_SrvTarget(g_resolver_lookup_service(gobj(), service.c_str(), protocol.c_str(), domain.c_str(), 0, &(gerror)), Glib::OWNERSHIP_SHALLOW);
 
84
#ifdef GLIBMM_EXCEPTIONS_ENABLED
 
85
  if(gerror)
 
86
    ::Glib::Error::throw_exception(gerror);
 
87
#else
 
88
  if(gerror)
 
89
    error = ::Glib::Error::throw_exception(gerror);
 
90
#endif //GLIBMM_EXCEPTIONS_ENABLED
 
91
 
 
92
  return retvalue;
 
93
 
 
94
}
 
95
 
 
96
void
 
97
Resolver::lookup_by_name_async(const Glib::ustring& hostname,
 
98
                               const SlotAsyncReady& slot,
 
99
                               const Glib::RefPtr<Cancellable>& cancellable)
 
100
{
 
101
  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
 
102
 
 
103
  g_resolver_lookup_by_name_async (gobj(),
 
104
                                   hostname.c_str(),
 
105
                                   cancellable->gobj(),
 
106
                                   &SignalProxy_async_callback,
 
107
                                   slot_copy);
 
108
}
 
109
 
 
110
void
 
111
Resolver::lookup_by_name_async(const Glib::ustring& hostname,
 
112
                               const SlotAsyncReady& slot)
 
113
{
 
114
  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
 
115
 
 
116
  g_resolver_lookup_by_name_async (gobj(),
 
117
                                   hostname.c_str(),
 
118
                                   0,
 
119
                                   &SignalProxy_async_callback,
 
120
                                   slot_copy);
 
121
}
 
122
 
 
123
void
 
124
Resolver::lookup_by_address_async(const Glib::RefPtr<InetAddress>& address,
 
125
                                  const SlotAsyncReady& slot,
 
126
                                  const Glib::RefPtr<Cancellable>& cancellable)
 
127
{
 
128
  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
 
129
 
 
130
  g_resolver_lookup_by_address_async (gobj(),
 
131
                                      address->gobj(),
 
132
                                      cancellable->gobj(),
 
133
                                      &SignalProxy_async_callback,
 
134
                                      slot_copy);
 
135
}
 
136
 
 
137
void
 
138
Resolver::lookup_by_address_async(const Glib::RefPtr<InetAddress>& address,
 
139
                                  const SlotAsyncReady& slot)
 
140
{
 
141
  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
 
142
 
 
143
  g_resolver_lookup_by_address_async (gobj(),
 
144
                                      address->gobj(),
 
145
                                      0,
 
146
                                      &SignalProxy_async_callback,
 
147
                                      slot_copy);
 
148
}
 
149
 
 
150
void
 
151
Resolver::lookup_service_async(const Glib::ustring& service,
 
152
                               const Glib::ustring& protocol,
 
153
                               const Glib::ustring& domain,
 
154
                               const SlotAsyncReady& slot,
 
155
                               const Glib::RefPtr<Cancellable>& cancellable)
 
156
{
 
157
  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
 
158
 
 
159
  g_resolver_lookup_service_async (gobj(),
 
160
                                   service.c_str(),
 
161
                                   protocol.c_str(),
 
162
                                   domain.c_str(),
 
163
                                   cancellable->gobj(),
 
164
                                   &SignalProxy_async_callback,
 
165
                                   slot_copy);
 
166
}
 
167
 
 
168
void
 
169
Resolver::lookup_service_async(const Glib::ustring& service,
 
170
                               const Glib::ustring& protocol,
 
171
                               const Glib::ustring& domain,
 
172
                               const SlotAsyncReady& slot)
 
173
{
 
174
  SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
 
175
 
 
176
  g_resolver_lookup_service_async (gobj(),
 
177
                                   service.c_str(),
 
178
                                   protocol.c_str(),
 
179
                                   domain.c_str(),
 
180
                                   0,
 
181
                                   &SignalProxy_async_callback,
 
182
                                   slot_copy);
 
183
}
 
184
 
35
185
} //namespace Gio