summaryrefslogtreecommitdiffstats
path: root/avahi-sharp
diff options
context:
space:
mode:
authorJames Willcox <snopr@snorp.net>2005-09-09 20:48:41 +0000
committerJames Willcox <snopr@snorp.net>2005-09-09 20:48:41 +0000
commit223014183d626cd4cf6fb2cb7b17319375688138 (patch)
treea7c02650b51fec8eafceb3397741ff03d46d1f46 /avahi-sharp
parent8a3450396a4d60565b34cbce73aa03eb61389bb0 (diff)
add some data access api to string list, and use it in ServiceResolver
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@550 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-sharp')
-rw-r--r--avahi-sharp/AvahiTest.cs4
-rw-r--r--avahi-sharp/ServiceResolver.cs22
2 files changed, 25 insertions, 1 deletions
diff --git a/avahi-sharp/AvahiTest.cs b/avahi-sharp/AvahiTest.cs
index 1679ee2..7be4b06 100644
--- a/avahi-sharp/AvahiTest.cs
+++ b/avahi-sharp/AvahiTest.cs
@@ -20,6 +20,7 @@
***/
using System;
+using System.Text;
using System.Net;
using Gtk;
using Avahi;
@@ -73,6 +74,9 @@ public class AvahiTest {
private static void OnServiceResolved (object o, ServiceInfo info)
{
Console.WriteLine ("Service '{0}' at {1}:{2}", info.Name, info.Host, info.Port);
+ foreach (byte[] bytes in info.Text) {
+ Console.WriteLine ("Text: " + Encoding.UTF8.GetString (bytes));
+ }
AddressResolver ar = new AddressResolver (client, info.Address);
ar.Found += OnAddressResolved;
}
diff --git a/avahi-sharp/ServiceResolver.cs b/avahi-sharp/ServiceResolver.cs
index 7737994..1b5d51a 100644
--- a/avahi-sharp/ServiceResolver.cs
+++ b/avahi-sharp/ServiceResolver.cs
@@ -54,6 +54,15 @@ namespace Avahi
Protocol aproto, ServiceResolverCallback cb,
IntPtr userdata);
+ [DllImport ("avahi-common")]
+ private static extern IntPtr avahi_string_list_get_next (IntPtr list);
+
+ [DllImport ("avahi-common")]
+ private static extern IntPtr avahi_string_list_get_text (IntPtr list);
+
+ [DllImport ("avahi-common")]
+ private static extern int avahi_string_list_get_size (IntPtr list);
+
[DllImport ("avahi-client")]
private static extern void avahi_service_resolver_free (IntPtr handle);
@@ -161,8 +170,19 @@ namespace Avahi
info.Host = Utility.PtrToString (host);
info.Address = Utility.PtrToAddress (address);
info.Port = port;
- info.Text = null;
+ ArrayList txtlist = new ArrayList ();
+ for (IntPtr l = txt; l != IntPtr.Zero; l = avahi_string_list_get_next (l)) {
+ IntPtr buf = avahi_string_list_get_text (l);
+ int len = avahi_string_list_get_size (l);
+
+ byte[] txtbuf = new byte[len];
+ Marshal.Copy (buf, txtbuf, 0, len);
+ txtlist.Add (txtbuf);
+ }
+
+ info.Text = (byte[][]) txtlist.ToArray (typeof (byte[]));
+
if (revent == ResolverEvent.Found) {
currentInfo = info;