Resubmitting change:Added Null Checks and rearranging code
authormanish.r <manish.r@samsung.com>
Thu, 6 Oct 2016 04:15:58 +0000 (09:45 +0530)
committermanish.r <manish.r@samsung.com>
Thu, 6 Oct 2016 04:15:58 +0000 (09:45 +0530)
Change-Id: I39f3d227090157e1271c960a784cbaec95e93945
Signed-off-by: manish.r <manish.r@samsung.com>
Tizen.Telephony/Tizen.Telephony.Net45.csproj [changed mode: 0644->0755]
Tizen.Telephony/Tizen.Telephony.csproj
Tizen.Telephony/Tizen.Telephony/Call.cs
Tizen.Telephony/Tizen.Telephony/CallHandle.cs
Tizen.Telephony/Tizen.Telephony/ChangeNotificationEventArgs.cs
Tizen.Telephony/Tizen.Telephony/Modem.cs
Tizen.Telephony/Tizen.Telephony/Network.cs
Tizen.Telephony/Tizen.Telephony/Sim.cs
Tizen.Telephony/Tizen.Telephony/SlotHandle.cs
Tizen.Telephony/Tizen.Telephony/StateEventArgs.cs
Tizen.Telephony/Tizen.Telephony/Telephony.cs

old mode 100644 (file)
new mode 100755 (executable)
index bd56dd0..0c9f21e
@@ -1,71 +1,81 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
-  <PropertyGroup>\r
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
-    <ProjectGuid>{B0A02F90-8B02-4F35-AFD7-6A7EABD14A91}</ProjectGuid>\r
-    <OutputType>Library</OutputType>\r
-    <AppDesignerFolder>Properties</AppDesignerFolder>\r
-    <RootNamespace>Tizen.Telephony</RootNamespace>\r
-    <AssemblyName>Tizen.Telephony</AssemblyName>\r
-    <FileAlignment>512</FileAlignment>\r
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
-    <DebugSymbols>true</DebugSymbols>\r
-    <DebugType>full</DebugType>\r
-    <Optimize>false</Optimize>\r
-    <OutputPath>bin\Debug\Net45\</OutputPath>\r
-    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
-    <ErrorReport>prompt</ErrorReport>\r
-    <WarningLevel>4</WarningLevel>\r
-    <Prefer32Bit>false</Prefer32Bit>\r
-  </PropertyGroup>\r
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
-    <DebugType>pdbonly</DebugType>\r
-    <Optimize>true</Optimize>\r
-    <OutputPath>bin\Release\Net45\</OutputPath>\r
-    <DefineConstants>TRACE</DefineConstants>\r
-    <ErrorReport>prompt</ErrorReport>\r
-    <WarningLevel>4</WarningLevel>\r
-    <Prefer32Bit>false</Prefer32Bit>\r
-  </PropertyGroup>\r
-  <PropertyGroup>\r
-    <SignAssembly>true</SignAssembly>\r
-  </PropertyGroup>\r
-  <PropertyGroup>\r
-    <AssemblyOriginatorKeyFile>Tizen.Telephony.snk</AssemblyOriginatorKeyFile>\r
-  </PropertyGroup>\r
-  <ItemGroup>\r
-    <Compile Include="Interop\Interop.Libraries.cs" />\r
-    <Compile Include="Interop\Interop.Telephony.cs" />\r
-    <Compile Include="Interop\Interop.Call.cs" />\r
-    <Compile Include="Interop\Interop.Network.cs" />\r
-    <Compile Include="Interop\Interop.Modem.cs" />\r
-    <Compile Include="Interop\Interop.Sim.cs" />\r
-    <Compile Include="Properties\AssemblyInfo.cs" />\r
-    <Compile Include="Tizen.Telephony\CallHandle.cs" />\r
-    <Compile Include="Tizen.Telephony\Call.cs" />\r
-    <Compile Include="Tizen.Telephony\ChangeNotificationEventArgs.cs" />\r
-    <Compile Include="Tizen.Telephony\ExceptionFactory.cs" />\r
-    <Compile Include="Tizen.Telephony\Modem.cs" />\r
-    <Compile Include="Tizen.Telephony\Network.cs" />\r
-    <Compile Include="Tizen.Telephony\Sim.cs" />\r
-    <Compile Include="Tizen.Telephony\SlotHandle.cs" />\r
-    <Compile Include="Tizen.Telephony\StateEventArgs.cs" />\r
-    <Compile Include="Tizen.Telephony\Telephony.cs" />\r
-  </ItemGroup>\r
-  <ItemGroup>\r
-    <None Include="Tizen.Telephony.nuspec" />\r
-    <None Include="Tizen.Telephony.Net45.project.json" />\r
-    <None Include="Tizen.Telephony.snk" />\r
-  </ItemGroup>\r
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{E87B20AE-B752-4E64-9517-4827AC42A33A}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Tizen.Telephony</RootNamespace>
+    <AssemblyName>Tizen.Telephony</AssemblyName>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\Net45\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\Net45\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>Tizen.Telephony.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Interop\Interop.Libraries.cs" />
+    <Compile Include="Interop\Interop.Telephony.cs" />
+    <Compile Include="Interop\Interop.Call.cs" />
+    <Compile Include="Interop\Interop.Network.cs" />
+    <Compile Include="Interop\Interop.Modem.cs" />
+    <Compile Include="Interop\Interop.Sim.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Tizen.Telephony\CallHandle.cs" />
+    <Compile Include="Tizen.Telephony\Call.cs" />
+    <Compile Include="Tizen.Telephony\ChangeNotificationEventArgs.cs" />
+    <Compile Include="Tizen.Telephony\ExceptionFactory.cs" />
+    <Compile Include="Tizen.Telephony\Modem.cs" />
+    <Compile Include="Tizen.Telephony\Network.cs" />
+    <Compile Include="Tizen.Telephony\Sim.cs" />
+    <Compile Include="Tizen.Telephony\SlotHandle.cs" />
+    <Compile Include="Tizen.Telephony\StateEventArgs.cs" />
+    <Compile Include="Tizen.Telephony\Telephony.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Tizen.Telephony.nuspec" />
+    <None Include="Tizen.Telephony.Net45.project.json" />
+    <None Include="Tizen.Telephony.snk" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">
   </Target>
   <Target Name="AfterBuild">
   </Target>
