#include "..\script_component.hpp"

/*
 * Function: forge_client_phone_fnc_delEmail
 * Author: IDSolutions
 *
 * [Description]
 * Deletes an email from the address book.
 *
 * Arguments:
 * None
 *
 * Return Value:
 * None
 *
 * Example:
 * [] call forge_client_phone_fnc_delEmail;
 *
 * Public: Yes
 */

private _myDialog = findDisplay 202300;
private _ctrl01 = _myDialog displayCtrl 202302;

_myDialog displayRemoveEventHandler ["KeyDown", FORGE_DeleteMsg];

if (lbCurSel _ctrl01 == -1) exitWith {};

private _homeScreenBgBtns = [202202, 202203, 202204, 202205, 202206, 202207, 202208, 202209];
private _homeScreenBtns = [202310, 202311, 202312, 202313, 202314, 202315, 202316, 202317, 202318];
private _viewMessagesBtns = [202201, 2023001, 2023002, 2023003, 202302, 202305, 202306, 202307, 202308];

{ ctrlShow [_x, true]; ctrlEnable [_x, true]; } forEach _homeScreenBgBtns;
{ ctrlShow [_x, true]; ctrlEnable [_x, true]; } forEach _homeScreenBtns;
{ ctrlShow [_x, false] } forEach _viewMessagesBtns;
ctrlShow [202319, false];
ctrlEnable [202319, false];

// [player getVariable ["FORGE_Email", "unknown@spearnet.mil"], lbCurSel _ctrl01] remoteExec ["db_fnc_listrem", 2, false];
// ["listrem", player getVariable ["FORGE_Email", "unknown@spearnet.mil"], "", lbCurSel _ctrl01, [], "", false] spawn dragonfly_db_fnc_addTask;
["listrem", player getVariable ["FORGE_Email", "unknown@spearnet.mil"], "", lbCurSel _ctrl01, [], "", false] remoteExec ["dragonfly_db_fnc_addTask", 2, false];

uiSleep 1;

// [player getVariable ["FORGE_Email", "unknown@spearnet.mil"], player, "forge_client_phone_fnc_addEmail", true] remoteExec ["db_fnc_listload", 2, false];
// ["listrng", player getVariable ["FORGE_Email", "unknown@spearnet.mil"], "", -1, [], "forge_client_phone_fnc_addEmail", true] spawn dragonfly_db_fnc_addTask;
["listrng", player getVariable ["FORGE_Email", "unknown@spearnet.mil"], "", -1, [], "forge_client_phone_fnc_addEmail", true, netId player] remoteExec ["dragonfly_db_fnc_addTask", 2, false];