}
/// <summary>
- /// Sets content to the particular part of the widget, and the preserve old content will not be unset.
+ /// Sets content to the particular part of the widget, and the preserve old content will be deleted.
/// </summary>
/// <param name="part">The name of the particular part.</param>
/// <param name="content">The content.</param>
/// </summary>
/// <param name="part">The name of the particular part.</param>
/// <param name="content">The content.</param>
- /// <param name="preserveOldContent">true, preserve old content will be unset. false, preserve old content will not be unset.</param>
+ /// <param name="preserveOldContent">true, preserve old content will be unset and not be deleted. false, preserve old content will be deleted.</param>
/// <seealso cref="SetPartContent(string, EvasObject)"/>
/// <since_tizen> preview </since_tizen>
public virtual bool SetPartContent(string part, EvasObject content, bool preserveOldContent)
}
/// <summary>
- /// Sets content to the widget, and the preserve old content will not be unset.
+ /// Sets content to the widget, and the preserve old content will be deleted.
/// </summary>
/// <param name="content">The content.</param>
/// <seealso cref="SetContent(EvasObject, bool)"/>
/// Sets content to the widget.
/// </summary>
/// <param name="content">The content.</param>
- /// <param name="preserveOldContent">true, preserve old content will be unset. false, preserve old content will not be unset.</param>
+ /// <param name="preserveOldContent">true, preserve old content will be unset and not be deleted. false, preserve old content will be deleted.</param>
/// <seealso cref="SetContent(EvasObject)"/>
/// <since_tizen> preview </since_tizen>
public void SetContent(EvasObject content, bool preserveOldContent)
return Interop.Elementary.elm_object_part_content_get(RealHandle, part);
}
}
-}
\ No newline at end of file
+}
*/
using System;
-using Tizen;
+using System.IO;
+using Tizen.System;
namespace Tizen.Account.AccountManager
{
{
case AccountError.InvalidParameter:
{
- exp = new ArgumentException(msg + " Invalid Parameters Provided");
+ exp = new ArgumentException($"{msg} Invalid Parameters Provided");
break;
}
case AccountError.OutOfMemory:
{
- exp = new OutOfMemoryException(msg + " Out Of Memory");
+ exp = new OutOfMemoryException($"{msg} Out Of Memory");
break;
}
case AccountError.InvalidOperation:
{
- exp = new InvalidOperationException(msg + " Inavlid operation");
+ exp = new InvalidOperationException($"{msg} Inavlid operation");
break;
}
case AccountError.NoData:
{
- exp = new InvalidOperationException(msg + " Empty Data");
+ exp = new InvalidOperationException($"{msg} Empty Data");
break;
}
case AccountError.PermissionDenied:
{
- exp = new UnauthorizedAccessException(msg + " Permission Denied");
+ exp = new UnauthorizedAccessException($"{msg} Permission Denied");
break;
}
case AccountError.DBFailed:
{
- exp = new InvalidOperationException(msg + " DataBase Failed");
+ exp = new InvalidOperationException($"{msg} DataBase Failed");
break;
}
case AccountError.DBBusy:
{
- exp = new InvalidOperationException(msg + " DataBase Busy");
+ exp = new InvalidOperationException($"{msg} DataBase Busy");
break;
}
case AccountError.QuerySyntaxError:
{
- exp = new InvalidOperationException(msg + " Network Error");
+ exp = new InvalidOperationException($"{msg} Network Error");
break;
}
case AccountError.XMLFileNotFound:
{
- exp = new System.IO.FileNotFoundException(msg + " XML File not found");
+ exp = new FileNotFoundException($"{msg} XML File not found");
break;
}
case AccountError.XMLParseFailed:
{
- exp = new System.IO.InvalidDataException(msg + " XML parse error");
+ exp = new InvalidDataException($"{msg} XML parse error");
break;
}
return exp;
}
+
+ internal static bool IsAccountFeatureSupported()
+ {
+ return ((Information.TryGetValue("http://tizen.org/feature/account", out bool IsAccountSupported)) && IsAccountSupported);
+ }
+
+ internal static void CheckAccountFeature()
+ {
+ if (IsAccountFeatureSupported() == false)
+ {
+ Log.Warn(AccountErrorFactory.LogTag, "platform account feature is disabled");
+ throw new NotSupportedException("platform account feature is disabled");
+ }
+ }
}
}
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsAsync()
{
+ AccountErrorFactory.CheckAccountFeature();
+
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr data, IntPtr userdata) =>
{
- Account account = new Account(new SafeAccountHandle(data, true));
+ Account account = new Account(new SafeAccountHandle(data, false));
values.Add(account.AccountId);
account.Dispose();
return true;
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static Account GetAccountById(int accountId)
{
- Account account = Account.CreateAccount();
- SafeAccountHandle handle = account.SafeAccountHandle;
+ AccountErrorFactory.CheckAccountFeature();
- AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, ref handle);
+ AccountError err = (AccountError)Interop.Account.CreateUnmanagedHandle(out IntPtr handle);
+ if (err != AccountError.None)
+ {
+ Log.Warn(AccountErrorFactory.LogTag, "Failed to create handle");
+ throw AccountErrorFactory.CreateException(err, "Failed to create unmanaged handle");
+ }
+
+ SafeAccountHandle accountHandle = new SafeAccountHandle(handle, false);
+
+ AccountError res = (AccountError)Interop.AccountService.QueryAccountById(accountId, ref accountHandle);
if (res != AccountError.None)
{
throw AccountErrorFactory.CreateException(res, "Failed to get accounts from the database for account id: " + accountId);
}
- Account ref_account = new Account(handle);
-
+
+ Account ref_account = new Account(accountHandle);
+
return ref_account;
}
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<AccountProvider> GetAccountProviders()
{
+ AccountErrorFactory.CheckAccountFeature();
+
List<string> values = new List<string>();
List<AccountProvider> providers = new List<AccountProvider>();
Interop.AccountProvider.AccountProviderCallback accountCallback = (IntPtr handle, IntPtr data) =>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static AccountProvider GetAccountProviderByAppId(string appId)
{
+ AccountErrorFactory.CheckAccountFeature();
+
IntPtr handle;
Interop.AccountProvider.Create(out handle);
AccountError err = (AccountError)Interop.AccountService.GetAccountProviderByAppId(appId, out handle);
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<AccountProvider> GetAccountProvidersByFeature(string feature)
{
+ AccountErrorFactory.CheckAccountFeature();
+
List<string> values = new List<string>();
List<AccountProvider> providers = new List<AccountProvider>();
Interop.AccountProvider.AccountProviderCallback providerCallback = (IntPtr handle, IntPtr data) =>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static int AddAccount(Account account)
{
+ AccountErrorFactory.CheckAccountFeature();
+
if (account == null)
{
throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to AddAccount");
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void UpdateAccount(Account account)
{
+ AccountErrorFactory.CheckAccountFeature();
+
if (account == null)
{
throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to UpdateAccount");
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void DeleteAccount(Account account)
{
+ AccountErrorFactory.CheckAccountFeature();
+
if (account == null)
{
throw AccountErrorFactory.CreateException(AccountError.InvalidParameter, "Failed to DeleteAccount");
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void DeleteAccount(string userName, string packageName)
{
+ AccountErrorFactory.CheckAccountFeature();
+
AccountError err = (AccountError)Interop.AccountService.DeleteAccountByUser(userName, packageName);
if (err != AccountError.None)
{
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void DeleteAccount(string packageName)
{
+ AccountErrorFactory.CheckAccountFeature();
+
AccountError err = (AccountError)Interop.AccountService.DeleteAccountByPackage(packageName);
if (err != AccountError.None)
{
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsByUserName(string userName)
{
+ AccountErrorFactory.CheckAccountFeature();
+
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
{
- Account account = new Account(new SafeAccountHandle(handle, true));
+ Account account = new Account(new SafeAccountHandle(handle, false));
values.Add(account.AccountId);
account.Dispose();
return true;
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsByPackageName(string packageName)
{
+ AccountErrorFactory.CheckAccountFeature();
+
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
{
- Account account = new Account(new SafeAccountHandle(handle, true));
+ Account account = new Account(new SafeAccountHandle(handle, false));
values.Add(account.AccountId);
account.Dispose();
return true;
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static IEnumerable<Account> GetAccountsByCapabilityType(string type)
{
+ AccountErrorFactory.CheckAccountFeature();
+
List<Account> accounts = new List<Account>();
List<int> values = new List<int>();
Interop.Account.AccountCallback accountCallback = (IntPtr handle, IntPtr data) =>
{
- Account account = new Account(new SafeAccountHandle(handle, true));
+ Account account = new Account(new SafeAccountHandle(handle, false));
values.Add(account.AccountId);
account.Dispose();
return true;
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static Dictionary<string, CapabilityState> GetCapabilitiesById(int accountId)
{
+ AccountErrorFactory.CheckAccountFeature();
+
Dictionary<string, CapabilityState> capabilities = new Dictionary<string, CapabilityState>();
Interop.Account.AccountCapabilityCallback capabilityCallback = (string type, int capabilityState, IntPtr data) =>
{
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static int GetAccountsCount()
{
+ AccountErrorFactory.CheckAccountFeature();
+
int count = 0;
AccountError err = (AccountError)Interop.AccountService.GetAccountCount(out count);
if (err != AccountError.None)
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
public static void UpdateSyncStatusById(Account account, AccountSyncState status)
{
+ AccountErrorFactory.CheckAccountFeature();
+
AccountError err = (AccountError)Interop.AccountService.UpdateAccountSyncStatusById(account.AccountId, (int)status);
if (err != AccountError.None)
{
private static readonly Interop.AccountService.SubscribeCallback s_accountUpdatedCallback = (string eventType, int accountId, IntPtr userData) =>
{
+ AccountErrorFactory.CheckAccountFeature();
+
AccountSubscriberEventArgs eventArgs = new AccountSubscriberEventArgs(eventType, accountId);
s_accountUpdated?.Invoke(null, eventArgs);
return true;
{
add
{
+ AccountErrorFactory.CheckAccountFeature();
+
if (s_accountUpdated == null)
{
if (s_subscriberHandle == null)
remove
{
+ AccountErrorFactory.CheckAccountFeature();
+
s_accountUpdated -= value;
if (s_accountUpdated == null)
{