-  -->\r
+  -->
 </Project>
\ No newline at end of file
index 8d5c062..494797f 100755 (executable)
     <None Include="Tizen.Telephony.project.json" />
     <None Include="Tizen.Telephony.snk" />
   </ItemGroup>
+  <ItemGroup />
+  <ItemGroup>
+    <Reference Include="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
        Other similar extension points exist, see Microsoft.Common.targets.
index c1317c1..f86a283 100755 (executable)
@@ -19,14 +19,28 @@ namespace Tizen.Telephony
     /// </summary>
     public class Call
     {
+        internal IntPtr _handle;
+        private List<IntPtr> _callHandle = new List<IntPtr>();
+        private List<CallHandle> _list = new List<CallHandle>();
+        private IntPtr _callList;
+        private Interop.Call.SafeCallList _safeCallList;
+
         /// <summary>
         /// Public Constructor
         /// </summary>
         /// <param name="handle">
         /// SlotHandle received in the Manager.Init API
         /// </param>
+        /// <exception cref="ArgumentNullException">
+        /// This exception occurs if handle provided is null
+        /// </exception>
         public Call(SlotHandle handle)
         {
+            if (handle == null)
+            {
+                throw new ArgumentNullException();
+            }
+
             _handle = handle._handle;
         }
 
@@ -64,6 +78,12 @@ namespace Tizen.Telephony
         /// <returns>
         /// List of CallHandle for existing calls.
         /// </returns>
+        /// <exception cref="InvalidOperationException">
+        /// This exception can occur due to one of the following reasons:
+        /// 1. Permission Denied
+        /// 2. Not Supported
+        /// 3. Operation Failed
+        /// </exception>
         public List<CallHandle> GetCallHandleList()
         {
             uint count;
@@ -73,26 +93,23 @@ namespace Tizen.Telephony
             if (error != TelephonyError.None)
             {
                 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallList Failed with error " + error);
-                return _list;
+                throw ExceptionFactory.CreateException(error);
             }
 
             _callHandle.Clear();
-            IntPtr[] handleArray = new IntPtr[count];
-            Marshal.Copy(_callList, handleArray, 0, (int)count);
-            foreach (IntPtr handle in handleArray)
+            if (count > 0)
             {
-                CallHandle info = new CallHandle(handle);
-                _list.Add(info);
-            }
+                IntPtr[] handleArray = new IntPtr[count];
+                Marshal.Copy(_callList, handleArray, 0, (int)count);
+                foreach (IntPtr handle in handleArray)
+                {
+                    CallHandle info = new CallHandle(handle);
+                    _list.Add(info);
+                }
 
-            _safeCallList = new Interop.Call.SafeCallList(_callList, count);
+                _safeCallList = new Interop.Call.SafeCallList(_callList, count);
+            }
             return _list;
         }
