diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0eef45 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +bin +obj +*.userprefs \ No newline at end of file diff --git a/JmDNS/README.md b/JmDNS/README.md new file mode 100644 index 0000000..34d04cb --- /dev/null +++ b/JmDNS/README.md @@ -0,0 +1,19 @@ +JmDNS bindings +=============== + +This is the JmDNS bindings for Xamarin.Android which at the moment are not working with JmDNS 3.4.1. + +Building +======== + +Download the JmDNS Jar v3.4.1. +> http://sourceforge.net/projects/jmdns/ + + +Extract the zip and copy the jar file +> jmdns-3.4.1/lib/jmdns.jar +to +> JmDNS/binding/Jars + + +Samples contains a short sample I found online but it is currently not functional. Was just so I could easily reference the corret binding name. diff --git a/JmDNS/bindings/Additions/AboutAdditions.txt b/JmDNS/bindings/Additions/AboutAdditions.txt new file mode 100644 index 0000000..c511f1d --- /dev/null +++ b/JmDNS/bindings/Additions/AboutAdditions.txt @@ -0,0 +1,48 @@ +Additions allow you to add arbitrary C# to the generated classes +before they are compiled. This can be helpful for providing convenience +methods or adding pure C# classes. + +== Adding Methods to Generated Classes == + +Let's say the library being bound has a Rectangle class with a constructor +that takes an x and y position, and a width and length size. It will look like +this: + +public partial class Rectangle +{ + public Rectangle (int x, int y, int width, int height) + { + // JNI bindings + } +} + +Imagine we want to add a constructor to this class that takes a Point and +Size structure instead of 4 ints. We can add a new file called Rectangle.cs +with a partial class containing our new method: + +public partial class Rectangle +{ + public Rectangle (Point location, Size size) : + this (location.X, location.Y, size.Width, size.Height) + { + } +} + +At compile time, the additions class will be added to the generated class +and the final assembly will a Rectangle class with both constructors. + + +== Adding C# Classes == + +Another thing that can be done is adding fully C# managed classes to the +generated library. In the above example, let's assume that there isn't a +Point class available in Java or our library. The one we create doesn't need +to interact with Java, so we'll create it like a normal class in C#. + +By adding a Point.cs file with this class, it will end up in the binding library: + +public class Point +{ + public int X { get; set; } + public int Y { get; set; } +} diff --git a/JmDNS/bindings/Additions/IDNSListener.cs b/JmDNS/bindings/Additions/IDNSListener.cs new file mode 100644 index 0000000..3d4f537 --- /dev/null +++ b/JmDNS/bindings/Additions/IDNSListener.cs @@ -0,0 +1,10 @@ +using System; + +namespace Javax.Jmdns.Impl +{ + public interface IDNSListener + { + // void updateRecord(DNSCache dnsCache, long now, DNSEntry record); + } +} + diff --git a/JmDNS/bindings/Additions/SubTypeEntry.cs b/JmDNS/bindings/Additions/SubTypeEntry.cs new file mode 100644 index 0000000..f62df1f --- /dev/null +++ b/JmDNS/bindings/Additions/SubTypeEntry.cs @@ -0,0 +1,17 @@ +using System; +using Android.Runtime; + +namespace Javax.Jmdns.Impl +{ + public partial class SubTypeEntry + { + /* + static IntPtr n_GetKey (IntPtr jnienv, IntPtr native__this) + { + global::Javax.Jmdns.Impl.JmDNSImpl.SubTypeEntry __this = global::Java.Lang.Object.GetObject (jnienv, native__this, JniHandleOwnership.DoNotTransfer); + return JNIEnv.NewString(__this.Key.ToString()); + } + */ + } +} + diff --git a/JmDNS/bindings/Jars/AboutJars.txt b/JmDNS/bindings/Jars/AboutJars.txt new file mode 100644 index 0000000..4f9de89 --- /dev/null +++ b/JmDNS/bindings/Jars/AboutJars.txt @@ -0,0 +1,37 @@ +This directory is for Android .jars. + +There are 3 types of jars that are supported: + +== Input Jar and Embedded Jar == + +This is the jar that bindings should be generated for. + +For example, if you were binding the Google Maps library, this would +be Google's "maps.jar". + +The difference between EmbeddedJar and InputJar is, EmbeddedJar is to be +embedded in the resulting dll as EmbeddedResource, while InputJar is not. +There are couple of reasons you wouldn't like to embed the target jar +in your dll (the ones that could be internally loaded by +feature e.g. maps.jar, or you cannot embed jars that are under some +proprietary license). + +Set the build action for these jars in the properties page to "InputJar". + + +== Reference Jar and Embedded Reference Jar == + +These are jars that are referenced by the input jar. C# bindings will +not be created for these jars. These jars will be used to resolve +types used by the input jar. + +NOTE: Do not add "android.jar" as a reference jar. It will be added automatically +based on the Target Framework selected. + +Set the build action for these jars in the properties page to "ReferenceJar". + +"EmbeddedJar" works like "ReferenceJar", but like "EmbeddedJar", it is +embedded in your dll. But at application build time, they are not included +in the final apk, like ReferenceJar files. + + diff --git a/JmDNS/bindings/Jars/jmdns.jar b/JmDNS/bindings/Jars/jmdns.jar new file mode 100644 index 0000000..b677c2e Binary files /dev/null and b/JmDNS/bindings/Jars/jmdns.jar differ diff --git a/JmDNS/bindings/Jars/jmdns_mod.jar b/JmDNS/bindings/Jars/jmdns_mod.jar new file mode 100644 index 0000000..ec1c263 Binary files /dev/null and b/JmDNS/bindings/Jars/jmdns_mod.jar differ diff --git a/JmDNS/bindings/JmDNS-Bindings.csproj b/JmDNS/bindings/JmDNS-Bindings.csproj new file mode 100644 index 0000000..b7a90fa --- /dev/null +++ b/JmDNS/bindings/JmDNS-Bindings.csproj @@ -0,0 +1,59 @@ + + + + Debug + AnyCPU + {3E8EAC06-E226-4FB2-90B4-0AD65A618EAE} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{10368E6C-D01B-4462-8E8B-01FC667A7035};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + JmDNSBindings + True + Assets + Resources + JmDNS-Bindings + v4.4 + + + true + full + false + bin\Debug + DEBUG;__MOBILE__;__ANDROID__; + prompt + 4 + None + false + + + full + true + bin\Release + __MOBILE__;__ANDROID__; + prompt + 4 + false + false + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JmDNS/bindings/Properties/AssemblyInfo.cs b/JmDNS/bindings/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..cd0bb13 --- /dev/null +++ b/JmDNS/bindings/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using Android.App; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("JmDNS-Bindings")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("brads_000")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("1.0.0")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/JmDNS/bindings/Transforms/EnumFields.xml b/JmDNS/bindings/Transforms/EnumFields.xml new file mode 100644 index 0000000..e9af0ee --- /dev/null +++ b/JmDNS/bindings/Transforms/EnumFields.xml @@ -0,0 +1,18 @@ + + + diff --git a/JmDNS/bindings/Transforms/EnumMethods.xml b/JmDNS/bindings/Transforms/EnumMethods.xml new file mode 100644 index 0000000..24ff88d --- /dev/null +++ b/JmDNS/bindings/Transforms/EnumMethods.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/JmDNS/bindings/Transforms/Metadata.xml b/JmDNS/bindings/Transforms/Metadata.xml new file mode 100644 index 0000000..866c61b --- /dev/null +++ b/JmDNS/bindings/Transforms/Metadata.xml @@ -0,0 +1,3 @@ + + public + diff --git a/JmDNS/sample/JmDNS-Sample.sln b/JmDNS/sample/JmDNS-Sample.sln new file mode 100644 index 0000000..9c153e1 --- /dev/null +++ b/JmDNS/sample/JmDNS-Sample.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JmDNS-Sample", "JmDNS-Sample\JmDNS-Sample.csproj", "{2A5E6D72-742E-4B63-9DBA-EFDF89EE8F06}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JmDNS-Bindings", "..\bindings\JmDNS-Bindings.csproj", "{3E8EAC06-E226-4FB2-90B4-0AD65A618EAE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2A5E6D72-742E-4B63-9DBA-EFDF89EE8F06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A5E6D72-742E-4B63-9DBA-EFDF89EE8F06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A5E6D72-742E-4B63-9DBA-EFDF89EE8F06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A5E6D72-742E-4B63-9DBA-EFDF89EE8F06}.Release|Any CPU.Build.0 = Release|Any CPU + {3E8EAC06-E226-4FB2-90B4-0AD65A618EAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E8EAC06-E226-4FB2-90B4-0AD65A618EAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E8EAC06-E226-4FB2-90B4-0AD65A618EAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E8EAC06-E226-4FB2-90B4-0AD65A618EAE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = JmDNS-Sample\JmDNS-Sample.csproj + EndGlobalSection +EndGlobal diff --git a/JmDNS/sample/JmDNS-Sample/Assets/AboutAssets.txt b/JmDNS/sample/JmDNS-Sample/Assets/AboutAssets.txt new file mode 100644 index 0000000..a9b0638 --- /dev/null +++ b/JmDNS/sample/JmDNS-Sample/Assets/AboutAssets.txt @@ -0,0 +1,19 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories) and given a Build Action of "AndroidAsset". + +These files will be deployed with your package and will be accessible using Android's +AssetManager, like this: + +public class ReadAsset : Activity +{ + protected override void OnCreate (Bundle bundle) + { + base.OnCreate (bundle); + + InputStream input = Assets.Open ("my_asset.txt"); + } +} + +Additionally, some Android functions will automatically load asset files: + +Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); diff --git a/JmDNS/sample/JmDNS-Sample/JmDNS-Sample.csproj b/JmDNS/sample/JmDNS-Sample/JmDNS-Sample.csproj new file mode 100644 index 0000000..6dfeb9a --- /dev/null +++ b/JmDNS/sample/JmDNS-Sample/JmDNS-Sample.csproj @@ -0,0 +1,69 @@ + + + + Debug + AnyCPU + {2A5E6D72-742E-4B63-9DBA-EFDF89EE8F06} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + JmDNSSample + Resources + Assets + True + True + Resources\Resource.designer.cs + Resource + JmDNS-Sample + Properties\AndroidManifest.xml + v4.4 + + + true + full + false + bin\Debug + DEBUG;__MOBILE__;__ANDROID__; + prompt + 4 + None + false + + + full + true + bin\Release + __MOBILE__;__ANDROID__; + prompt + 4 + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + {3E8EAC06-E226-4FB2-90B4-0AD65A618EAE} + JmDNS-Bindings + + + \ No newline at end of file diff --git a/JmDNS/sample/JmDNS-Sample/MainActivity.cs b/JmDNS/sample/JmDNS-Sample/MainActivity.cs new file mode 100644 index 0000000..1ee0549 --- /dev/null +++ b/JmDNS/sample/JmDNS-Sample/MainActivity.cs @@ -0,0 +1,163 @@ +using System; +using Android.App; +using Android.Content; +using Android.Runtime; +using Android.Views; +using Android.Widget; +using Android.OS; + +// Only thing I can import. +//using Javax.Jmdns.Impl ?? +using Javax.Jmdns; +using Javax.Jmdns.Impl; +// What the sample imports. +//import javax.jmdns.JmDNS; +//import Javax.Jmdns.ServiceEvent; +//import Javax.Jmdns.ServiceListener; +using Java.IO; +using Android.Util; + + +namespace JmDNSSample +{ + [Activity(Label = "JmDNS-Sample", MainLauncher = true)] + public class MainActivity : Activity + { + private Android.Net.Wifi.WifiManager.MulticastLock _lock; + private Android.OS.Handler _handler = new Android.OS.Handler(); + private string _type = "_workstation._tcp.local."; + private ServiceListener _listener = null; + private ServiceInfo _serviceInfo; + private JmDNS _jmdns = null; + public JmDNS JmDNS + { + get { return _jmdns; } + } + + protected override void OnCreate(Bundle bundle) + { + base.OnCreate(bundle); + + SetContentView(Resource.Layout.Main); + Button button = FindViewById