[STC] Add C# API wrapper for Stc CAPIs (#984)
authorLokesh kasana <47134215+lkasana@users.noreply.github.com>
Fri, 27 Sep 2019 06:00:56 +0000 (11:30 +0530)
committerWonYoung Choi <wy80.choi@samsung.com>
Fri, 27 Sep 2019 06:00:56 +0000 (15:00 +0900)
commitd079b363c1d8a28dc0937859e5293c9ceb99a435
tree5a8d140a1baa85d08567fdfa3eeece7c41fa7261
parent80b655ebf2b32980f84b367a1d4e570865702db2
[STC] Add C# API wrapper for Stc CAPIs (#984)

* Add C# API wrapper for Stc CAPIs

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Changes according to comments of STC PR

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Further changes done as per suggestions

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Change in Callback Delegate for network statistics

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Resolution of ACR review comments and Addition of Newly created and updated APIs

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Change in csproj file

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Resolution of PR review comments

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Resolution of Codacy warnings and PR comments.

Some properties are changed to methods, because  getters should not throw exceptions.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Removed GetTotalStatisticsAsync() as stc_get_total_stats API is deprecated.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Removed unused variable 'StcManagerImpl._getTotalStatsCb'

Left out in last commit: Removed GetTotalStatisticsAsync() as stc_get_total_stats API is deprecated

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Correction in descriptions of properties and methods

Removed exception throw comments of property getters.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Changed Handle storage from 'IntPtr' to 'Safehandle'

As per the comment of Mr. Wonyoung Choi on PR.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Add support to handle multiple requests for GetStatisticsAsync and GetAllStatisticsAsync.

The implementation is referenced from WiFi C# package and Microsoft documentation.
Callback delegates are now stored in map.
'Task' is not needed to be stored according to:
'https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions#variable-scope-in-lambda-expressions'

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Dispose infoHandle and ruleHandle properly (as managed resources)

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Made InterfaceType and TimePeriod of Rule as nullable type to replace the default Unknown value.

Decription of timePeriod is improved.
Getter and Setter methods 'InterfaceType and TimePeriod' are changed to properties.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Fix of build fail due to typecast in conditional expression

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Removed appId parameter(public) from StcRule class

GetStatisticsAsync() will receive appId as a separate parameter.

Signed-off-by: Lokesh <l.kasana@samsung.com>
*  Make pure C# StcRule class

Signed-off-by: Lokesh <l.kasana@samsung.com>
* 'Unknown' NetworkInterfaceType is now passed to app as 'Others' (uncategorized). Removed throw exception from this case.

Same is done with 'NetworkProtocolType' and 'NetworkProtocol'.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Rename 'StcRule' as 'StatisticsFilter' and 'rule' as 'filter'.

And, use of 'using' to release SafeFilterHandle after use.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Rename 'ProcessState' to 'ApplicationState'

And, make it a property.

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Rename files as per their class name:

'info' as 'statistics' and 'Rule' as 'filter'
Files:
renamed:    Tizen.Network.Stc/StcInfo.cs -> Tizen.Network.Stc/StcStatistics.cs
renamed:    Tizen.Network.Stc/StcRule.cs -> Tizen.Network.Stc/StcStatsFilter.cs

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Removed 'GetStatisticsAsync' and added public property for AppId in StatsFilter.

Now there is only one API to get Statistics and application specific statistics
will be provided if appId is set in filter.
Fix for this comment:
https://github.com/Samsung/TizenFX/pull/802/#discussion_r288860344

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Now, 'GetStatisticsAsync' is the only API to get statistics of one/many apps based on filter provided to it.

It internally used 'stc_get_all_stats' and 'stc_foreach_all_stats' CAPIs.
Incorporated:
1/ http://suprem.sec.samsung.net/jira/browse/ACR-1358
2/ https://review.tizen.org/gerrit/#/c/platform/core/connectivity/stc-manager/+/209639/
3/ https://review.tizen.org/gerrit/#/c/platform/core/connectivity/stc-manager/+/209617/
4/ https://review.tizen.org/gerrit/#/c/platform/core/api/smart-traffic-control/+/209616/

Signed-off-by: Lokesh <l.kasana@samsung.com>
* Corrected feature tag in public methods of 'StcManager'

Signed-off-by: Lokesh <l.kasana@samsung.com>
* [Fix] Conversion methods for DateTime to timestamp and vice-versa

Signed-off-by: Lokesh <l.kasana@samsung.com>
* [Fix] Use 'IntPtr' instead of 'SafeStatsHandle'

As the handle is receieved in callback, we have to use IntPtr(unmanaged).
While after we have cloned it, we used SafeStatsHandle(managed)
to destroy it.

Signed-off-by: Lokesh <l.kasana@samsung.com>
src/Tizen.Network.Stc/Interop/Interop.Libraries.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Interop/Interop.Stc.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc.csproj [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc.sln [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc/StcEnumerations.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc/StcError.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc/StcManager.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc/StcManagerImpl.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc/StcStatistics.cs [new file with mode: 0755]
src/Tizen.Network.Stc/Tizen.Network.Stc/StcStatsFilter.cs [new file with mode: 0755]