-
-        internal IntPtr _handle;
-        private List<IntPtr> _callHandle = new List<IntPtr>();
-        private List<CallHandle> _list = new List<CallHandle>();
-        private IntPtr _callList;
-        private Interop.Call.SafeCallList _safeCallList;
     }
 }
index fc2c2d1..6be7936 100755 (executable)
@@ -16,6 +16,8 @@ namespace Tizen.Telephony
     /// </summary>
     public class CallHandle
     {
+        private IntPtr _callHandle;
+
         /// <summary>
         /// Enumeration for the call status.
         /// </summary>
@@ -237,7 +239,5 @@ namespace Tizen.Telephony
         {
             _callHandle = handle;
         }
-
-        private IntPtr _callHandle;
     }
 }
index 3856f8a..bfc3703 100755 (executable)
@@ -14,6 +14,12 @@ namespace Tizen.Telephony
     /// </summary>
     public class ChangeNotificationEventArgs : EventArgs
     {
+        internal ChangeNotificationEventArgs(Notification noti, object data)
+        {
+            NotificationType = noti;
+            NotificationData = data;
+        }
+
         /// <summary>
         /// Enumeration for Telephony notification.
         /// </summary>
@@ -256,17 +262,19 @@ namespace Tizen.Telephony
         /// <summary>
         /// Telephony notification type
         /// </summary>
-        public Notification notificationType;
+        public Notification NotificationType
+        {
+            get;
+            internal set;
+        }
 
         /// <summary>
         /// Data as per the Notification type
         /// </summary>
-        public object notificationData;
-
-        internal ChangeNotificationEventArgs(Notification noti, object data)
+        public object NotificationData
         {
-            notificationType = noti;
-            notificationData = data;
+            get;
+            internal set;
         }
     }
 }
index 856aed8..23001b9 100755 (executable)
@@ -15,14 +15,24 @@ namespace Tizen.Telephony
     /// </summary>
     public class Modem
     {
+        internal IntPtr _handle;
+
         /// <summary>
         /// Modem Class Constructor
         /// </summary>
         /// <param name="handle">
         /// SlotHandle received in the Manager.Init API
         /// </param>
+        /// <exception cref="ArgumentNullException">
+        /// This exception occurs if handle provided is null
+        /// </exception>
         public Modem(SlotHandle handle)
         {
+            if (handle == null)
+            {
+                throw new ArgumentNullException();
+            }
+
             _handle = handle._handle;
         }
 
@@ -132,7 +142,5 @@ namespace Tizen.Telephony
             }
 
         }
-
-        internal IntPtr _handle;
     }
 }
