From f0e6c7d67cad6e97dceee58e387773bbcee66ea9 Mon Sep 17 00:00:00 2001 From: "seungha.son" Date: Fri, 17 Feb 2017 16:44:12 +0900 Subject: [PATCH] Initialize Tizen.Applications.ToastMessage Signed-off-by: seungha.son Change-Id: I9a8ed7dc5f20b7fbae5fe6224d1592b982209a51 --- Tizen.Applications.sln | 8 +- Tizen.Applications/Interop/Interop.Libraries.cs | 1 + Tizen.Applications/Tizen.Applications.csproj | 3 + packaging/csapi-application.spec | 26 ++++++- .../Interop/Interop.Notification.cs | 3 - .../Tizen.Applications/NotificationManager.cs | 20 ----- .../Interop/Interop.Libraries.cs | 23 ++++++ .../Interop/Interop.ToastMessage.cs | 28 +++++++ .../Properties/AssemblyInfo.cs | 20 +++++ .../Tizen.Applications.ToastMessage.csproj | 84 +++++++++++++++++++++ .../Tizen.Applications.ToastMessage.nuspec | 21 ++++++ .../Tizen.Applications.ToastMessage.project.json | 9 +++ .../Tizen.Applications.ToastMessage.snk | Bin 0 -> 596 bytes .../Tizen.Applications/ToastMessage.cs | 56 ++++++++++++++ .../Tizen.Applications/ToastMessageErrorFactory.cs | 45 +++++++++++ 15 files changed, 322 insertions(+), 25 deletions(-) create mode 100755 src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs create mode 100755 src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs create mode 100755 src/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs create mode 100755 src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj create mode 100755 src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec create mode 100755 src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json create mode 100755 src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk create mode 100755 src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs create mode 100755 src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs diff --git a/Tizen.Applications.sln b/Tizen.Applications.sln index a270b3b..33c3708 100755 --- a/Tizen.Applications.sln +++ b/Tizen.Applications.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.UI", "Ti EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications", "Tizen.Applications\Tizen.Applications.csproj", "{6209641F-4B03-4DAD-84D8-4775AD72AD75}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.ToastMessage", "Tizen.Applications.ToastMessage\Tizen.Applications.ToastMessage.csproj", "{C35F85FC-A095-4356-8F17-DD248FB1C9AA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,6 +65,10 @@ Global {6209641F-4B03-4DAD-84D8-4775AD72AD75}.Debug|Any CPU.Build.0 = Debug|Any CPU {6209641F-4B03-4DAD-84D8-4775AD72AD75}.Release|Any CPU.ActiveCfg = Release|Any CPU {6209641F-4B03-4DAD-84D8-4775AD72AD75}.Release|Any CPU.Build.0 = Release|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Tizen.Applications/Interop/Interop.Libraries.cs b/Tizen.Applications/Interop/Interop.Libraries.cs index 9f909be..ecf4b10 100755 --- a/Tizen.Applications/Interop/Interop.Libraries.cs +++ b/Tizen.Applications/Interop/Interop.Libraries.cs @@ -32,5 +32,6 @@ internal static partial class Interop public const string Notification = "libnotification.so.0"; public const string Preference = "libcapi-appfw-preference.so.0"; public const string Alarm = "libcapi-appfw-alarm.so.0"; + public const string ToastMessage = "libnotification.so.0"; } } diff --git a/Tizen.Applications/Tizen.Applications.csproj b/Tizen.Applications/Tizen.Applications.csproj index 2600bae..f74d4a0 100755 --- a/Tizen.Applications/Tizen.Applications.csproj +++ b/Tizen.Applications/Tizen.Applications.csproj @@ -92,6 +92,7 @@ + @@ -134,6 +135,8 @@ + + diff --git a/packaging/csapi-application.spec b/packaging/csapi-application.spec index fb034de..1e41090 100755 --- a/packaging/csapi-application.spec +++ b/packaging/csapi-application.spec @@ -16,7 +16,7 @@ BuildRequires: dotnet-build-tools # C# API Requires BuildRequires: csapi-tizen-nuget -%define Assemblies Tizen.Applications.Common Tizen.Applications.MessagePort Tizen.Applications.Service Tizen.Applications.PackageManager Tizen.Applications.Notification Tizen.Applications.Preference Tizen.Applications.Alarm Tizen.Applications.UI Tizen.Applications +%define Assemblies Tizen.Applications.Common Tizen.Applications.MessagePort Tizen.Applications.Service Tizen.Applications.PackageManager Tizen.Applications.Notification Tizen.Applications.Preference Tizen.Applications.Alarm Tizen.Applications.UI Tizen.Applications Tizen.Applications.ToastMessage %description %{summary} @@ -92,6 +92,22 @@ Group: Development/Libraries %description -n csapi-application-notification-nuget A notification library in Tizen C# API package. +%package -n csapi-application-toastmessage +Summary: A toastmessage library in Tizen C# API +Group: Development/Libraries +AutoReqProv: no +ExcludeArch: aarch64 + +%description -n csapi-application-toastmessage +A toastmessage library in Tizen C# API package. + +%package -n csapi-application-toastmessage-nuget +Summary: A toastmessage library in Tizen C# API +Group: Development/Libraries + +%description -n csapi-application-toastmessage-nuget +A toastmessage library in Tizen C# API package. + %package -n csapi-application-preference Summary: A preference library in Tizen C# API Group: Development/Libraries @@ -210,6 +226,14 @@ done %files -n csapi-application-notification-nuget /nuget/Tizen.Applications.Notification.%{version}.nupkg +%files -n csapi-application-toastmessage +%manifest %{name}.manifest +%license LICENSE +%attr(644,root,root) %{_dotnet_assembly_path}/Tizen.Applications.ToastMessage.dll + +%files -n csapi-application-toastmessage-nuget +/nuget/Tizen.Applications.ToastMessage.%{version}.nupkg + %files -n csapi-application-preference %manifest %{name}.manifest %license LICENSE diff --git a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs index 7ddb1d4..5252adb 100755 --- a/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs +++ b/src/Tizen.Applications.Notification/Interop/Interop.Notification.cs @@ -146,9 +146,6 @@ internal static partial class Interop [DllImport(Libraries.Notification, EntryPoint = "notification_get_tag")] internal static extern int GetTag(SafeNotificationHandle handle, out IntPtr tag); - [DllImport(Libraries.Notification, EntryPoint = "notification_status_message_post")] - internal static extern int PostMessage(string text); - [DllImport(Libraries.Notification, EntryPoint = "notification_load_by_tag")] internal static extern SafeNotificationHandle Load(string text); diff --git a/src/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs b/src/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs index 3e43764..c9abb3b 100755 --- a/src/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs +++ b/src/Tizen.Applications.Notification/Tizen.Applications/NotificationManager.cs @@ -160,26 +160,6 @@ namespace Tizen.Applications.Notifications } /// - /// Posts a message on a toast popup - /// - /// Text to display on popup - /// Thrown when argument is null - /// - /// - /// string msg = "hey there!!"; - /// NotificationManager.PostToastMessage(msg); - /// - /// - public static void PostToastMessage(string text) - { - int ret = Interop.Notification.PostMessage(text); - if(ret != (int)NotificationError.None) - { - throw NotificationErrorFactory.GetException((NotificationError)ret, "post toast message failed"); - } - } - - /// /// Searches for a posted notification which has the inputted tag /// /// diff --git a/src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs b/src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs new file mode 100755 index 0000000..c284ac5 --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Interop/Interop.Libraries.cs @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string ToastMessage = "libnotification.so.0"; + } +} diff --git a/src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs b/src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs new file mode 100755 index 0000000..69e49db --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Interop/Interop.ToastMessage.cs @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; +using Tizen.Applications; + +internal static partial class Interop +{ + internal static class ToastMessage + { + [DllImport(Libraries.ToastMessage, EntryPoint = "notification_status_message_post")] + internal static extern int ToastMessagePost(string message); + } +} diff --git a/src/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs b/src/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..46f164d --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Properties/AssemblyInfo.cs @@ -0,0 +1,20 @@ +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Tizen.Applications.ToastMessage")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Samsung Electronics")] +[assembly: AssemblyProduct("Tizen.Applications")] +[assembly: AssemblyCopyright("Copyright (c) 2017 Samsung Electronics Co., Ltd")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(true)] + +[assembly: Guid("d2d1a3ce-000e-4ab3-81c4-a8a44a008989")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj new file mode 100755 index 0000000..2c7f346 --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.csproj @@ -0,0 +1,84 @@ + + + + Debug + AnyCPU + {C35F85FC-A095-4356-8F17-DD248FB1C9AA} + Library + Properties + + + Tizen.Applications.ToastMessage + 512 + + + .NETStandard + v1.3 + .NETStandard,Version=v1.3 + false + true + $(NoWarn);1701;1702 + + + true + full + true + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + true + + + Tizen.Applications.ToastMessage.snk + + + + + + + + + + + + + + + {663c5a3d-e631-4987-aee7-f498c56a40fc} + Tizen.Applications.Common + + + + + + + + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) + true + + diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec new file mode 100755 index 0000000..1c1760f --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.nuspec @@ -0,0 +1,21 @@ + + + + Tizen.Applications.ToastMessage + $version$ + Samsung Electronics + false + https://www.apache.org/licenses/LICENSE-2.0 + https://www.tizen.org/ + https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png + © Samsung Electronics Co., Ltd All Rights Reserved + Provides the Application Frameworks API for Tizen.Net + + + + + + + + + diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json new file mode 100755 index 0000000..55ec093 --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.project.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "NETStandard.Library": "1.6.0", + "Tizen": "1.0.2" + }, + "frameworks": { + "netstandard1.3": {} + } +} diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk b/src/Tizen.Applications.ToastMessage/Tizen.Applications.ToastMessage.snk new file mode 100755 index 0000000000000000000000000000000000000000..7ac1b002b5c0f81a5b5194224843bb744535469c GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096S12Rh1DXm4>qRQE|Fs044$*e zEyJbLiSRL%Y#NVHY@M>K{9%``de=>mN4`TL|e33wl+OPc%mFqo0y5WXHq`9 zzb|ZJ4h&Bj6c_rG!7}`~i6%VYa##vxfyTV;!iBSG^crc_ZYFA#CU>3g9K5*jw~)Or zz!4Uw+aAT)FC3}nr!?kwh{M_Fq-Ii# z;Z*f_6NQu>yLa!^q~UAJ4yGN@`X9e*X}`7`c+Gny`pNGz9top#4Q7JitBDF~xjM?Yfw<8!w;k;&3kd6H; zc_m-w)0fvjmhV3!9a-U}J|vpk3}J!NNm;rFiy-#L)B-O5r)DkHSl_1`RKo~T`Ns1k zmW}ASU5<(A0WV&H#e}2kJfoL8I2fWqOreJRffWl&M2k)LE`<1N9254nJHy%AHN8vk zfcM~VsKgn7%Zd27DtZ~=pm20An|4X6Bx6v%A0yctfr={tz_&?S4$cPy|G@GzJ&^)7 iFLJDP0G>I0;>GMWh@X3wz0E^RqQ6^4@1FSr|AKP?HYIHU literal 0 HcmV?d00001 diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs b/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs new file mode 100755 index 0000000..9b85824 --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessage.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tizen.Applications +{ + public sealed class ToastMessage + { + + /// + /// Gets and sets message to post ToastMessage + /// + public string Message { get; set; } + + /// + /// Posts a message on a toast popup + /// + /// Thrown when Message is null + /// + /// + /// ToastMessage toast = new ToastMessage + /// { + /// Message = "Hello TIzen" + /// }; + /// toast.Post(); + /// + /// + public void Post() + { + int ret = Interop.ToastMessage.ToastMessagePost(Message); + if (ret != (int)ToastMessageError.None) + { + throw ToastMessageErrorFactory.GetException((ToastMessageError)ret, "post toast message failed"); + } + } + } + +} diff --git a/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs b/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs new file mode 100755 index 0000000..cd2eebc --- /dev/null +++ b/src/Tizen.Applications.ToastMessage/Tizen.Applications/ToastMessageErrorFactory.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Applications +{ + internal enum ToastMessageError + { + None = Tizen.Internals.Errors.ErrorCode.None, + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, + DBusError = -0x01140000 | 0x03, + } + + internal class ToastMessageErrorFactory + { + private const string _logTag = "Tizen.Applications.ToastMessage"; + + internal static Exception GetException(ToastMessageError ret, string msg) + { + switch (ret) + { + case ToastMessageError.InvalidParameter: + Log.Error(_logTag, msg); + return new ArgumentException(ret + " error occurred."); + default: + Log.Error(_logTag, msg); + return new InvalidOperationException(ret + " error occurred."); + } + } + } +} -- 2.7.4