using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;



namespace INT_PT002.Part11_UserManager
{
    public partial class UserManager
    {
        private const string PathDll = "SD Card\\Run\\DllUserMgr.dll";

        private delegate void fnUserMgrDebugCB(int level, StringBuilder pMessage);
        private static fnUserMgrDebugCB fnUserMgrDebugCallBack;

        private delegate void fnUserMgrNewUserCB(IntPtr pBuffer);
        private static fnUserMgrNewUserCB fnUserMgrNewUserCallBack;

        private delegate void fnUserMgrAddUserCB(ref UserMgr_user_add_t user_add);
        private static fnUserMgrAddUserCB fnUserMgrAddUserCallBack;

        private delegate void fnUserMgrModifyUserCB(ref UserMgr_user_modify_t user_mod);
        private static fnUserMgrModifyUserCB fnUserMgrModifyUserCallBack;

        private delegate void fnUserMgrModifyInfoCB(ref UserMgr_user_info_t user_info);
        private static fnUserMgrModifyInfoCB fnUserMgrModifyInfoCallBack;

        private delegate void fnUserMgrDelUserCB(ref UserMgr_user_del_t user_del);
        private static fnUserMgrDelUserCB fnUserMgrDelUserCallBack;

        private delegate void fnUserMgrUserLockCB(ref UserMgr_user_lock_t user_lock);
        private static fnUserMgrUserLockCB fnUserMgrUserLockCallBack;

        private delegate void fnUserMgrDefaultSettingCB(int status);
        private static fnUserMgrDefaultSettingCB fnUserMgrDefaultSettingCallBack;

        private delegate void fnUserMgrLoginCB(int status, IntPtr pBuffer);
        private static fnUserMgrLoginCB fnUserMgrLoginCallBack;

        private delegate void fnUserMgrLogoutCB(int status);
        private static fnUserMgrLogoutCB fnUserMgrLogoutCallBack;

        private delegate void fnUserMgrLoginTimeoutCB(ref UserMgr_login_timeout_t timeout);
        private static fnUserMgrLoginTimeoutCB fnUserMgrLoginTimeoutCallBack;

        private delegate void fnUserMgrGetListCB(ref UserMgr_user_list_t user_list);
        private static fnUserMgrGetListCB fnUserMgrGetListCallBack;

        private delegate void fnUserMgrGetListNameCB(ref UserMgr_user_list_name_t user_name);
        private static fnUserMgrGetListNameCB fnUsermgrGetListNameCallBack;


        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_DebugCB(fnUserMgrDebugCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_NewStatusCB(fnUserMgrNewUserCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_AddStatusCB(fnUserMgrAddUserCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_ModifyUserCB(fnUserMgrModifyUserCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_ModifyStatusCB(fnUserMgrModifyInfoCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_DelStatusCB(fnUserMgrDelUserCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_UserLockCB(fnUserMgrUserLockCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_DefaultSettingCB(fnUserMgrDefaultSettingCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_LoginStausCB(fnUserMgrLoginCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_LogoutStausCB(fnUserMgrLogoutCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_LoginTimeoutCB(fnUserMgrLoginTimeoutCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_GetListCB(fnUserMgrGetListCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Register_GetListNameCB(fnUserMgrGetListNameCB func);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_HelloWorld();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Activation();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern void DLL_UserMgr_Deactivation();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserNew(IntPtr user_id, IntPtr user_pw, int fadmin, int expire_pw, int expire_account, IntPtr menuId);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserAdd(IntPtr user_id, IntPtr user_pw, int fadmin, int expire_pw, int expire_account, DateTime_t dateRegister, DateTime_t dateLogin);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserAddHistoryPW(IntPtr user_id, IntPtr user_pw);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserResetHistoryPW(IntPtr user_id);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserModify(IntPtr user_id, IntPtr user_pw, int fadmin, int expire_pw, int expire_account, IntPtr menuId);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserModifyPW(IntPtr user_id, IntPtr user_pw);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserModifyID(IntPtr user_org_id, IntPtr user_new_id);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserModifyOthers(IntPtr user_id, int fadmin, int expire_pw, int expire_account);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserDel(IntPtr user_id);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserAllDel_Default();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserLockRelease(IntPtr user_id, bool lock_account, bool lock_password);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserLockGet(IntPtr user_id);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserLoginCB(IntPtr user_id, IntPtr user_pw);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserLoginDirect(IntPtr user_id, IntPtr user_pw, ref UserMgr_user_info_t user_info);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_UserLogout();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_AutoLogoutTimeoutReset();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_AutoLogoutTimeoutPause();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_AutoLogoutSetTimeout(int timeout_min, int warning_timeout_sec);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_GetUserList(int index);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_GetUserListID(IntPtr user_id);

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_GetUserListName();

        [DllImport(PathDll, CallingConvention = CallingConvention.Winapi)]
        private static extern int DLL_UserMgr_SetFolder(IntPtr folder);
    }
}
