2 * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
21 namespace Tizen.Applications
24 /// Represents the proxy class for the widget application.
26 public class RemoteView
29 /// The event types to send.
34 /// Type for feeding the mouse-up event to the widget application.
39 /// Type for canceling the click event procedure.
45 /// Layout object including preview image, overlay text, loading text, and remote screen image.
47 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
48 public Layout Layout { get; internal set; }
53 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
58 IntPtr ptr = Interop.WidgetViewerEvas.GetWidgetId(Layout);
60 return Marshal.PtrToStringAnsi(ptr);
65 /// The update period.
67 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
72 return Interop.WidgetViewerEvas.GetPeriod(Layout);
77 /// Contents of the widget.
80 /// This string can be used for creating contents of the widget again after rebooting a device or it can be recovered from a crash (abnormal status).
82 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
87 IntPtr ptr = Interop.WidgetViewerEvas.GetContentInfo(Layout);
89 return Marshal.PtrToStringAnsi(ptr);
94 /// Summarized string of the widget content for accessibility.
96 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
101 IntPtr ptr = Interop.WidgetViewerEvas.GetTitleString(Layout);
103 return Marshal.PtrToStringAnsi(ptr);
107 internal RemoteView()
111 internal static void CheckException(Interop.WidgetViewerEvas.ErrorCode err)
115 case Interop.WidgetViewerEvas.ErrorCode.Fault:
116 throw new InvalidOperationException("Fault at unmanaged code");
118 case Interop.WidgetViewerEvas.ErrorCode.PermissionDenied:
119 throw new UnauthorizedAccessException();
121 case Interop.WidgetViewerEvas.ErrorCode.NotSupported:
122 throw new NotSupportedException();
124 case Interop.WidgetViewerEvas.ErrorCode.InvalidParameter:
125 throw new InvalidOperationException("Invalid parameter error at unmanaged code");
127 case Interop.WidgetViewerEvas.ErrorCode.AlreadyExist:
128 throw new InvalidOperationException("Already exist");
130 case Interop.WidgetViewerEvas.ErrorCode.MaxExceeded:
131 throw new InvalidOperationException("Max exceeded");
136 /// Pauses all the connected widget applications.
138 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
139 /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
140 /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
141 /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
142 public static void PauseAll()
144 CheckException(Interop.WidgetViewerEvas.NotifyPausedStatusOfViewer());
148 /// Resumes all the connected widget applications.
150 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
151 /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
152 /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
153 /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device<./exception>
154 public static void ResumeAll()
156 CheckException(Interop.WidgetViewerEvas.NotifyResumedStatusOfViewer());
160 /// Pauses the widget application which is connected on this proxy.
162 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
163 /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
164 /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
165 /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
168 CheckException(Interop.WidgetViewerEvas.PauseWidget(Layout));
172 /// Resumes the widget application which is connected on this proxy.
174 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
175 /// <exception cref="InvalidOperationException">Thrown when this operation failed.</exception>
176 /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
177 /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
180 CheckException(Interop.WidgetViewerEvas.ResumeWidget(Layout));
184 /// Sends the event to the widget application which is connected on this proxy.
186 /// <privilege>http://tizen.org/privilege/widget.viewer</privilege>
187 /// <exception cref="UnauthorizedAccessException">Thrown when this operation is denied.</exception>
188 /// <exception cref="NotSupportedException">Thrown when this operation is not supported for this device.</exception>
189 public void SendEvent(Event ev)
193 case Event.FeedMouseUp:
194 Interop.WidgetViewerEvas.FeedMouseUpEvent(Layout);
197 case Event.CancelClick:
198 Interop.WidgetViewerEvas.CancelClickEvent(Layout);
202 throw new NotSupportedException("Not supported event type");
205 int err = Internals.Errors.ErrorFacts.GetLastResult();
206 CheckException((Interop.WidgetViewerEvas.ErrorCode)err);
209 internal void HideLoadingMessage()
211 Interop.WidgetViewerEvas.DisableLoading(Layout);
212 int err = Internals.Errors.ErrorFacts.GetLastResult();
213 CheckException((Interop.WidgetViewerEvas.ErrorCode)err);
216 internal void HidePreviewImage()
218 Interop.WidgetViewerEvas.DisablePreview(Layout);
219 int err = Internals.Errors.ErrorFacts.GetLastResult();
220 CheckException((Interop.WidgetViewerEvas.ErrorCode)err);
223 internal void HideOverlayText()
225 Interop.WidgetViewerEvas.DisableOverlayText(Layout);
226 int err = Internals.Errors.ErrorFacts.GetLastResult();
227 CheckException((Interop.WidgetViewerEvas.ErrorCode)err);