From: Sidharth Gupta Date: Mon, 14 Mar 2016 08:56:08 +0000 (+0900) Subject: [CommonError] Add common errors and utility functions X-Git-Tag: accepted/tizen/mobile/20161214.052220~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d1b3aa681345daae062ded4df42bb92c017d3609;p=platform%2Fcore%2Fcsapi%2Ftizen.git [CommonError] Add common errors and utility functions - Currently error enum and methods are public. Should be made private - Also changed entire Tizen namespace project from .NET 4.5.2 to 4.5 Signed-off-by: Sidharth Gupta Change-Id: I421969d59e95be5d648cb31c1d5d866aa6d74fe3 --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b2312e5 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +ASM_DIRS := Tizen Tizen.Internals +ASM_DLLS := $(addsuffix .dll,$(ASM_DIRS)) + +ALL: $(ASM_DLLS) + +define make-dll +$(eval SRC = $(shell find $1 -path $1/obj -prune -o -name '*.cs' -print)) +$1.dll: $(SRC) + @echo "[BUILD] $$@" + @mcs /nologo /out:$$@ /t:library /keyfile:$1/$1.snk $(SRC) + @echo "[CHECK] $$@" + @RET=`mono-shlib-cop $$@`; \ + CNT=`echo $$$$RET | grep -e '^error:' | wc -l`; \ + if [ $$$$CNT -gt 0 ]; then echo $$$$RET; rm -f $$@ exit 1; fi +endef + +$(eval $(call make-dll,Tizen)) +$(eval $(call make-dll,Tizen.Internals)) + +clean: + @rm -f $(ASM_DLLS) diff --git a/Tizen.Internals/Interop/Interop.CommonError.cs b/Tizen.Internals/Interop/Interop.CommonError.cs new file mode 100755 index 0000000..3c55b54 --- /dev/null +++ b/Tizen.Internals/Interop/Interop.CommonError.cs @@ -0,0 +1,28 @@ +/// 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 Libraries + { + public const string Base = "libcapi-base-common.so.0"; + } + + internal static partial class CommonError + { + [DllImport(Libraries.Base, EntryPoint = "get_last_result")] + internal static extern int GetLastResult(); + + [DllImport(Libraries.Base, EntryPoint = "get_error_message")] + internal static extern IntPtr GetErrorMessage(int errorCode); + } +} diff --git a/Tizen.Internals/Properties/AssemblyInfo.cs b/Tizen.Internals/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..0fa808a --- /dev/null +++ b/Tizen.Internals/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tizen.Internals")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyProduct("Tizen.Internals")] +[assembly: AssemblyCopyright("Copyright (c) 2015 Samsung Electronics Co., Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("b9aa1cb2-f72d-4a30-a33b-a20c850a38a0")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tizen.Internals/Tizen.Internals.Errors/ErrorCode.cs b/Tizen.Internals/Tizen.Internals.Errors/ErrorCode.cs new file mode 100755 index 0000000..331f7e2 --- /dev/null +++ b/Tizen.Internals/Tizen.Internals.Errors/ErrorCode.cs @@ -0,0 +1,115 @@ +/// 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. + + +namespace Tizen.Internals.Errors +{ + public enum ErrorCode : int + { + None = 0, // 0, /**< Successful */ + NotPermitted = -1, // -EPERM, /**< Operation not permitted */ + NoSuchFile = -2, // -ENOENT, /**< No such file or directory */ + NoSuchProcess = -3, // -ESRCH, /**< No such process */ + InterruptedSysCall = -4, // -EINTR, /**< Interrupted system call */ + IoError = -5, // -EIO, /**< I/O error */ + NoSuchDevice = -6, // -ENXIO, /**< No such device or address */ + ArgumentListTooLong = -7, // -E2BIG, /**< Argument list too long */ + ExecFormatError = -8, // -ENOEXEC, /**< Exec format error */ + BadFileNumber = -9, // -EBADF, /**< Bad file number */ + TryAgain = -11, // -EAGAIN, /**< Try again */ + OutOfMemory = -12, // -ENOMEM, /**< Out of memory */ + PermissionDenied = -13, // -EACCES, /**< Permission denied */ + BadAddress = -14, // -EFAULT, /**< Bad address */ + BlockDeviceRequired = -15, // -ENOTBLK, /**< Block device required */ + ResourceBusy = -16, // -EBUSY, /**< Device or resource busy */ + FileExists = -17, // -EEXIST, /**< File exists */ + CrossDeviceLink = -18, // -EXDEV, /**< Cross-device link */ + NotaDirectory = -20, // -ENOTDIR, /**< Not a directory */ + IsADirectory = -21, // -EISDIR, /**< Is a directory */ + InvalidParameter = -22, // -EINVAL, /**< Invalid function parameter */ + FileTableOverflow = -23, // -ENFILE, /**< File table overflow */ + TooManyOpenFiles = -24, // -EMFILE, /**< Too many open files */ + TooNotaTerminal = -25, // -ENOTTY, /**< Not a terminal */ + TooTextFileBusy = -26, // -ETXTBSY, /**< Not a terminal */ + FileTooLarge = -27, // -EFBIG, /**< File too large */ + FileNoSpaceOnDevice = -28, // -ENOSPC, /**< No space left on device */ + IllegalSeek = -29, // -ESPIPE, /**< Illegal seek */ + ReadOnlyFilesystem = -30, // -EROFS, /**< Read-only file system */ + NoData = -61, // -ENODATA, /**< No data available */ + TooManyLinks = -31, // -EMLINK, /**< Too many links */ + BrokenPipe = -32, // -EPIPE, /**< Broken pipe */ + ArgumentOutOfDomain = -33, // -EDOM, /**< Math argument out of domain of func */ + ResultOutOfRange = -34, // -ERANGE, /**< Math result not representable */ + WouldCauseDeadlock = -35, // -EDEADLK, /**< Resource deadlock would occur */ + FileNameTooLong = -36, // -ENAMETOOLONG,/**< File name too long */ + FileNoLocksAvailable = -37, // -ENOLCK, /**< No record locks available */ + InvalidOperation = -38, // -ENOSYS, /**< Function not implemented */ + DirNotEmpty = -39, // -ENOTEMPTY, /**< Directory not empty */ + TooManySymbolicLinks = -40, // -ELOOP, /**< Too many symbolic links encountered */ + WouldBlock = -11, // TryAgain (-EAGAIN), /**< Operation would block */ + CorruptedSharedLib = -80, // -ELIBBAD, /**< Accessing a corrupted shared library */ + LibSectionCorrupted = -81, // -ELIBSCN, /**< .lib section in a.out corrupted */ + LinkTooManySharedLib = -82, // -ELIBMAX, /**< Attempting to link in too many shared libraries */ + SharedLibExec = -83, // -ELIBEXEC, /**< Cannot exec a shared library directly */ + IllegalByteSeq = -84, // -EILSEQ, /**< Illegal byte sequence */ + SystemCallRestart = -85, // -ERESTART, /**< Interrupted system call should be restarted */ + StreamsPipe = -86, // -ESTRPIPE, /**< Streams pipe error */ + TooManyUsers = -87, // -EUSERS, /**< Too many users */ + NonSocket = -88, // -ENOTSOCK, /**< Socket operation on non-socket */ + NoDestAddress = -89, // -EDESTADDRREQ, /**< Destination address required */ + MsgTooLong = -90, // -EMSGSIZE, /**< Message too long */ + ProtocolWrongType = -91, // -EPROTOTYPE, /**< Protocol wrong type for socket */ + ProtocolNotAvaliable = -92, // -ENOPROTOOPT, /**< Protocol not available */ + ProtocolNotSupported = -93, // -EPROTONOSUPPORT, /**< Protocol not supported */ + SocketTypeNotSupported = -94, // -ESOCKTNOSUPPORT, /**< Socket type not supported */ + EndpointOperatinNotSupported = -95, // -EOPNOTSUPP, /**< Operation not supported on transport endpoint */ + ProtocolFamilyNotSupported = -96, // -EPFNOSUPPORT, /**< Protocol family not supported */ + AddressFamilyNotSupported = -97, // -EAFNOSUPPORT, /**< Address family not supported by protocol */ + AddresInUse = -98, // -EADDRINUSE, /**< Address already in use */ + CannotAssignAddress = -99, // -EADDRNOTAVAIL, /**< Cannot assign requested address */ + Networkdown = -100, // -ENETDOWN, /**< Network is down */ + NetworkUnreachable = -101, // -ENETUNREACH, /**< Network is unreachable */ + NetworkReset = -102, // -ENETRESET, /**< Network dropped connection because of reset */ + ConnectionAborted = -103, // -ECONNABORTED, /**< Software caused connection abort */ + ConnectionResetByPeer = -104, // -ECONNRESET, /**< Connection reset by peer */ + BufferSpace = -105, // -ENOBUFS, /**< No buffer space available */ + EndpointConnected = -106, // -EISCONN, /**< Transport endpoint is already connected */ + EndpointNotConnected = -107, // -ENOTCONN, /**< Transport endpoint is not connected */ + EndpointShutdown = -108, // -ESHUTDOWN, /**< Cannot send after transport endpoint shutdown */ + TooManyReferences = -109, // -ETOOMANYREFS, /**< Too many references: cannot splice */ + ConnectionTimeout = -110, // -ETIMEDOUT, /**< Connection timed out */ + ConnectionRefused = -111, // -ECONNREFUSED, /**< Connection refused */ + Hostdown = -112, // -EHOSTDOWN, /**< Host is down */ + NoRouteToHost = -113, // -EHOSTUNREACH, /**< No route to host */ + AlreadyInProgress = -114, // -EALREADY, /**< Operation already in progress */ + NowInProgress = -115, // -EINPROGRESS, /**< Operation now in progress */ + StaleNfsFileHandle = -116, // -ESTALE, /**< Stale NFS file handle */ + StructureUnclean = -117, // -EUCLEAN, /**< Structure needs cleaning */ + NotXenixNamedTypeFile = -118, // -ENOTNAM, /**< Not a XENIX named type file */ + NoXenixSemaphoresAvailable = -119, // -ENAVAIL, /**< No XENIX semaphores available */ + IsNamedTypeFile = -120, // -EISNAM, /**< Is a named type file */ + RemoteIo = -121, // -EREMOTEIO, /**< Remote I/O error */ + QuotaExceeded = -122, // -EDQUOT, /**< Quota exceeded */ + NoMedium = -123, // -ENOMEDIUM, /**< No medium found */ + WrongMediumType = -124, // -EMEDIUMTYPE, /**< Wrong medium type */ + Canceled = -125, // -ECANCELED, /**< Operation Canceled */ + KeyNotAvailable = -126, // -ENOKEY, /**< Required key not available */ + KeyExpired = -127, // -EKEYEXPIRED, /**< Key has expired */ + KeyRevoked = -128, // -EKEYREVOKED, /**< Key has been revoked */ + KeyRejected = -129, // -EKEYREJECTED, /**< Key was rejected by service */ + + OwnerDead = -130, // -EOWNERDEAD, /**< Owner died (for robust mutexes) */ + + Unknown = -1073741824, // TIZEN_ERROR_MIN_PLATFORM_ERROR, /**< Unknown error */ + + TimedOut, // /**< Time out */ + NotSupported, // /**< Not Supported */ + UserNotConsented,// /**< Not Consented */ + EndofCollection // + } +} diff --git a/Tizen.Internals/Tizen.Internals.Errors/ErrorFacts.cs b/Tizen.Internals/Tizen.Internals.Errors/ErrorFacts.cs new file mode 100755 index 0000000..4a09063 --- /dev/null +++ b/Tizen.Internals/Tizen.Internals.Errors/ErrorFacts.cs @@ -0,0 +1,40 @@ +/// 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; + +namespace Tizen.Internals.Errors +{ + /// + /// + /// + public static class ErrorFacts + { + /// + /// + /// + /// + public static int GetLastResult() + { + return Interop.CommonError.GetLastResult(); + } + + /// + /// + /// + /// + /// + public static string GetErrorMessage(int errorCode) + { + IntPtr errorPtr = Interop.CommonError.GetErrorMessage(errorCode); + return Marshal.PtrToStringAuto(errorPtr); + } + } +} diff --git a/Tizen.Internals/Tizen.Internals.csproj b/Tizen.Internals/Tizen.Internals.csproj new file mode 100755 index 0000000..d4119c6 --- /dev/null +++ b/Tizen.Internals/Tizen.Internals.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0} + Library + Properties + Tizen.Internals + Tizen.Internals + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + Tizen.Internals.snk + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tizen.Internals/Tizen.Internals.snk b/Tizen.Internals/Tizen.Internals.snk new file mode 100755 index 0000000..0fcdde4 Binary files /dev/null and b/Tizen.Internals/Tizen.Internals.snk differ diff --git a/Tizen.sln b/Tizen.sln index 3ef5a12..a3af06a 100755 --- a/Tizen.sln +++ b/Tizen.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen", "Tizen\Tizen.csproj", "{7659CA59-410D-41A1-9841-586E88BC78C9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Internals", "Tizen.Internals\Tizen.Internals.csproj", "{B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {7659CA59-410D-41A1-9841-586E88BC78C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {7659CA59-410D-41A1-9841-586E88BC78C9}.Release|Any CPU.ActiveCfg = Release|Any CPU {7659CA59-410D-41A1-9841-586E88BC78C9}.Release|Any CPU.Build.0 = Release|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Tizen/Tizen.csproj b/Tizen/Tizen.csproj index cc3e3ff..1083135 100755 --- a/Tizen/Tizen.csproj +++ b/Tizen/Tizen.csproj @@ -9,8 +9,9 @@ Properties Tizen Tizen - v4.5.2 + v4.5 512 + true diff --git a/packaging/csapi-tizen.pc.in b/packaging/csapi-tizen.pc.in index e0b220a..e8cb460 100644 --- a/packaging/csapi-tizen.pc.in +++ b/packaging/csapi-tizen.pc.in @@ -1,5 +1,5 @@ Name: csapi-tizen Description: Tizen API for C# Version: @version@ -Libs: -r:@dllpath@/@dllname@ -Requires: \ No newline at end of file +Libs: -r:@dllpath@/Tizen.dll,@dllpath@/Tizen.Internals.dll +Requires: diff --git a/packaging/csapi-tizen.spec b/packaging/csapi-tizen.spec index 19ebe13..f0765f5 100644 --- a/packaging/csapi-tizen.spec +++ b/packaging/csapi-tizen.spec @@ -1,5 +1,4 @@ %define dllpath %{_libdir}/mono/tizen -%define dllname Tizen.dll Name: csapi-tizen Summary: Tizen API for C# @@ -12,22 +11,16 @@ 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(dlog) +BuildRequires: pkgconfig(capi-base-common) -# P/Invoke Runtime Dependencies -# TODO: It should be removed after fix tizen-rpm-config Requires: dlog -# DLL Dependencies -#BuildRequires: ... +Requires: capi-base-common + +Requires(post): mono-core +Requires(postun): mono-core %description Tizen API for C# @@ -46,36 +39,27 @@ Development package for %{name} cp %{SOURCE1} . %build -# build dll -mcs -target:library -out:%{dllname} -keyfile:Tizen/Tizen.snk \ - Tizen/Properties/AssemblyInfo.cs \ - Tizen/Tizen/*.cs \ - Tizen/Interop/*.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 +make %install # copy dll mkdir -p %{buildroot}%{dllpath} -install -p -m 644 %{dllname} %{buildroot}%{dllpath} +install -p -m 644 Tizen.dll %{buildroot}%{dllpath} +install -p -m 644 Tizen.Internals.dll %{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} +gacutil -i %{dllpath}/Tizen.dll +gacutil -i %{dllpath}/Tizen.Internals.dll %files -%{dllpath}/%{dllname} +%{dllpath}/Tizen.dll +%{dllpath}/Tizen.Internals.dll %files devel %{_libdir}/pkgconfig/%{name}.pc