index 45c6728..25cf220 100755 (executable)
@@ -15,6 +15,27 @@ namespace Tizen.Telephony
     /// </summary>
     public class Network
     {
+        internal IntPtr _handle;
+
+        /// <summary>
+        /// Network Class Constructor
+        /// </summary>
+        /// <param name="handle">
+        /// SlotHandle received in the Manager.Init API
+        /// </param>
+        /// <exception cref="ArgumentNullException">
+        /// This exception occurs if handle provided is null
+        /// </exception>
+        public Network(SlotHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            _handle = handle._handle;
+        }
+
         /// <summary>
         /// Enumeration for RSSI (Receive Signal Strength Indicator).
         /// Rssi6 indicates the highest strength.
@@ -253,17 +274,6 @@ namespace Tizen.Telephony
         }
 
         /// <summary>
-        /// Network Class Constructor
-        /// </summary>
-        /// <param name="handle">
-        /// SlotHandle received in the Manager.Init API
-        /// </param>
-        public Network(SlotHandle handle)
-        {
-            _handle = handle._handle;
-        }
-
-        /// <summary>
         /// Gets the LAC (Location Area Code) of the current location.
         /// </summary>
         /// <priviledge>
@@ -826,7 +836,5 @@ namespace Tizen.Telephony
                 return baseStationLongitude;
             }
         }
-
-        internal IntPtr _handle;
     }
 }
index 143e73f..242949a 100755 (executable)
@@ -16,6 +16,27 @@ namespace Tizen.Telephony
     /// </summary>
     public class Sim
     {
+        internal IntPtr _handle;
+
+        /// <summary>
+        /// Sim Class Constructor
+        /// </summary>
+        /// <param name="handle">
+        /// SlotHandle received in the Manager.Init API
+        /// </param>
+        /// <exception cref="ArgumentNullException">
+        /// This exception occurs if handle provided is null
+        /// </exception>
+        public Sim(SlotHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException();
+            }
+
+            _handle = handle._handle;
+        }
+
         /// <summary>
         /// Enumeration for the state of SIM card.
         /// </summary>
@@ -90,17 +111,6 @@ namespace Tizen.Telephony
         }
 
         /// <summary>
-        /// Sim Class Constructor
-        /// </summary>
-        /// <param name="handle">
-        /// SlotHandle received in the Manager.Init API
-        /// </param>
-        public Sim(SlotHandle handle)
-        {
-            _handle = handle._handle;
-        }
-
-        /// <summary>
         /// Gets the Integrated Circuit Card IDentification (ICC-ID).
         /// The Integrated Circuit Card Identification number internationally identifies SIM cards.
         /// </summary>
@@ -452,7 +462,5 @@ namespace Tizen.Telephony
                 return callForwardingIndicatorState;
             }
         }
-
-        internal IntPtr _handle;
     }
 }
index e19b4ab..8fb6a1d 100755 (executable)
@@ -14,12 +14,28 @@ namespace Tizen.Telephony
 {
     public class SlotHandle
     {
+        internal IntPtr _handle;
+        private List<Interop.Telephony.NotificationCallback> _changeNotificationList = new List<Interop.Telephony.NotificationCallback>();
+
+        internal SlotHandle(IntPtr handle)
+        {
+            _handle = handle;
+        }
+
         /// <summary>
         /// Event Handler for Receiving the Telephony State Changes
         /// this event will be triggered for the NotificationId's given in the SetNotificationId API
         /// </summary>
         public event EventHandler<ChangeNotificationEventArgs> ChangeNotification;
 
+        internal IntPtr Handle
+        {
+            get
+            {
+                return _handle;
+            }
+        }
+
         /// <summary>
         /// The Notification Id's for which the ChangeNotification event will be triggered
         /// </summary>
@@ -70,20 +86,6 @@ namespace Tizen.Telephony
             }
         }
 
-        internal SlotHandle(IntPtr handle)
-        {
-            _handle = handle;
-        }
-
-        internal IntPtr Handle
-        {
-            get
-            {
-                return _handle;
-            }
-        }
-
-        internal IntPtr _handle;
         private void SetCallback(ChangeNotificationEventArgs.Notification n)
         {
             Interop.Telephony.NotificationCallback NotificationDelegate = (IntPtr handle, ChangeNotificationEventArgs.Notification notiId, IntPtr data, IntPtr userData) =>
@@ -286,7 +288,5 @@ namespace Tizen.Telephony
                 throw e;
             }
         }
