EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.CallManager", "..\src\Tizen.CallManager\Tizen.CallManager.csproj", "{05DD16B8-2027-4728-AEB6-6296E7457533}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.Shortcut", "..\src\Tizen.Applications.Shortcut\Tizen.Applications.Shortcut.csproj", "{4F6ECAC1-C311-42E2-A700-40347DD9830E}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
{05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x64.Build.0 = Release|x64
{05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x86.ActiveCfg = Release|x86
{05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x86.Build.0 = Release|x86
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Debug|x64.ActiveCfg = Debug|x64
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Debug|x64.Build.0 = Debug|x64
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Debug|x86.ActiveCfg = Debug|x86
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Debug|x86.Build.0 = Debug|x86
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Release|x64.ActiveCfg = Release|x64
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Release|x64.Build.0 = Release|x64
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Release|x86.ActiveCfg = Release|x86
+ {4F6ECAC1-C311-42E2-A700-40347DD9830E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
EndGlobal
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netstandard1.6</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Tizen\Tizen.csproj" />
+ <ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
+ </ItemGroup>
+
+</Project>
--- /dev/null
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26430.6
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Shortcut", "Tizen.Applications.Shortcut.csproj", "{002C0868-E774-4ACA-B033-83B91C3B2C57}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {002C0868-E774-4ACA-B033-83B91C3B2C57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {002C0868-E774-4ACA-B033-83B91C3B2C57}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {002C0868-E774-4ACA-B033-83B91C3B2C57}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {002C0868-E774-4ACA-B033-83B91C3B2C57}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class that contains shortcut information.
+ /// </summary>
+ public class HomeShortcutInfo : ShortcutInfo
+ {
+ /// <summary>
+ /// Gets or sets the specific information for delivering to the viewer for creating a shortcut.
+ /// </summary>
+ public string Uri { get; set; } = string.Empty;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// Enumeration for sizes of shortcut widget.
+ /// </summary>
+ public enum ShortcutWidgetSize
+ {
+ /// <summary>
+ /// Type mask for the normal mode widget , don't use this value for specific size.
+ /// </summary>
+ WidgetDefault = 0x10000000,
+
+ /// <summary>
+ /// 1by1
+ /// </summary>
+ Widget1by1 = 0x10010000,
+
+ /// <summary>
+ /// 2by1
+ /// </summary>
+ Widget2by1 = 0x10020000,
+
+ /// <summary>
+ /// 2by2
+ /// </summary>
+ Widget2by2 = 0x10040000,
+
+ /// <summary>
+ /// 4by1
+ /// </summary>
+ Widget4by1 = 0x10080000,
+
+ /// <summary>
+ /// 4by2
+ /// </summary>
+ Widget4by2 = 0x10100000,
+
+ /// <summary>
+ /// 4by3
+ /// </summary>
+ Widget4by3 = 0x10200000,
+
+ /// <summary>
+ /// 4by4
+ /// </summary>
+ Widget4by4 = 0x10400000,
+
+ /// <summary>
+ /// 4by5
+ /// </summary>
+ Widget4by5 = 0x11000000,
+
+ /// <summary>
+ /// 4by6
+ /// </summary>
+ Widget4by6 = 0x12000000,
+
+ /// <summary>
+ /// Type mask for the easy mode widget, don't use this value for specific size.
+ /// </summary>
+ EasyDefault = 0x30000000,
+
+ /// <summary>
+ /// Easy mode 1by1
+ /// </summary>
+ Easy1by1 = 0x30010000,
+
+ /// <summary>
+ /// Easy mode 3by2
+ /// </summary>
+ Easy3by1 = 0x30020000,
+
+ /// <summary>
+ /// Easy mode 3by3
+ /// </summary>
+ Easy3by3 = 0x30040000,
+ }
+
+ /// <summary>
+ /// Enumeration for shortcut types.
+ /// </summary>
+ internal enum ShortcutType
+ {
+ /// <summary>
+ /// Launch the application itself.
+ /// </summary>
+ LaunchByApp = 0x00000000,
+
+ /// <summary>
+ /// Launch the application with the given data(URI).
+ /// </summary>
+ LaunchByUri = 0x00000001,
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ using System;
+
+ internal static class ShortcutErrorFactory
+ {
+ private const string LogTag = "Tizen.Applications.Shortcut";
+
+ internal static Exception GetException(Interop.Shortcut.ErrorCode err, string msg)
+ {
+ switch (err)
+ {
+ case Interop.Shortcut.ErrorCode.InvalidParameter:
+ return new ArgumentException(err + " error occurred.");
+ case Interop.Shortcut.ErrorCode.PermissionDenied:
+ return new UnauthorizedAccessException(err + " Permission denied (http://tizen.org/privilege/shortcut)");
+ case Interop.Shortcut.ErrorCode.NotSupported:
+ return new NotSupportedException(err + " Not Supported (http://tizen.org/feature/shortcut)");
+ default:
+ Log.Error(LogTag, msg);
+ return new InvalidOperationException(err + " error occurred.");
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class to get information of the Shortcut.
+ /// </summary>
+ public class ShortcutInfo
+ {
+ /// <summary>
+ /// Gets or sets the name of the created shortcut icon.
+ /// </summary>
+ public string ShortcutName { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the absolute path of an icon file for this shortcut.
+ /// </summary>
+ public string IconPath { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets a value indicating whether to allow or not to allow duplication.
+ /// </summary>
+ public bool IsAllowDuplicate { get; set; }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ using System;
+ using System.Threading.Tasks;
+
+ /// <summary>
+ /// This class provides the some functions to add, delete shortcut.
+ /// </summary>
+ public static class ShortcutManager
+ {
+ private const string LogTag = "Tizen.Applications.Shortcut";
+
+ private static Interop.Shortcut.ResultCallback shortcutAddResult = null;
+
+ private static Interop.Shortcut.ResultCallback widgetAddResult = null;
+
+ private static Interop.Shortcut.ResultCallback shortcutDeleteResult = null;
+
+ /// <summary>
+ /// Adds a shortcut on home-screen.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="shortcut">Object that contain shortcut info.</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void Add(HomeShortcutInfo shortcut)
+ {
+ Interop.Shortcut.ErrorCode err = Interop.Shortcut.ErrorCode.None;
+
+ try
+ {
+ int type;
+
+ if (shortcut.Uri == null || shortcut.Uri == String.Empty)
+ {
+ type = 0;
+ }
+ else
+ {
+ type = 1;
+ }
+
+ if (shortcutAddResult == null)
+ {
+ shortcutAddResult = new Interop.Shortcut.ResultCallback(ShortcutAddResultCallback);
+ }
+
+ err = Interop.Shortcut.AddToHome(shortcut.ShortcutName, type, shortcut.Uri, shortcut.IconPath, Convert.ToInt32(shortcut.IsAllowDuplicate), shortcutAddResult, IntPtr.Zero);
+ if (err != Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException(err, "unable to add shortcut");
+ }
+ }
+ catch (Exception e)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.IoError, e.Message);
+ }
+ }
+
+ /// <summary>
+ /// Adds a shortcut on home-screen.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="shortcut">Object that contain shortcut info.</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void Add(WidgetShortcutInfo shortcut)
+ {
+ Interop.Shortcut.ErrorCode err = Interop.Shortcut.ErrorCode.None;
+
+ if (shortcut.Period < 0.0)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
+
+ try
+ {
+ if (widgetAddResult == null)
+ {
+ widgetAddResult = new Interop.Shortcut.ResultCallback(WidgetAddResultCallback);
+ }
+
+ err = Interop.Shortcut.AddToWidget(shortcut.ShortcutName, shortcut.WidgetSize, shortcut.WidgetId, shortcut.IconPath, shortcut.Period, Convert.ToInt32(shortcut.IsAllowDuplicate), null, IntPtr.Zero);
+ if (err != Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException(err, "unable to add shortcut");
+ }
+ }
+ catch (Exception e)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.IoError, e.Message);
+ }
+ }
+
+ /// <summary>
+ /// Removes a shortcut from home by ShortcutName.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="shortcutName">Shortcut name string.</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void Delete(string shortcutName)
+ {
+ Interop.Shortcut.ErrorCode err = Interop.Shortcut.ErrorCode.None;
+
+ if (shortcutName == null)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
+
+ try
+ {
+ if (shortcutDeleteResult == null)
+ {
+ shortcutDeleteResult = new Interop.Shortcut.ResultCallback(DeleteResultCallback);
+ }
+
+ err = Interop.Shortcut.Delete(shortcutName, shortcutDeleteResult, IntPtr.Zero);
+ if (err != Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException(err, "unable to delete shortcut");
+ }
+ }
+ catch (Exception e)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.IoError, e.Message);
+ }
+ }
+
+ /// <summary>
+ /// Removes a shortcut from home by ShortcutInfo.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="shortcut">Object that contain shortcut info.</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void Delete(ShortcutInfo shortcut)
+ {
+ if (shortcut == null)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, "Invalid parameter");
+ }
+
+ try
+ {
+ Delete(shortcut.ShortcutName);
+ }
+ catch (Exception e)
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.IoError, e.Message);
+ }
+ }
+
+ private static int ShortcutAddResultCallback(int ret, IntPtr data)
+ {
+ if (ret != (int)Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)ret, "unable to add shortcut");
+ }
+
+ return 0;
+ }
+
+ private static int WidgetAddResultCallback(int ret, IntPtr data)
+ {
+ if (ret != (int)Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)ret, "unable to add widget");
+ }
+
+ return 0;
+ }
+
+ private static int DeleteResultCallback(int ret, IntPtr data)
+ {
+ if (ret != (int)Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException((Interop.Shortcut.ErrorCode)ret, "unable to delete shortcut");
+ }
+
+ return 0;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class that contains information about the widget.
+ /// </summary>
+ public class WidgetShortcutInfo : ShortcutInfo
+ {
+ /// <summary>
+ /// Gets or sets the Widget ID.
+ /// </summary>
+ public string WidgetId { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Gets or sets the size of widget.
+ /// </summary>
+ public ShortcutWidgetSize WidgetSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the Update period in seconds.
+ /// </summary>
+ public double Period { get; set; }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class that contains shortcut information.
+ /// </summary>
+ public class HomeShortcutAddedInfo : ShortcutAddedInfo
+ {
+ /// <summary>
+ /// Gets the name of application.
+ /// </summary>
+ public string AppId { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the specific information for creating a new shortcut.
+ /// </summary>
+ public string Uri { get; internal set; } = string.Empty;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class for getting information of the Shortcut.
+ /// </summary>
+ public class ShortcutAddedInfo
+ {
+ /// <summary>
+ /// Gets the name of the created shortcut icon.
+ /// </summary>
+ public string ShortcutName { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the absolute path of an icon file for this shortcut.
+ /// </summary>
+ public string IconPath { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets a value indicating whether to allow or not to allow duplication.
+ /// </summary>
+ public bool IsAllowDuplicate { get; internal set; }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class for getting information of the Shortcut.
+ /// </summary>
+ public class ShortcutDeletedInfo
+ {
+ /// <summary>
+ /// Gets the name of package.
+ /// </summary>
+ public string AppId { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the name of the created shortcut icon.
+ /// </summary>
+ public string ShortcutName { get; internal set; } = string.Empty;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// Enumeration for values of shortcut response types.
+ /// </summary>
+ public enum ShortcutError
+ {
+ /// <summary>
+ /// Successful.
+ /// </summary>
+ None = Tizen.Internals.Errors.ErrorCode.None,
+
+ /// <summary>
+ /// Invalid function parameter.
+ /// </summary>
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+
+ /// <summary>
+ /// Out of memory.
+ /// </summary>
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+
+ /// <summary>
+ /// Permission denied.
+ /// </summary>
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+
+ /// <summary>
+ /// I/O Error.
+ /// </summary>
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+
+ /// <summary>
+ /// Not supported.
+ /// </summary>
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
+
+ /// <summary>
+ /// Device or resource busy.
+ /// </summary>
+ ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,
+
+ /// <summary>
+ /// There is no space to add a new shortcut.
+ /// </summary>
+ NoSpace = -0x01160000 | 0x01,
+
+ /// <summary>
+ /// Shortcut is already added.
+ /// </summary>
+ Exist = -0x01160000 | 0x02,
+
+ /// <summary>
+ /// Unrecoverable error.
+ /// </summary>
+ Fault = -0x01160000 | 0x04,
+
+ /// <summary>
+ /// Not exist shortcut.
+ /// </summary>
+ NotExist = -0x01160000 | 0x08,
+
+ /// <summary>
+ /// Connection not established or communication problem.
+ /// </summary>
+ COMM = -0x01160000 | 0x40
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ using System;
+ using System.Collections.Generic;
+
+ /// <summary>
+ /// The callback function that is invoked when add request occurred
+ /// </summary>
+ /// <param name="args">Object that contain shortcut info to add.</param>
+ /// <returns>The result of handling a shortcut add request</returns>
+ public delegate ShortcutError ShortcutAdded(ShortcutAddedInfo args);
+
+ /// <summary>
+ /// The callback function that is invoked when delete request occurred
+ /// </summary>
+ /// <param name="args">Object that contain shortcut info to delete.</param>
+ /// <returns>The result of handling a shortcut delete request</returns>
+ public delegate ShortcutError ShortcutDeleted(ShortcutDeletedInfo args);
+
+ /// <summary>
+ /// This class provides a way to register callback function for shortcut add, delete events.
+ /// </summary>
+ public static class ShortcutEventManager
+ {
+ private static Interop.Shortcut.AddCallback shortcutAddCallback;
+
+ private static Interop.Shortcut.DeleteCallback shortcutDeleteCallback;
+
+ private static IList<ShortcutTemplate> shortcutTemplates = new List<ShortcutTemplate>();
+
+ private static ShortcutAdded shortcutAdded = null;
+
+ private static ShortcutDeleted shortcutDeleted = null;
+
+ /// <summary>
+ /// Registers a callback function to listen requests from applications.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="addedEvent">The callback function pointer that is invoked when Add() is requested</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <remarks>
+ /// Previous registered delegate function should be unregister.
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void RegisterEventHandler(ShortcutAdded addedEvent)
+ {
+ shortcutAdded = addedEvent;
+
+ if (shortcutAddCallback == null)
+ {
+ shortcutAddCallback = new Interop.Shortcut.AddCallback(AddCallback);
+
+ Interop.Shortcut.ErrorCode err = Interop.Shortcut.SetShortcutAddCallback(shortcutAddCallback, IntPtr.Zero);
+ if (err != Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException(err, "unable to register callback");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Registers a callback function to listen requests from applications.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="deletedEvent">The callback function pointer that is invoked when Delete() is requested</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <remarks>
+ /// Previous registered delegate function should be unregister.
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void RegisterEventHandler(ShortcutDeleted deletedEvent)
+ {
+ shortcutDeleted = deletedEvent;
+
+ if (shortcutDeleteCallback == null)
+ {
+ shortcutDeleteCallback = new Interop.Shortcut.DeleteCallback(DeleteCallback);
+
+ Interop.Shortcut.ErrorCode err = Interop.Shortcut.SetShortcutDeleteCallback(shortcutDeleteCallback, IntPtr.Zero);
+ if (err != Interop.Shortcut.ErrorCode.None)
+ {
+ throw ShortcutErrorFactory.GetException(err, "unable to register callback");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Unregisters a callback for the shortcut request.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="addedEvent">The callback function pointer that used for RegisterCallback</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void UnregisterEventHandler(ShortcutAdded addedEvent)
+ {
+ if (shortcutAdded.Equals(addedEvent))
+ {
+ shortcutAdded = null;
+
+ if (shortcutAddCallback != null)
+ {
+ Interop.Shortcut.UnsetShortcutAddCallback();
+ shortcutAddCallback = null;
+ }
+ }
+ else
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, null);
+ }
+ }
+
+ /// <summary>
+ /// Unregisters a callback for the shortcut request.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="deletedEvent">The callback function pointer that used for RegisterCallback</param>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static void UnregisterEventHandler(ShortcutDeleted deletedEvent)
+ {
+ if (shortcutDeleted.Equals(deletedEvent))
+ {
+ shortcutDeleted = null;
+
+ if (shortcutDeleteCallback != null)
+ {
+ Interop.Shortcut.UnsetShortcutDeleteCallback();
+ shortcutDeleteCallback = null;
+ }
+ }
+ else
+ {
+ throw ShortcutErrorFactory.GetException(Interop.Shortcut.ErrorCode.InvalidParameter, null);
+ }
+ }
+
+ /// <summary>
+ /// Gets the preset list of shortcut template from the installed package.
+ /// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ /// <param name="appId">Application ID.</param>
+ /// <returns>The List of ShortcutTemplate.</returns>
+ /// <feature>http://tizen.org/feature/shortcut </feature>
+ /// <privilege>http://tizen.org/privilege/shortcut</privilege>
+ /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown in case of permission denied.</exception>
+ /// <exception cref="InvalidOperationException">Thrown in case of any internal error.</exception>
+ /// <exception cref="NotSupportedException">Thrown when Shortcut is not supported.</exception>
+ public static IEnumerable<ShortcutTemplate> GetTemplateList(string appId)
+ {
+ shortcutTemplates.Clear();
+
+ Interop.Shortcut.ListCallback callback = (appName, iconPath, shortcutName, extrakey, extraData, user_data) =>
+ {
+ ShortcutTemplate template = new ShortcutTemplate
+ {
+ AppId = appName,
+ ShortcutName = shortcutName,
+ IconPath = iconPath,
+ ExtraKey = extrakey,
+ ExtraData = extraData,
+ };
+
+ shortcutTemplates.Add(template);
+
+ return 0;
+ };
+
+ Interop.Shortcut.GetList(appId, callback, IntPtr.Zero);
+
+ return shortcutTemplates;
+ }
+
+ private static int AddCallback(string appId, string shortcutName, int type, string contentInfo, string iconPath, int processId, double period, bool isAllowDuplicate, IntPtr data)
+ {
+ ShortcutError err;
+
+ if (type == (int)ShortcutType.LaunchByApp || type == (int)ShortcutType.LaunchByUri)
+ {
+ HomeShortcutAddedInfo shortcutInfo = new HomeShortcutAddedInfo
+ {
+ ShortcutName = shortcutName,
+ IconPath = iconPath,
+ IsAllowDuplicate = isAllowDuplicate,
+ AppId = appId,
+ };
+
+ if (contentInfo != null && contentInfo != String.Empty)
+ {
+ shortcutInfo.Uri = contentInfo;
+ }
+
+ if (shortcutAdded != null)
+ {
+ err = shortcutAdded(shortcutInfo);
+ }
+ else
+ {
+ err = ShortcutError.IoError;
+ }
+ }
+ else
+ {
+ WidgetShortcutAddedInfo shortcutInfo = new WidgetShortcutAddedInfo
+ {
+ ShortcutName = shortcutName,
+ IconPath = iconPath,
+ IsAllowDuplicate = isAllowDuplicate,
+ WidgetId = appId,
+ WidgetSize = (ShortcutWidgetSize)type,
+ Period = period,
+ };
+
+ if (shortcutAdded != null)
+ {
+ err = shortcutAdded(shortcutInfo);
+ }
+ else
+ {
+ err = ShortcutError.IoError;
+ }
+ }
+
+ return (int)err;
+ }
+
+ private static int DeleteCallback(string appId, string shortcutName, int processId, IntPtr data)
+ {
+ ShortcutError err = ShortcutError.None;
+
+ ShortcutDeletedInfo deletedInfo = new ShortcutDeletedInfo
+ {
+ AppId = appId,
+ ShortcutName = shortcutName,
+ };
+
+ if (shortcutDeleted != null)
+ {
+ err = shortcutDeleted(deletedInfo);
+ }
+ else
+ {
+ err = ShortcutError.IoError;
+ }
+
+ return (int)err;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class that contains the preset list of shortcut template from the installed package.
+ /// </summary>
+ public class ShortcutTemplate
+ {
+ /// <summary>
+ /// Gets the Application ID.
+ /// </summary>
+ public string AppId { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the name of the created shortcut icon.
+ /// </summary>
+ public string ShortcutName { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the absolute path of an icon file for this shortcut.
+ /// </summary>
+ public string IconPath { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the user data. A property of shortcut element in manifest file.
+ /// </summary>
+ public string ExtraKey { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the user data. A property of shortcut element in manifest file.
+ /// </summary>
+ public string ExtraData { get; internal set; } = string.Empty;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.
+ */
+
+namespace Tizen.Applications.Shortcut
+{
+ /// <summary>
+ /// A class that contains information about the widget.
+ /// </summary>
+ public class WidgetShortcutAddedInfo : ShortcutAddedInfo
+ {
+ /// <summary>
+ /// Gets the Widget ID.
+ /// </summary>
+ public string WidgetId { get; internal set; } = string.Empty;
+
+ /// <summary>
+ /// Gets the size of widget.
+ /// </summary>
+ public ShortcutWidgetSize WidgetSize { get; internal set; }
+
+ /// <summary>
+ /// Gets the Update period in seconds.
+ /// </summary>
+ public double Period { get; internal set; }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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 Shortcut = "libshortcut.so.0";
+ }
+}
--- /dev/null
+/*
+ * 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.Shortcut;
+
+internal static partial class Interop
+{
+ internal static partial class Shortcut
+ {
+ internal delegate int AddCallback(string appId, string shortcutName, int type, string contentInfo, string iconPath, int processId, double period, bool isAllowDuplicate, IntPtr data);
+
+ internal delegate int DeleteCallback(string appId, string shortcutName, int processId, IntPtr data);
+
+ internal delegate int ResultCallback(int ret, IntPtr data);
+
+ internal delegate int ListCallback(string package_name, string icon, string name, string extra_key, string extra_data, IntPtr user_data);
+
+ /// <summary>
+ /// Enumeration for values of shortcut response types.
+ /// </summary>
+ internal enum ErrorCode : int
+ {
+ /// <summary>
+ /// Successful
+ /// </summary>
+ None = Tizen.Internals.Errors.ErrorCode.None,
+
+ /// <summary>
+ /// Invalid function parameter
+ /// </summary>
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+
+ /// <summary>
+ /// Out of memory
+ /// </summary>
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+
+ /// <summary>
+ /// Permission denied
+ /// </summary>
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+
+ /// <summary>
+ /// I/O Error
+ /// </summary>
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+
+ /// <summary>
+ /// Not supported
+ /// </summary>
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
+
+ /// <summary>
+ /// Device or resource busy
+ /// </summary>
+ ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy,
+
+ /// <summary>
+ /// There is no space to add a new shortcut
+ /// </summary>
+ NoSpace = -0x01160000 | 0x01,
+
+ /// <summary>
+ /// Shortcut is already added
+ /// </summary>
+ Exist = -0x01160000 | 0x02,
+
+ /// <summary>
+ /// Unrecoverable error
+ /// </summary>
+ Fault = -0x01160000 | 0x04,
+
+ /// <summary>
+ /// Not exist shortcut
+ /// </summary>
+ NotExist = -0x01160000 | 0x08,
+
+ /// <summary>
+ /// Connection not established or communication problem
+ /// </summary>
+ COMM = -0x01160000 | 0x40
+ }
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home")]
+ internal static extern ErrorCode AddToHome(string name, int type, string uri, string icon, int dubplicate, ResultCallback result, IntPtr data);
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_add_to_home_widget")]
+ internal static extern ErrorCode AddToWidget(string name, ShortcutWidgetSize size, string widgetId, string icon, double period, int dubplicate, ResultCallback result, IntPtr data);
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_remove_from_home")]
+ internal static extern ErrorCode Delete(string name, ResultCallback result, IntPtr data);
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_get_list")]
+ internal static extern ErrorCode GetList(string name, ListCallback list, IntPtr data);
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_set_request_cb")]
+ internal static extern ErrorCode SetShortcutAddCallback(AddCallback cb, IntPtr data);
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_unset_request_cb")]
+ internal static extern ErrorCode UnsetShortcutAddCallback();
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_set_remove_cb")]
+ internal static extern ErrorCode SetShortcutDeleteCallback(DeleteCallback cb, IntPtr data);
+
+ [DllImport(Libraries.Shortcut, EntryPoint = "shortcut_unset_remove_cb")]
+ internal static extern ErrorCode UnsetShortcutDeleteCallback();
+ }
+}