Add comments for LibTVRefCommonTizen
authorGeunsun, Lee <gs86.lee@samsung.com>
Wed, 29 Mar 2017 05:18:48 +0000 (14:18 +0900)
committerChulSeung Kim <charles0.kim@samsung.com>
Thu, 8 Jun 2017 09:34:51 +0000 (18:34 +0900)
Change-Id: Icbc66eaa4e3e6651069135d93f7ebf131ec940f7

LibTVRefCommonTizen/Ports/AppControlPort.cs
LibTVRefCommonTizen/Ports/ApplicationManagerPort.cs
LibTVRefCommonTizen/Ports/DbgPort.cs
LibTVRefCommonTizen/Ports/FileSystemPort.cs
LibTVRefCommonTizen/Ports/FileSystemWatcherPort.cs
LibTVRefCommonTizen/Ports/PackageManagerPort.cs
TVApps/TVApps.TizenTV/TVApps.TizenTV.cs
TVHome/TVHome.TizenTV/TVHome.TizenTV.cs

index d3762ae..51494a3 100644 (file)
@@ -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;
                 }
 
index 6610a01..59af18c 100644 (file)
@@ -100,8 +100,8 @@ namespace LibTVRefCommonTizen.Ports
         /// <summary>
         /// Gets the information of the specified application with the app ID
         /// </summary>
-        /// <param name="appID">The app Id you want to get</param>
-        /// <returns>The information of the installed applications</returns>
+        /// <param name="appID">The app Id to get</param>
+        /// <returns>The information of the installed application</returns>
         public Dictionary<string, string> GetInstalledApplication(string appID)
         {
             Dictionary<string, string> result = null;
index c530c5e..ebad4b3 100644 (file)
@@ -77,7 +77,7 @@ namespace LibTVRefCommonTizen.Ports
         }
 
         /// <summary>
-        ///Displays a dialog with a given message
+        /// Displays a dialog with a given message
         /// </summary>
         /// <param name="message"> A debugging message </param>
         public void Popup(string message)
