--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio Express 2013 for Windows Desktop\r
+VisualStudioVersion = 12.0.21005.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Content", "Tizen.Content\Tizen.Content.csproj", "{3EE5842E-7004-43BC-825B-29FFDEC18D4E}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Release|Any CPU = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {3EE5842E-7004-43BC-825B-29FFDEC18D4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {3EE5842E-7004-43BC-825B-29FFDEC18D4E}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {3EE5842E-7004-43BC-825B-29FFDEC18D4E}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {3EE5842E-7004-43BC-825B-29FFDEC18D4E}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+Name: csapi-mime-type
+Description: Tizen MimeType API for C#
+Version: @version@
+Libs: -r:@dllpath@/@dllname@
+Requires:
--- /dev/null
+%define dllpath %{_libdir}/mono/tizen
+%define dllname Tizen.Content.MimeType.dll
+
+Name: csapi-mime-type
+Summary: Tizen MimeType API for C#
+Version: 1.0.0
+Release: 1
+Group: Development/Libraries
+License: Apache-2.0
+URL: https://www.tizen.org
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+Source2: %{name}.pc.in
+
+# TODO: replace mono-compiler, mono-devel to mcs, mono-shlib-cop
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+# TODO: replace mono-core to gacutil.
+# mono-core should provide the symbol 'gacutil'
+Requires(post): mono-core
+Requires(postun): mono-core
+
+# P/Invoke Dependencies
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-content-mime-type)
+BuildRequires: pkgconfig(csapi-tizen)
+
+%description
+Tizen API for C#
+
+%package devel
+Summary: Development package for %{name}
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Development package for %{name}
+
+%prep
+%setup -q
+
+cp %{SOURCE1} .
+
+%build
+# build dll
+mcs -target:library -out:%{dllname} -keyfile:Tizen.Content.MimeType/Tizen.Content.MimeType.snk -pkg:'csapi-tizen'\
+ Tizen.Content.MimeType/Properties/AssemblyInfo.cs \
+ Tizen.Content.MimeType/Interop/*.cs \
+ Tizen.Content.MimeType/Tizen.Content.MimeType/*.cs
+
+# check p/invoke
+if [ -x %{dllname} ]; then
+ RET=`mono-shlib-cop %{dllname}`; \
+ CNT=`echo $RET | grep -E "^error:" | wc -l`; \
+ if [ $CNT -gt 0 ]; then exit 1; fi
+fi
+
+%install
+# copy dll
+mkdir -p %{buildroot}%{dllpath}
+install -p -m 644 %{dllname} %{buildroot}%{dllpath}
+
+# generate pkgconfig
+mkdir -p %{buildroot}%{_libdir}/pkgconfig
+sed -e "s#@version@#%{version}#g" \
+ -e "s#@dllpath@#%{dllpath}#g" \
+ -e "s#@dllname@#%{dllname}#g" \
+ %{SOURCE2} > %{buildroot}%{_libdir}/pkgconfig/%{name}.pc
+
+%post
+gacutil -i %{dllpath}/%{dllname}
+
+%files
+%{dllpath}/%{dllname}
+
+%files devel
+%{_libdir}/pkgconfig/%{name}.pc
--- /dev/null
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Glib
+ {
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate bool GSourceFunc(IntPtr userData);
+
+ [DllImport(Libraries.Glib, EntryPoint = "g_idle_add", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern uint IdleAdd(GSourceFunc d, IntPtr data);
+ }
+}
--- /dev/null
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Libc
+ {
+ [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int Free(IntPtr ptr);
+ }
+}
--- /dev/null
+/// Copyright 2016 by Samsung Electronics, Inc.,
+///
+/// This software is the confidential and proprietary information
+/// of Samsung Electronics, Inc. ("Confidential Information"). You
+/// shall not disclose such Confidential Information and shall use
+/// it only in accordance with the terms of the license agreement
+/// you entered into with Samsung.
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string Mime = "libcapi-content-mime-type.so.0";
+ public const string Glib = "libglib-2.0.so.0";
+ public const string Libc = "libc.so.6";
+ }
+}
--- /dev/null
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Mime
+ {
+ [DllImport(Libraries.Mime, EntryPoint = "mime_type_get_mime_type", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int GetMime(
+ [System.Runtime.InteropServices.InAttribute()]
+ [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string file_extension
+ , out string mime_type);
+
+ [DllImport(Libraries.Mime, EntryPoint = "mime_type_get_file_extension", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int GetFile(
+ [System.Runtime.InteropServices.InAttribute()]
+ [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)] string mime_type
+ , out System.IntPtr file_extension, out int length);
+ }
+}
\ No newline at end of file
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Content.MimeType")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tizen.Content.MimeType")]
+[assembly: AssemblyCopyright("Copyright \u00A9 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("99a90243-7db1-4704-a078-3529c2da4e81")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{3EE5842E-7004-43BC-825B-29FFDEC18D4E}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Tizen.Content.MimeType</RootNamespace>
+ <AssemblyName>Tizen.Content.MimeType</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Tizen.Content.MimeType.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Tizen">
+ <HintPath>..\..\..\..\..\..\..\dll\usr\lib\mono\tizen\Tizen.dll</HintPath>
+ </Reference>
+ <Reference Include="Tizen.Internals">
+ <HintPath>..\..\..\..\..\..\..\dll\usr\lib\mono\tizen\Tizen.Internals.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Interop\Interop.Glib.cs" />
+ <Compile Include="Interop\Interop.Libc.cs" />
+ <Compile Include="Interop\Interop.Libraries.cs" />
+ <Compile Include="Interop\Interop.Mime.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Tizen.Content.MimeType\MimeExceptionFactory.cs" />
+ <Compile Include="Tizen.Content.MimeType\MimeUtil.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Tizen.Content.MimeType.snk" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Tizen.Content.MimeType
+{
+ internal class MimeExceptionFactory
+ {
+ internal static Exception CreateException(MimeUtil.MimeError err)
+ {
+ Exception exp;
+ switch (err)
+ {
+ case MimeUtil.MimeError.InvalidParameter:
+ {
+ exp = new ArgumentException("Invalid Parameters Provided");
+ break;
+ }
+
+ case MimeUtil.MimeError.IoError:
+ {
+ exp = new SystemException("I/O Error Occured");
+ break;
+ }
+ case MimeUtil.MimeError.OutOfMemory:
+ {
+ exp = new SystemException("Out Of Memory");
+ break;
+ }
+ default:
+ {
+ exp = new InvalidOperationException("");
+ break;
+ }
+ }
+ return exp;
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Collections.Specialized;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Content.MimeType
+{
+ /// <summary>
+ /// The MimeUtil API provides functions to map MIME types to file extensions and vice versa.</summary>
+ /// <remarks>
+ /// Conversions are provided from file extensions to MIME types and from MIME types to file extensions.</remarks>
+ public static class MimeUtil
+ {
+ /// <summary>
+ /// Gets the MIME type for the given file extension.
+ /// The MIME type is 'application/octet-stream' if the given file extension is not associated with specific file formats
+ /// </summary>
+ /// <param name="fileExtension"> The file Extension</param>
+ /// <example>
+ /// <code>
+ /// string mimeType = MimeUtil.GetMimeType("png");
+ /// </code>
+ /// </example>
+ public static string GetMimeType(string fileExtension)
+ {
+ string mime;
+ int res = Interop.Mime.GetMime(fileExtension, out mime);
+ if (res != (int)MimeError.None)
+ {
+ throw MimeExceptionFactory.CreateException((MimeError)res);
+ }
+ return mime;
+ }
+
+ /// <summary>
+ /// Gets file extensions for the given MIME type. </summary>
+ /// <returns>
+ /// If Successfull, return's the list of file extension strings for the given MIME type.
+ /// The array of file extension are without the leading dot ('.')</returns>
+ /// <param name="mime"> The mime type</param>
+ /// <example>
+ /// <code>
+ /// IEnumerable<string> extColl = MimeUtil.GetFileExtension("video/mpeg");
+ /// foreach ( string obj in extColl )
+ /// {
+ /// Console.WriteLine(obj);
+ /// }
+ /// </code>
+ /// </example>
+ public static IEnumerable<string> GetFileExtension(string mime)
+ {
+ IntPtr extensionArray = IntPtr.Zero;
+ int length = -1;
+ int res = Interop.Mime.GetFile(mime, out extensionArray, out length);
+ if (res != (int)MimeError.None)
+ {
+ throw MimeExceptionFactory.CreateException((MimeError)res);
+ }
+ IntPtr[] extensionList = new IntPtr[length];
+ Marshal.Copy(extensionArray, extensionList, 0, length);
+ Collection<string> coll = new Collection<string>();
+ foreach (IntPtr extension in extensionList)
+ {
+ coll.Add(Marshal.PtrToStringAnsi(extension));
+ Interop.Libc.Free(extension);
+ }
+ Interop.Libc.Free(extensionArray);
+ return coll;
+ }
+
+ internal enum MimeError : int
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None, /**< Successful */
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /**< Invalid parameter */
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /**< Out of memory */
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError, /**< Internal I/O error */
+ }
+ }
+}