-
-        private List<Interop.Telephony.NotificationCallback> _changeNotificationList = new List<Interop.Telephony.NotificationCallback>();
     }
 }
index 3be5c31..9468bca 100755 (executable)
@@ -14,14 +14,18 @@ namespace Tizen.Telephony
     /// </summary>
     public class StateEventArgs : EventArgs
     {
+        internal StateEventArgs(State s)
+        {
+            CurrentState = s;
+        }
+
         /// <summary>
         /// The Current State
         /// </summary>
-        public State currentState;
-
-        internal StateEventArgs(State s)
+        public State CurrentState
         {
-            currentState = s;
+            get;
+            internal set;
         }
     }
 }
index 8093ed4..5e6b5ed 100755 (executable)
@@ -65,6 +65,16 @@ namespace Tizen.Telephony
     /// </summary>
     public static class Manager
     {
+        internal static List<SlotHandle> _telephonyHandle = new List<SlotHandle>();
+        private static HandleList _handleList;
+        private static bool _isInitialized = false;
+        private static event EventHandler<StateEventArgs> _stateChanged;
+        private static StateChangedCallback stateDelegate = delegate(State state, IntPtr userData)
+        {
+            StateEventArgs args = new StateEventArgs(state);
+            _stateChanged?.Invoke(null, args);
+        };
+
         /// <summary>
         /// Event Handler to be invoked when the telephony state changes.
         /// </summary>
@@ -103,6 +113,28 @@ namespace Tizen.Telephony
         }
 
         /// <summary>
+        /// Acquires the telephony state value.
+        /// </summary>
+        /// <returns>
+        /// The state value of telephony.
+        /// </returns>
+        public static State CurrentState
+        {
+            get
+            {
+                State state = State.NotReady;
+                TelephonyError error = Interop.Telephony.TelephonyGetState(out state);
+                if (error != TelephonyError.None)
+                {
+                    Tizen.Log.Error(Interop.Telephony.LogTag, "GetState Failed with Error " + error);
+                    return State.Unavailable;
+                }
+
+                return state;
+            }
+        }
+
+        /// <summary>
         /// Acquires the Number of available handles to use the telephony API.
         /// </summary>
         /// <returns>
@@ -145,7 +177,7 @@ namespace Tizen.Telephony
             }
 
             _isInitialized = true;
-            Tizen.Log.Info(Interop.Telephony.LogTag, "Returning the number of sims " + _handleList.Count);
+            //Tizen.Log.Info(Interop.Telephony.LogTag, "Returning the number of sims " + _handleList.Count);
             return _telephonyHandle;
         }
 
@@ -176,28 +208,6 @@ namespace Tizen.Telephony
             _telephonyHandle.Clear();
         }
 
-        /// <summary>
-        /// Acquires the telephony state value.
-        /// </summary>
-        /// <returns>
-        /// The state value of telephony.
-        /// </returns>
-        public static State CurrentState
-        {
-            get
-            {
-                State state = State.NotReady;
-                TelephonyError error = Interop.Telephony.TelephonyGetState(out state);
-                if (error != TelephonyError.None)
-                {
-                    Tizen.Log.Error(Interop.Telephony.LogTag, "GetState Failed with Error " + error);
-                    return State.Unavailable;
-                }
-
-                return state;
-            }
-        }
-
         internal static SlotHandle FindHandle(IntPtr handle)
         {
             SlotHandle temp = _telephonyHandle[0];
@@ -211,16 +221,5 @@ namespace Tizen.Telephony
 
             return temp;
         }
-
-        internal static List<SlotHandle> _telephonyHandle = new List<SlotHandle>();
-
-        private static StateChangedCallback stateDelegate = delegate(State state, IntPtr userData)
-        {
-            StateEventArgs args = new StateEventArgs(state);
-            _stateChanged?.Invoke(null, args);
-        };
-        private static HandleList _handleList;
-        private static bool _isInitialized = false;
-        private static event EventHandler<StateEventArgs> _stateChanged;
     }
 }