index 5aa8db4..5d41d14 100644 (file)
  */
 
 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
 {
+    /// <summary>
+    /// Handles FileSystem APIs
+    /// </summary>
     public class FileSystemPort : IFileSystemAPIs
     {
+        /// <summary>
+        /// Opens the given file
+        /// </summary>
+        /// <param name="filePath">A relative or absolute path for the file that the current FileStream object will encapsulate</param>
+        /// <param name="mode">A constant that determines how to open or create the file</param>
+        /// <returns>A generic view of a sequence of bytes</returns>
         public Stream OpenFile(string filePath, UtilFileMode mode)
         {
             Stream fileStream = null;
@@ -45,37 +47,58 @@ namespace LibTVRefCommonTizen.Ports
             return fileStream;
         }
 
+        /// <summary>
+        /// Flushes the given steam
+        /// </summary>
+        /// <param name="stream">The stream to flush</param>
         public void Flush(Stream stream)
         {
             var fileStream = stream as FileStream;
             fileStream.Flush();
         }
 
+        /// <summary>
+        /// Closes the given stream
+        /// </summary>
+        /// <param name="stream">The stream to close</param>
         public void CloseFile(Stream stream)
         {
             var fileStream = stream as FileStream;
             fileStream.Dispose();
         }
 
+        /// <summary>
+        /// Checks whether the given file exist
+        /// </summary>
+        /// <param name="fileName">The file to check</param>
+        /// <returns>
+        /// true if the caller has the required permissions and path contains the name of an existing file, otherwise, false
+        /// </returns>
+        /// <remarks>
+        /// https://msdn.microsoft.com/en-us/library/system.io.file.exists(v=vs.110).aspx
+        /// </remarks>
         public bool IsFileExist(String fileName)
         {
             return File.Exists(fileName);
         }
 
+        /// <summary>
+        /// Checks whether the given file ready
+        /// </summary>
+        /// <param name="fileName">The file to check</param>
+        /// <returns>
+        /// true if the file is ready to open, otherwise, false
+        /// </returns>
+        /// <remarks>
+        /// https://msdn.microsoft.com/en-us/library/y973b725(v=vs.110).aspx
+        /// </remarks>
         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)
index 8a139a5..b1dc3d5 100755 (executable)
@@ -22,12 +22,22 @@ using LibTVRefCommonPortable.DataModels;
 
 namespace LibTVRefCommonTizen.Ports
 {
+    /// <summary>
+    /// Handles FileSystemWatcher APIs
+    /// </summary>
     public class FileSystemWatcherPort : IFileSystemWatcherAPIs
     {
         static FileSystemWatcher watcher;
         public event EventHandler<EventArgs> CustomChanged;
         private FileSystemEventCustomArgs args;
 
+        /// <summary>
+        /// 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
+        /// </summary>
+        /// <remarks>
+        /// https://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx
+        /// </remarks>
         public void Run()
         {
             watcher = new FileSystemWatcher();
@@ -42,6 +52,14 @@ namespace LibTVRefCommonTizen.Ports
             watcher.EnableRaisingEvents = true;
         }
 
+        /// <summary>
+        /// Represents the method that will handle the Changed, Created, or Deleted event of a FileSystemWatcher class
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">The FileSystemEventArgs that contains the event data</param>
+        /// <remarks>
+        /// https://msdn.microsoft.com/en-us/library/system.io.filesystemeventhandler(v=vs.110).aspx
+        /// </remarks>
         private void WatcherChanged(object sender, FileSystemEventArgs e)
         {
             args = new FileSystemEventCustomArgs((WatcherType)e.ChangeType, e.FullPath, e.Name);
index 7ee5260..4679071 100644 (file)
@@ -18,9 +18,13 @@ using System.Collections.Generic;
 using Tizen.Applications;
 
 using LibTVRefCommonPortable.Utils;
+using System;
 
 namespace LibTVRefCommonTizen.Ports
 {
+    /// <summary>
+    /// Handles PackageManager APIs
+    /// </summary>
     public class PackageManagerPort : IPackageManager
     {
         private static IPlatformNotification Notification
@@ -29,11 +33,18 @@ namespace LibTVRefCommonTizen.Ports
             set;
         }
 
+        /// <summary>
+        /// The constructor for this class
+        /// </summary>
         public PackageManagerPort()
         {
 
         }
 
+        /// <summary>
+        /// Registers a callback function to be invoked when the package is installed or uninstalled
+        /// </summary>
+        /// <param name="app"></param>
         public static void RegisterCallbacks(IPlatformNotification app)
         {
             Notification = app;
@@ -41,13 +52,22 @@ namespace LibTVRefCommonTizen.Ports
             PackageManager.UninstallProgressChanged += PackageManager_UninstallProgressChanged;
         }
 
-        public static void DeregisterCallbacks()
+        /// <summary>
+        /// Unregisters the callback function
+        /// </summary>
+        public static void UnregisterCallbacks()
         {
             Notification = null;
             PackageManager.InstallProgressChanged -= PackageManager_InstallProgressChanged;
             PackageManager.UninstallProgressChanged -= PackageManager_UninstallProgressChanged;
         }
 
+        /// <summary>
+        /// UninstallProgressChanged event
+        /// This event is occurred when a package is getting uninstalled and the progress of the request to the package manager changes
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">An object that contains no event data</param>
         private static void PackageManager_UninstallProgressChanged(object sender, PackageManagerEventArgs e)
         {
             if (e.State == PackageEventState.Completed)
@@ -59,6 +79,12 @@ namespace LibTVRefCommonTizen.Ports
             }
         }
 
+        /// <summary>
+        /// InstallProgressChanged event
+        /// This event is occurred when a package is getting installed and the progress of the request to the package manager changes
+        /// </summary>
+        /// <param name="sender">The source of the event</param>
+        /// <param name="e">An object that contains no event data</param>
         private static void PackageManager_InstallProgressChanged(object sender, PackageManagerEventArgs e)
         {
             if (e.State == PackageEventState.Completed)
@@ -70,6 +96,10 @@ namespace LibTVRefCommonTizen.Ports
             }
         }
 
+        /// <summary>
+        /// Retrieves package information of all installed packages
+        /// </summary>
+        /// <returns>The list of packages.</returns>
         public Dictionary<string, string[]> GetPackageList()
         {
             Dictionary<string, string[]> pkgList = new Dictionary<string, string[]>();
@@ -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)
+        /// <summary>
+        /// Gets the package information for the given package
+        /// </summary>
+        /// <param name="pkgID">The ID of the package</param>
+        /// <returns>The package name for the given package ID</returns>
+        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;
+            }
         }
 
+        /// <summary>
+        /// Uninstalls package with the given package
+        /// </summary>
+        /// <param name="pkgID">The ID of the package to be uninstalled</param>
+        /// <returns>Returns true if uninstalltion request is successful, false otherwise</returns>
         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);
         }
 
+        /// <summary>
+        /// Uninstalls package with the given  app ID
+        /// </summary>
+        /// <param name="appID">The app ID to be uninstalled<</param>
+        /// <returns>Returns true if uninstallation request is successful, false otherwise</returns>
         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
index 3abc9a7..6d9a57e 100644 (file)
@@ -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);
 
index b88fe17..4f4ea25 100755 (executable)
@@ -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);
         }