2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
21 /// Interop for Account class APIs
23 /// <since_tizen> 3 </since_tizen>
24 internal static partial class Interop
27 /// Interop for Account class APIs
29 /// <since_tizen> 3 </since_tizen>
30 internal static partial class AccountService
32 [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_to_db_by_id", CallingConvention = CallingConvention.Cdecl)]
33 internal static extern int UpdateAccountToDBById(IntPtr handle, int id);
35 [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_to_db_by_user_name", CallingConvention = CallingConvention.Cdecl)]
36 internal static extern int UpdateAccountToDBByUserName(IntPtr handle, string userName, string packageName);
38 [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_account_id", CallingConvention = CallingConvention.Cdecl)]
39 internal static extern int QueryAccountById(int accountId, out IntPtr handle);
41 [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_user_name", CallingConvention = CallingConvention.Cdecl)]
42 internal static extern int QueryAccountByUserName(Interop.Account.AccountCallback callback, string userName, IntPtr userData);
44 [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_package_name", CallingConvention = CallingConvention.Cdecl)]
45 internal static extern int QueryAccountByPackageName(Interop.Account.AccountCallback callback, string packageName, IntPtr userData);
47 [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_capability_by_account_id", CallingConvention = CallingConvention.Cdecl)]
48 internal static extern int QueryAccountCapabilityById(Interop.Account.AccountCapabilityCallback callback, int accoutId, IntPtr data);
50 [DllImport(Libraries.AccountSvc, EntryPoint = "account_update_sync_status_by_id", CallingConvention = CallingConvention.Cdecl)]
51 internal static extern int UpdateAccountSyncStatusById(int accoutId, int status);
53 [DllImport(Libraries.AccountSvc, EntryPoint = "account_insert_to_db", CallingConvention = CallingConvention.Cdecl)]
54 internal static extern int AddAccount(IntPtr handle, out int accountId);
56 [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_id", CallingConvention = CallingConvention.Cdecl)]
57 internal static extern int DeleteAccountById(int accountId);
59 [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_user_name", CallingConvention = CallingConvention.Cdecl)]
60 internal static extern int DeleteAccountByUser(string userName, string packageName);
62 [DllImport(Libraries.AccountSvc, EntryPoint = "account_delete_from_db_by_package_name", CallingConvention = CallingConvention.Cdecl)]
63 internal static extern int DeleteAccountByPackage(string packageName);
65 [DllImport(Libraries.AccountSvc, EntryPoint = "account_get_total_count_from_db", CallingConvention = CallingConvention.Cdecl)]
66 internal static extern int GetAccountCount(out int count);
68 [DllImport(Libraries.AccountSvc, EntryPoint = "account_foreach_account_from_db")]
69 internal static extern int AccountForeachAccountFromDb(Interop.Account.AccountCallback callback, IntPtr userData);
71 [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_capability")]
72 internal static extern int GetAccountByCapability(Interop.Account.AccountCallback callback, string capabilityType, int value, IntPtr userData);
74 [DllImport(Libraries.AccountSvc, EntryPoint = "account_query_account_by_capability_type")]
75 internal static extern int GetAccountByCapabilityType(Interop.Account.AccountCallback callback, string capabilityType, IntPtr userData);
77 [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_foreach_account_type_from_db")]
78 internal static extern int GetAllAccountproviders(Interop.AccountProvider.AccountProviderCallback callback, IntPtr userData);
80 [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_by_provider_feature")]
81 internal static extern int GetAccountProviderByFeature(Interop.AccountProvider.AccountProviderCallback callback, string key, IntPtr userData);
83 [DllImport(Libraries.AccountSvc, EntryPoint = "account_type_query_by_app_id")]
84 internal static extern int GetAccountProviderByAppId(string appId, out IntPtr handle);
86 [DllImport(Libraries.AccountSvc, EntryPoint = "account_subscribe_create")]
87 internal static extern int CreateAccountSubscriber(out Interop.AccountService.SafeAccountSubscriberHandle handle);
89 [DllImport(Libraries.AccountSvc, EntryPoint = "account_subscribe_notification")]
90 internal static extern int RegisterSubscriber(Interop.AccountService.SafeAccountSubscriberHandle handle, Interop.AccountService.SubscribeCallback callback, IntPtr userData);
92 [DllImport(Libraries.AccountSvc, EntryPoint = "account_unsubscribe_notification")]
93 internal static extern int UnregisterSubscriber(Interop.AccountService.SafeAccountSubscriberHandle handle);
96 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
97 internal delegate bool SubscribeCallback(string eventType, int accountId, IntPtr userData);
99 internal sealed class SafeAccountSubscriberHandle : SafeHandle
101 public SafeAccountSubscriberHandle()
102 : base(IntPtr.Zero, true)
106 public override bool IsInvalid
108 get { return this.handle == IntPtr.Zero; }
111 protected override bool ReleaseHandle()
113 this.SetHandle(IntPtr.Zero);