Author: abock
Date: 2006-04-24 23:45:23 -0400 (Mon, 24 Apr 2006)
New Revision: 59833
Added:
trunk/Mono.Zeroconf/Test/ZeroconfClient.cs
trunk/Mono.Zeroconf/Test/mzclient.in
Removed:
trunk/Mono.Zeroconf/Test/ZeroConfTest.cs
Modified:
trunk/Mono.Zeroconf/ChangeLog
trunk/Mono.Zeroconf/Mono.Zeroconf.mdp
trunk/Mono.Zeroconf/Mono.Zeroconf/Makefile
Log:
2006-04-24 Aaron Bockover <[EMAIL PROTECTED]>
* Test/ZeroConfTest.cs: removed
* Test/ZeroconfClient.cs: Added new replacement client (mzclient) for the
mDNSClient tool that ships with Bonjour on UNIX. mzclient supports
service resolving and publishing, unlinke mDNSClient
* Test/mzclient.in: Added wrapper script for mzclient.exe
* Mono.Zeroconf/Makefile: Build mzclient.exe and added install-client
rule for installing mzclient into /usr (hardcoded for now)
* Mono.Zeroconf.mdp: Updated MonoDevelop project
Modified: trunk/Mono.Zeroconf/ChangeLog
===================================================================
--- trunk/Mono.Zeroconf/ChangeLog 2006-04-25 01:38:44 UTC (rev 59832)
+++ trunk/Mono.Zeroconf/ChangeLog 2006-04-25 03:45:23 UTC (rev 59833)
@@ -1,3 +1,18 @@
+2006-04-24 Aaron Bockover <[EMAIL PROTECTED]>
+
+ * Test/ZeroConfTest.cs: removed
+
+ * Test/ZeroconfClient.cs: Added new replacement client (mzclient) for
the
+ mDNSClient tool that ships with Bonjour on UNIX. mzclient supports
+ service resolving and publishing, unlinke mDNSClient
+
+ * Test/mzclient.in: Added wrapper script for mzclient.exe
+
+ * Mono.Zeroconf/Makefile: Build mzclient.exe and added install-client
+ rule for installing mzclient into /usr (hardcoded for now)
+
+ * Mono.Zeroconf.mdp: Updated MonoDevelop project
+
2006-04-07 James Willcox <[EMAIL PROTECTED]>
* Mono.Zeroconf/ServiceType.cs: the enum should use
Modified: trunk/Mono.Zeroconf/Mono.Zeroconf/Makefile
===================================================================
--- trunk/Mono.Zeroconf/Mono.Zeroconf/Makefile 2006-04-25 01:38:44 UTC (rev
59832)
+++ trunk/Mono.Zeroconf/Mono.Zeroconf/Makefile 2006-04-25 03:45:23 UTC (rev
59833)
@@ -1,18 +1,27 @@
-ASM_SOURCES = *.cs ../Test/ZeroConfTest.cs
+ASM_SOURCES = *.cs
ASM = Mono.Zeroconf.dll
+MZCLIENT_SOURCES=../Test/ZeroconfClient.cs
+MZCLIENT_ASSEMBLY=mzclient.exe
MONO = mono --debug
MCS = mcs -debug
-all: $(ASM)
+all: $(ASM) $(MZCLIENT_ASSEMBLY)
$(ASM): $(ASM_SOURCES)
- $(MCS) -out:$@ -pkg:gtk-sharp-2.0 $(ASM_SOURCES)
+ $(MCS) -out:$@ -target:library $(ASM_SOURCES)
+$(MZCLIENT_ASSEMBLY): $(MZCLIENT_SOURCES)
+ $(MCS) -out:$@ -r:$(ASM) $(MZCLIENT_SOURCES)
+
clean:
- rm -f $(ASM) $(ASM).mdb *.pidb
+ rm -f $(ASM) $(MZCLIENT_ASSEMBLY) *.mdb *.pidb
run:
- $(MONO) $(ASM)
+ $(MONO) $(MZCLIENT_ASSEMBLY)
+install-client:
+ mkdir -p /usr/lib/mzclient; \
+ cp $(ASM) $(MZCLIENT_ASSEMBLY) $(ASM).config *.mdb /usr/lib/mzclient/;
+ cp ../Test/mzclient.in /usr/bin/mzclient;
+ chmod 0755 /usr/bin/mzclient;
-
Modified: trunk/Mono.Zeroconf/Mono.Zeroconf.mdp
===================================================================
--- trunk/Mono.Zeroconf/Mono.Zeroconf.mdp 2006-04-25 01:38:44 UTC (rev
59832)
+++ trunk/Mono.Zeroconf/Mono.Zeroconf.mdp 2006-04-25 03:45:23 UTC (rev
59833)
@@ -32,7 +32,7 @@
<File name="./Mono.Zeroconf/TxtRecordEnumerator.cs" subtype="Code"
buildaction="Compile" />
<File name="./Mono.Zeroconf/TxtRecordItem.cs" subtype="Code"
buildaction="Compile" />
<File name="./Test" subtype="Directory" buildaction="Compile" />
- <File name="./Test/ZeroConfTest.cs" subtype="Code" buildaction="Compile" />
+ <File name="./Test/ZeroconfClient.cs" subtype="Code" buildaction="Compile"
/>
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp,
Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
Deleted: trunk/Mono.Zeroconf/Test/ZeroConfTest.cs
===================================================================
--- trunk/Mono.Zeroconf/Test/ZeroConfTest.cs 2006-04-25 01:38:44 UTC (rev
59832)
+++ trunk/Mono.Zeroconf/Test/ZeroConfTest.cs 2006-04-25 03:45:23 UTC (rev
59833)
@@ -1,96 +0,0 @@
-//
-// ZeroConfTest.cs
-//
-// Authors:
-// Aaron Bockover <[EMAIL PROTECTED]>
-//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using Mono.Zeroconf;
-using Gtk;
-
-public class DnsTest
-{
- public static void Main()
- {
- Application.Init();
-
- // Create a test connection to daemon
- Zeroconf.Initialize();
-
- // Register a sample service
- RegisterService service = new RegisterService("Fruity Music", null,
"_daap._tcp");
- TxtRecord record = new TxtRecord();
- record.Add("A", "Apples");
- record.Add("B", "Bananas");
- record.Add("C", "Carrots");
- service.Port = 8080;
- service.TxtRecord = record;
- service.RegisterAsync();
-
- // Listen for events of some service type
- ServiceBrowser browser = new ServiceBrowser("_daap._tcp");
- browser.ServiceAdded += OnServiceAdded;
- browser.ServiceRemoved += OnServiceRemoved;
- browser.StartAsync();
-
- // Unregister our service in 10 seconds
- GLib.Timeout.Add(10000, delegate {
- service.Dispose();
- return false;
- });
-
- // Stop browsing and quit in 15 seconds
- GLib.Timeout.Add(15000, delegate {
- browser.Dispose();
- Application.Quit();
- return false;
- });
-
- Application.Run();
- }
-
- private static void OnServiceAdded(object o, ServiceBrowseEventArgs args)
- {
- Console.WriteLine("ADDED {0}", args.Service.Name);
- args.Service.Resolved += OnServiceResolved;
- args.Service.Resolve();
- }
-
- private static void OnServiceRemoved(object o, ServiceBrowseEventArgs args)
- {
- Console.WriteLine("REMOVED {0}", args.Service.Name);
- }
-
- private static void OnServiceResolved(object o, EventArgs args)
- {
- BrowseService service = o as BrowseService;
- Console.WriteLine("Resolved: {0} {1} {2} {3}", service.FullName,
service.Port,
- service.HostTarget, service.HostEntry.AddressList[0]);
- Console.WriteLine(service.TxtRecord);
- service.RefreshTxtRecord();
- Console.WriteLine(service.TxtRecord);
- }
-}
-
Added: trunk/Mono.Zeroconf/Test/ZeroconfClient.cs
===================================================================
--- trunk/Mono.Zeroconf/Test/ZeroconfClient.cs 2006-04-25 01:38:44 UTC (rev
59832)
+++ trunk/Mono.Zeroconf/Test/ZeroconfClient.cs 2006-04-25 03:45:23 UTC (rev
59833)
@@ -0,0 +1,225 @@
+//
+// ZeroconfClient.cs
+//
+// Authors:
+// Aaron Bockover <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections;
+using System.Text.RegularExpressions;
+
+using Mono.Zeroconf;
+
+public class DnsTest
+{
+ private static bool resolve_shares = false;
+ private static string app_name = "mzclient";
+
+ public static int Main(string [] args)
+ {
+ string type = "_afpovertcp._tcp";
+ bool show_help = false;
+ ArrayList services = new ArrayList();
+
+ for(int i = 0; i < args.Length; i++) {
+ if(args[i][0] != '-') {
+ continue;
+ }
+
+ switch(args[i]) {
+ case "-t":
+ case "--type":
+ type = args[++i];
+ break;
+ case "-r":
+ case "--resolve":
+ resolve_shares = true;
+ break;
+ case "-p":
+ case "--publish":
+ services.Add(args[++i]);
+ break;
+ case "-h":
+ case "--help":
+ show_help = true;
+ break;
+ }
+ }
+
+ if(show_help) {
+ Console.WriteLine("Usage: {0} [-t type] [--resolve] [--publish
\"description\"]", app_name);
+ Console.WriteLine(" -h|--help shows this help");
+ Console.WriteLine(" -t|--type uses 'type' as the service
type");
+ Console.WriteLine(" (default is
'_afpovertcp._tcp')");
+ Console.WriteLine(" -r|--resolve resolve found services to
hosts");
+ Console.WriteLine(" -p|--publish publish a service of
'description'");
+ Console.WriteLine("");
+ Console.WriteLine("The service description for publishing has the
following syntax.");
+ Console.WriteLine("The TXT record is optional.\n");
+ Console.WriteLine(" <type> <port> <name> TXT [ <key>='<value>',
... ]\n");
+ Console.WriteLine("For example:\n");
+ Console.WriteLine(" _http._tcp 80 Simple Web Server");
+ Console.WriteLine(" _daap._tcp 3689 Aaron's Music TXT [
Password='false', Machine Name='Aaron's Box', txtvers='1' ]");
+ Console.WriteLine("");
+ return 1;
+ }
+
+ // Create a test connection to daemon
+ Zeroconf.Initialize();
+
+ if(services.Count > 0) {
+ foreach(string service_description in services) {
+ RegisterService(service_description);
+ }
+ } else {
+ // Listen for events of some service type
+ ServiceBrowser browser = new ServiceBrowser(type);
+ browser.ServiceAdded += OnServiceAdded;
+ browser.ServiceRemoved += OnServiceRemoved;
+ browser.StartAsync();
+
+ Console.WriteLine("Hit ^C when you're bored waiting for
responses.");
+ }
+
+ while(true) {
+ System.Threading.Thread.Sleep(1000);
+ }
+ }
+
+ private static void RegisterService(string serviceDescription)
+ {
+ Match match = Regex.Match(serviceDescription,
@"(_[a-z]+._tcp|udp)\s*(\d+)\s*(.*)");
+ if(match.Groups.Count < 4) {
+ throw new ApplicationException("Invalid service description
syntax");
+ }
+
+ string type = match.Groups[1].Value.Trim();
+ short port = Convert.ToInt16(match.Groups[2].Value);
+ string name = match.Groups[3].Value.Trim();
+
+ int txt_pos = name.IndexOf("TXT");
+ string txt_data = null;
+
+ if(txt_pos > 0) {
+ txt_data = name.Substring(txt_pos).Trim();
+ name = name.Substring(0, txt_pos).Trim();
+
+ if(txt_data == String.Empty) {
+ txt_data = null;
+ }
+ }
+
+ RegisterService service = new RegisterService(name, null, type);
+ service.Port = port;
+ service.ReplyDomain = "local.";
+ TxtRecord record = null;
+
+ if(txt_data != null) {
+ Match tmatch = Regex.Match(txt_data, @"TXT\s*\[(.*)\]");
+ Console.WriteLine(tmatch.Groups.Count);
+ if(tmatch.Groups.Count != 2) {
+ throw new ApplicationException("Invalid TXT record definition
syntax");
+ }
+
+ txt_data = tmatch.Groups[1].Value;
+
+ foreach(string part in Regex.Split(txt_data, @"'\s*,")) {
+ string expr = part.Trim();
+ if(!expr.EndsWith("'")) {
+ expr += "'";
+ }
+
+ Match pmatch = Regex.Match(expr,
@"(\w+\s*\w*)\s*=\s*['](.*)[']\s*");
+ string key = pmatch.Groups[1].Value.Trim();
+ string val = pmatch.Groups[2].Value.Trim();
+
+ if(key == null || key == String.Empty || val == null || val ==
String.Empty) {
+ throw new ApplicationException("Invalid key = 'value'
syntax for TXT record item");
+ }
+
+ if(record == null) {
+ record = new TxtRecord();
+ }
+
+ record.Add(key, val);
+ }
+ }
+
+ if(record != null) {
+ service.TxtRecord = record;
+ }
+
+ service.RegisterAsync();
+ Console.WriteLine("*** Registered name = '{0}', type = '{1}', domain =
'{2}'",
+ service.Name,
+ service.RegType,
+ service.ReplyDomain);
+ }
+
+ private static void OnServiceAdded(object o, ServiceBrowseEventArgs args)
+ {
+ Console.WriteLine("*** Found name = '{0}', type = '{1}', domain =
'{2}'",
+ args.Service.Name,
+ args.Service.RegType,
+ args.Service.ReplyDomain);
+
+ if(resolve_shares) {
+ args.Service.Resolved += OnServiceResolved;
+ args.Service.Resolve();
+ }
+ }
+
+ private static void OnServiceRemoved(object o, ServiceBrowseEventArgs args)
+ {
+ Console.WriteLine("*** Lost name = '{0}', type = '{1}', domain =
'{2}'",
+ args.Service.Name,
+ args.Service.RegType,
+ args.Service.ReplyDomain);
+ }
+
+ private static void OnServiceResolved(object o, EventArgs args)
+ {
+ BrowseService service = o as BrowseService;
+ Console.Write("*** Resolved name = '{0}', host = '{1}', port = '{2}'",
+ service.FullName, service.HostEntry.AddressList[0], service.Port);
+
+ TxtRecord record = service.TxtRecord;
+ int record_count = record.Count;
+ if(record != null && record_count > 0) {
+ Console.Write(", TXT Record = [");
+ for(int i = 0, n = record.Count; i < n; i++) {
+ TxtRecordItem item = record.GetItemAt(i);
+ Console.Write("{0} = '{1}'", item.Key, item.ValueString);
+ if(i < n - 1) {
+ Console.Write(", ");
+ }
+ }
+ Console.WriteLine("]");
+ } else {
+ Console.WriteLine("");
+ }
+ }
+}
+
Added: trunk/Mono.Zeroconf/Test/mzclient.in
===================================================================
--- trunk/Mono.Zeroconf/Test/mzclient.in 2006-04-25 01:38:44 UTC (rev
59832)
+++ trunk/Mono.Zeroconf/Test/mzclient.in 2006-04-25 03:45:23 UTC (rev
59833)
@@ -0,0 +1,3 @@
+#!/bin/bash
+mono /usr/lib/mzclient/mzclient.exe "$@"
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches