From: Geunsun, Lee Date: Wed, 29 Mar 2017 05:18:48 +0000 (+0900) Subject: Add comments for LibTVRefCommonTizen X-Git-Tag: submit/tizen/20170808.015446~141 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d85e3e11d26ea46d20e3b03728197eaceb1f0375;p=profile%2Ftv%2Fapps%2Fdotnet%2Fhome.git Add comments for LibTVRefCommonTizen Change-Id: Icbc66eaa4e3e6651069135d93f7ebf131ec940f7 --- diff --git a/LibTVRefCommonTizen/Ports/AppControlPort.cs b/LibTVRefCommonTizen/Ports/AppControlPort.cs index d3762ae..51494a3 100644 --- a/LibTVRefCommonTizen/Ports/AppControlPort.cs +++ b/LibTVRefCommonTizen/Ports/AppControlPort.cs @@ -63,7 +63,7 @@ namespace LibTVRefCommonTizen.Ports if (AppId == null || AppId.Length <= 0) { - DebuggingUtils.Err("The AppID is null or black"); + DebuggingUtils.Err("The AppID is null or blank"); return; } diff --git a/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs b/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs index 6610a01..59af18c 100644 --- a/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs +++ b/LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs @@ -100,8 +100,8 @@ namespace LibTVRefCommonTizen.Ports /// /// Gets the information of the specified application with the app ID /// - /// The app Id you want to get - /// The information of the installed applications + /// The app Id to get + /// The information of the installed application public Dictionary GetInstalledApplication(string appID) { Dictionary result = null; diff --git a/LibTVRefCommonTizen/Ports/DbgPort.cs b/LibTVRefCommonTizen/Ports/DbgPort.cs index c530c5e..ebad4b3 100644 --- a/LibTVRefCommonTizen/Ports/DbgPort.cs +++ b/LibTVRefCommonTizen/Ports/DbgPort.cs @@ -77,7 +77,7 @@ namespace LibTVRefCommonTizen.Ports } /// - ///Displays a dialog with a given message + /// Displays a dialog with a given message /// /// A debugging message public void Popup(string message) diff --git a/LibTVRefCommonTizen/Ports/FileSystemPort.cs b/LibTVRefCommonTizen/Ports/FileSystemPort.cs index 5aa8db4..5d41d14 100644 --- a/LibTVRefCommonTizen/Ports/FileSystemPort.cs +++ b/LibTVRefCommonTizen/Ports/FileSystemPort.cs @@ -15,20 +15,22 @@ */ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.IO; - -using Tizen; -using Tizen.Applications; using LibTVRefCommonPortable.Utils; namespace LibTVRefCommonTizen.Ports { + /// + /// Handles FileSystem APIs + /// public class FileSystemPort : IFileSystemAPIs { + /// + /// Opens the given file + /// + /// A relative or absolute path for the file that the current FileStream object will encapsulate + /// A constant that determines how to open or create the file + /// A generic view of a sequence of bytes public Stream OpenFile(string filePath, UtilFileMode mode) { Stream fileStream = null; @@ -45,37 +47,58 @@ namespace LibTVRefCommonTizen.Ports return fileStream; } + /// + /// Flushes the given steam + /// + /// The stream to flush public void Flush(Stream stream) { var fileStream = stream as FileStream; fileStream.Flush(); } + /// + /// Closes the given stream + /// + /// The stream to close public void CloseFile(Stream stream) { var fileStream = stream as FileStream; fileStream.Dispose(); } + /// + /// Checks whether the given file exist + /// + /// The file to check + /// + /// true if the caller has the required permissions and path contains the name of an existing file, otherwise, false + /// + /// + /// https://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx + /// public bool IsFileExist(String fileName) { return File.Exists(fileName); } + /// + /// Checks whether the given file ready + /// + /// The file to check + /// + /// true if the file is ready to open, otherwise, false + /// + /// + /// https://msdn.microsoft.com/en-us/library/y973b725(v=vs.110).aspx + /// public bool IsFileReady(String fileName) { try { using (FileStream inputStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.None)) { - if (inputStream.Length > 0) - { - return true; - } - else - { - return false; - } + return (inputStream.Length > 0) ? true : false; } } catch (Exception) diff --git a/LibTVRefCommonTizen/Ports/FileSystemWatcherPort.cs b/LibTVRefCommonTizen/Ports/FileSystemWatcherPort.cs index 8a139a5..b1dc3d5 100755 --- a/LibTVRefCommonTizen/Ports/FileSystemWatcherPort.cs +++ b/LibTVRefCommonTizen/Ports/FileSystemWatcherPort.cs @@ -22,12 +22,22 @@ using LibTVRefCommonPortable.DataModels; namespace LibTVRefCommonTizen.Ports { + /// + /// Handles FileSystemWatcher APIs + /// public class FileSystemWatcherPort : IFileSystemWatcherAPIs { static FileSystemWatcher watcher; public event EventHandler CustomChanged; private FileSystemEventCustomArgs args; + /// + /// Listens to the file system change notifications and raises events when a directory, or file in a directory, changes + /// If the 'pinned_apps_info.xml' is created, changed, or deleted, invokes event handler method + /// + /// + /// https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx + /// public void Run() { watcher = new FileSystemWatcher(); @@ -42,6 +52,14 @@ namespace LibTVRefCommonTizen.Ports watcher.EnableRaisingEvents = true; } + /// + /// Represents the method that will handle the Changed, Created, or Deleted event of a FileSystemWatcher class + /// + /// The source of the event + /// The FileSystemEventArgs that contains the event data + /// + /// https://msdn.microsoft.com/en-us/library/system.io.filesystemeventhandler(v=vs.110).aspx + /// private void WatcherChanged(object sender, FileSystemEventArgs e) { args = new FileSystemEventCustomArgs((WatcherType)e.ChangeType, e.FullPath, e.Name); diff --git a/LibTVRefCommonTizen/Ports/PackageManagerPort.cs b/LibTVRefCommonTizen/Ports/PackageManagerPort.cs index 7ee5260..4679071 100644 --- a/LibTVRefCommonTizen/Ports/PackageManagerPort.cs +++ b/LibTVRefCommonTizen/Ports/PackageManagerPort.cs @@ -18,9 +18,13 @@ using System.Collections.Generic; using Tizen.Applications; using LibTVRefCommonPortable.Utils; +using System; namespace LibTVRefCommonTizen.Ports { + /// + /// Handles PackageManager APIs + /// public class PackageManagerPort : IPackageManager { private static IPlatformNotification Notification @@ -29,11 +33,18 @@ namespace LibTVRefCommonTizen.Ports set; } + /// + /// The constructor for this class + /// public PackageManagerPort() { } + /// + /// Registers a callback function to be invoked when the package is installed or uninstalled + /// + /// public static void RegisterCallbacks(IPlatformNotification app) { Notification = app; @@ -41,13 +52,22 @@ namespace LibTVRefCommonTizen.Ports PackageManager.UninstallProgressChanged += PackageManager_UninstallProgressChanged; } - public static void DeregisterCallbacks() + /// + /// Unregisters the callback function + /// + public static void UnregisterCallbacks() { Notification = null; PackageManager.InstallProgressChanged -= PackageManager_InstallProgressChanged; PackageManager.UninstallProgressChanged -= PackageManager_UninstallProgressChanged; } + /// + /// UninstallProgressChanged event + /// This event is occurred when a package is getting uninstalled and the progress of the request to the package manager changes + /// + /// The source of the event + /// An object that contains no event data private static void PackageManager_UninstallProgressChanged(object sender, PackageManagerEventArgs e) { if (e.State == PackageEventState.Completed) @@ -59,6 +79,12 @@ namespace LibTVRefCommonTizen.Ports } } + /// + /// InstallProgressChanged event + /// This event is occurred when a package is getting installed and the progress of the request to the package manager changes + /// + /// The source of the event + /// An object that contains no event data private static void PackageManager_InstallProgressChanged(object sender, PackageManagerEventArgs e) { if (e.State == PackageEventState.Completed) @@ -70,6 +96,10 @@ namespace LibTVRefCommonTizen.Ports } } + /// + /// Retrieves package information of all installed packages + /// + /// The list of packages. public Dictionary GetPackageList() { Dictionary pkgList = new Dictionary(); @@ -79,14 +109,13 @@ namespace LibTVRefCommonTizen.Ports foreach (var item in packages) { - if (item.Label == null || - item.Id == null) + if (item.Id == null) { continue; } result = new string[3]; - result[0] = item.Label; + result[0] = (item.Label == null || item.Label.Length <= 0) ? "No Name" : item.Label; result[1] = item.Id; result[2] = (System.IO.File.Exists(item.IconPath)) ? item.IconPath : "AppIcon.png"; @@ -96,34 +125,68 @@ namespace LibTVRefCommonTizen.Ports return pkgList; } - public string GetPackage(string PkgID) + /// + /// Gets the package information for the given package + /// + /// The ID of the package + /// The package name for the given package ID + public string GetPackage(string pkgID) { - Package tempItem = PackageManager.GetPackage(PkgID); + try + { + Package tempItem = PackageManager.GetPackage(pkgID); + + return tempItem.Label; + } + catch (Exception e) + { + DebuggingUtils.Err("Failed to get package information(" + pkgID + ") : " + e.Message); - return (tempItem != null) ? tempItem.Label : null; + return null; + } } + /// + /// Uninstalls package with the given package + /// + /// The ID of the package to be uninstalled + /// Returns true if uninstalltion request is successful, false otherwise public bool UninstallPackage(string pkgID) { - Package tempItem = PackageManager.GetPackage(pkgID); - if (tempItem == null) + try + { + Package tempItem = PackageManager.GetPackage(pkgID); + + return PackageManager.Uninstall(tempItem.Id, tempItem.PackageType); + } + catch (Exception e) { + DebuggingUtils.Err("Failed to get package information(" + pkgID + ") : " + e.Message); + return false; } - return PackageManager.Uninstall(tempItem.Id, tempItem.PackageType); } + /// + /// Uninstalls package with the given app ID + /// + /// The app ID to be uninstalled< + /// Returns true if uninstallation request is successful, false otherwise public bool UninstallPackageByAppID(string appID) { - string pkgID = PackageManager.GetPackageIdByApplicationId(appID); - if (pkgID == null || - pkgID.Length == 0) + try { - return false; + string pkgID = PackageManager.GetPackageIdByApplicationId(appID); + + return UninstallPackage(pkgID); } + catch (Exception e) + { + DebuggingUtils.Err("Failed to uninstall by AppID(" + appID + ") : " + e.Message); - return UninstallPackage(pkgID); + return false; + } } } } \ No newline at end of file diff --git a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs index 3abc9a7..6d9a57e 100644 --- a/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs +++ b/TVApps/TVApps.TizenTV/TVApps.TizenTV.cs @@ -85,7 +85,7 @@ namespace TVApps.TizenTV base.OnTerminate(); notification = null; - PackageManagerPort.DeregisterCallbacks(); + PackageManagerPort.UnregisterCallbacks(); MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformBackButtonName); MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName); diff --git a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs index b88fe17..4f4ea25 100755 --- a/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs +++ b/TVHome/TVHome.TizenTV/TVHome.TizenTV.cs @@ -93,7 +93,7 @@ namespace TVHome.TizenTV base.OnTerminate(); notification = null; - PackageManagerPort.DeregisterCallbacks(); + PackageManagerPort.UnregisterCallbacks(); MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformHomeButtonName); MainWindow.KeyUngrab(ElmSharp.EvasKeyEventArgs.PlatformMenuButtonName); }