You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RnQ/RnQ/prefSheet.pas

3007 lines
89 KiB
Plaintext

{
This file is part of R&Q.
Under same license
}
unit prefSheet;
{$I RnQConfig.inc}
interface
uses
Winapi.Windows, System.SysUtils, System.Classes, System.Variants, System.IniFiles, Vcl.Forms,
RnQPrefsLib, PluginLib, RQThemes, RQUtil, ICQCommon,
SciterJS, SciterJSAPI, BaseWindow;
{$I PubRTTI.inc}
type
TCaps = array [0..15] of String;
TPrefsObj = record
profile_index, profile_proxy, profile_proxyport,
icq_birthremind, icq_inactinterval, icq_recentlyofflinedelay,
spam_ignoreuinvalue, spam_botattempts, spam_botquestion,
autoaway_setawaydelay, autoaway_setnadelay,
design_blinkspeed, design_clsort, design_uiaccent, design_clautosizedown, design_clbar,
design_clfilterbar, design_actopacity, design_inactopacity, design_avmaxsizeval,
chat_relhours, chat_reldays, chat_msgbuffer, chat_entercount, chat_maximgwidthval, chat_maximgheightval,
chat_chatimgquality, chat_previewsize, chat_videores, chat_spellcheckstyle, chat_scrformat,
tips_max, tips_space, tips_opacity, tips_position, tips_hindent, tips_vindent,
start_withstatus, start_withvis,
events_inoutdur, events_volume, events_bdinformdur, events_bdnotifydur,
autoupdate_period,
other_mwheelspeed, other_clautohideval, other_notinlist, other_browser, other_servertoupload: Integer;
profile_proxyauth, profile_proxyntlm,
net_auto, net_whenavailable, net_lostdlg, net_showtemp,
icq_savepass, icq_clearpass, icq_savetoken, icq_ident, icq_addcap,
icq_msgencrypt, icq_showtyping, icq_sendtyping, icq_recentlyoffline, icq_autoreqxstatus,
icq_enableavatars, icq_autoavatars, icq_failedavatars, icq_autoxstatus,
spam_warn, spam_ignoreunk, spam_ignoreunkauth, spam_zero, spam_ignoremult,
spam_ignoreunk2, spam_ignorenohist, spam_ignoreuin, spam_ignorebadwords, spam_botenable,
spam_botusequest, spam_ignorelist, spam_quietlist,
autoaway_setaway, autoaway_setna, autoaway_setnascreen, autoaway_setnaboss, autoaway_restore, autoaway_setxstatus,
design_clontop, design_uindelim, design_xbutton, //design_xmain,
design_trayclick, design_btips, design_blinkstatus, design_userthemes, design_snapwin, design_leveling, design_animwindows,
design_newsettings, design_onlineonly, design_showtip, design_unauthasoff, design_enablegroups,
design_indentgrp, design_collapsegrp, design_showborder, design_noborderwithshadow, design_clautosizeup, design_transpcl,
design_transpchat, design_avchat, design_avhints, design_avtray, design_avmaxsize, design_avtaskbarbtn, design_avusepalette,
chat_autocopy, chat_singlemsg, chat_tabstatus, chat_cursorquote, chat_quoteselected, chat_textformat,
chat_chatontop, chat_pluginsabove, chat_tabhints, chat_wrapinseparate, chat_closeonempty, chat_closetabonsingle,
chat_smoothrender, chat_msgtrim, chat_smartreplies, chat_reactions, chat_smilescaptions,
chat_inimg, chat_outimg, chat_maximgwidth, chat_maximgheight, chat_enablestickers,
chat_videothumbs, chat_spellcheck, chat_animatedscroll,
tips_transparency,
start_autoconnect, start_skipsplash, start_checkro, start_minimized, start_lock,
start_reopenchats, start_firstonly,
security_writehist, security_backup, security_askboss,
events_notinclosed, events_playsnd, events_awayisonline, events_inoutignore, events_skipseen, events_chatfocus,
events_infoontop, events_logpacketswin, events_logpacketsfile, events_logpacketsclear, events_logeventswin,
events_logeventsfile, events_logeventsclear, events_bdinform, events_bdnotify,
autoupdate_enable, autoupdate_beta, autoupdate_onlogin,
other_confirmexit, other_autolayout, other_vacuum, other_indialog,
other_clautohide, other_trimws, other_handleicqlinks: Boolean;
profile_name, profile_proxyhost, profile_proxyuser, profile_proxypasswd, icq_password,
spam_badwords, spam_question, spam_answers,
design_wintitle,
start_withuin, start_userpath,
themeedit_maincss, themeedit_chatcss, themeedit_contents,
other_mybrowser: String;
autoaway_xstatus: Byte;
icq_addedcap: TCaps;
icq_birthdate: TDateTime;
end;
TListItem = record
s0: String;
s1: TUID;
isSrv: Boolean;
end;
PLangItem = ^TLangItem;
TLangItem = record
lang: String;
locale: String;
end;
{$I NoRTTI.inc}
TPrefsMethods = class(TNativeMethods)
class procedure RegisterMethods(var ReturnValue: TSciterValue); override;
class procedure OnPrefsCreate(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure OnPrefsClose(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UpdatePrefsXY(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure SetViewMode(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure AddProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure DeleteProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure AddBotQuestion(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure DelBotQuestion(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure AddIgnoredContacts(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure AddIgnoredContactToSrv(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure RemoveIgnoredContactFromSrv(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure DelIgnoredContact(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure AddQuietContacts(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure DelQuietContact(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure StoreProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure StoreQuestion(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UpdateQuestions(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UpdateMainProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure OpenContactChat(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure ViewContactInfo(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure PrefsApply(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure PrefsReset(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure ResetPlugins(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure IsOnline(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure ApplyTransp(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure RefreshLangs(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure ManageLangs(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UserDicts(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure SetMainSpellcheckLang(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure TestTips(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure GetCurrentAccountPath(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure GetXStatusMsg(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure GetMainStyles(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure GetChatStyles(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure GetKeyName(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure HotkeySelect(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure HotkeyDefault(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure HotkeySave(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure HotkeyDelete(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UpdateEventTriggers(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure StoreEventTrigger(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UpdateDisabledEvents(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure StoreDisabledEvents(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure PlaySound(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure SoundTest(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure TimeTest(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure IsAudioPresent(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure IsMasterMuted(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure BASSWarning(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure ReloadPlugins(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure OpenPluginPrefs(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure UpdateThemeEditProp(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure AddThemeProp(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure CheckPath(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
class procedure HasMDLFont(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
end;
TPrefs = class(TBaseWindow)
public
ArrPages: array of TPrefPage;
ThemePropsIni: TMemIniFile;
themeprops: aTthemeproperty;
pluginList: array of TPlugin;
OnStatusDisableLocal: array of TOnStatusDisable;
constructor Create;
destructor Destroy; override;
function HasPrefPage(pidx: Byte): Boolean;
procedure SortPrefPages;
procedure RefreshLangList;
procedure ResetLangs;
procedure LoadThemeProps;
procedure SetThemeProps(const props: String; doUpdate: Boolean = False);
function GetThemeProps: String;
procedure InitConnection;
procedure InitChat;
procedure InitAutoaway;
procedure InitStart;
procedure InitHotkeys;
procedure InitEvents;
procedure InitThemeEdit;
procedure InitOther;
procedure Init;
procedure ResetConnection(ProfileOnly: Boolean = False);
procedure ResetICQ;
procedure ResetAntispam(QuestionsOnly: Boolean = False);
procedure ResetAutoaway;
procedure ResetDesign;
procedure ResetChat;
procedure ResetTips;
procedure ResetStart;
procedure ResetSecurity;
procedure ResetHotkeys;
procedure ResetEvents;
procedure ResetPlugins;
procedure ResetAutoupdate;
procedure ResetThemeEdit;
procedure ResetOther;
procedure Reset;
procedure SetViewMode(pages: array of TPrefPage);
procedure SetActivePage(i: Integer); overload;
procedure SetActivePage(const pn: String); overload;
procedure FinishLoading;
end;
implementation
uses
System.UITypes, System.Rtti, System.AnsiStrings, System.StrUtils, Vcl.Menus, Winapi.ShellAPI,
SciterLib, globalLib, utilLib, themesLib, iniLib, roasterLib,
RDGlobal, RDUtils, RnQGlobal, RnQSysUtils, RnQLangs, RnQNet, RnQTips, RnQMacros,
ICQSession, ICQConsts, ICQContacts, events,
HistAllSearch, Dynamic_Bass, MsSpellCheckLib_TLB, RnQGraphics32, SQLiteDB;
var
PrefsObj: TPrefsObj;
v_proxyes: TProxies;
qst: TQuestAnsArr;
tempBeh: Tbehaviours;
const
sb2index: array [TSortBy] of Integer = (0, 1, 2);
PrefIsShowBDFirst = 'is-show-bd-first';
PrefShowBDFirst = 'show-bd-first';
PrefIsShowBDBefore = 'is-show-bd-before';
PrefShowBDBefore = 'show-bd-before';
function ObjToPrefs(param: Pointer; const pkey: PSciterValue; const pval: PSciterValue): BOOL; stdcall;
function FileTimeToDateTime(FileTime: TFileTime): TDateTime;
var
ModifiedTime: TFileTime;
SystemTime: TSystemTime;
begin
Result := Now;
if (FileTime.dwLowDateTime = 0) and (FileTime.dwHighDateTime = 0) then
Exit;
try
FileTimeToLocalFileTime(FileTime, ModifiedTime);
FileTimeToSystemTime(ModifiedTime, SystemTime);
Result := SystemTimeToDateTime(SystemTime);
except end;
end;
var
keyStr: PWideChar;
tmpInt: Integer;
tmpInt64: Int64;
tmpFloat: Double;
tmpLen: Cardinal;
tmpBool: Bool;
tmpString: PWideChar;
// tmpDate: TDateTime;
tmpCaps: TValue;
tmpVal: TSciterValue;
field: TRttiField;
sz, i: UINT;
vtype: TSciterValueType;
begin
keyStr := '';
API.ValueStringData(pkey, keyStr, tmpLen);
field := TRTTIContext.Create.GetType(TypeInfo(TPrefsObj)).GetField(keyStr);
if not Assigned(field) then
begin
ODS('Field not found: ' + keyStr);
Result := True;
Exit;
end;
API.ValueType(pval, vtype, tmpLen);
if not (vtype = T_UNDEFINED) and not (vtype = T_NULL) then
if field.FieldType.TypeKind = tkInteger then
begin
if vtype = T_INT then
begin
tmpInt := 0;
API.ValueIntData(pval, tmpInt);
field.SetValue(@PrefsObj, tmpInt);
end else if vtype = T_STRING then
begin
tmpString := '';
API.ValueStringData(pval, tmpString, tmpLen);
field.SetValue(@PrefsObj, StrToInt(tmpString));
end else ODS('[INT] Format mismatch: ' + keyStr);
end else if field.FieldType.TypeKind = tkEnumeration then
begin
tmpInt := 0;
API.ValueIntData(pval, tmpInt);
tmpBool := tmpInt = 1;
field.SetValue(@PrefsObj, tmpBool);
if not (vtype = T_BOOL) then ODS('[BOOL] Format mismatch: ' + keyStr);
end else if field.FieldType.TypeKind = tkUString then
begin
if vtype = T_INT then
begin
tmpInt := 0;
API.ValueIntData(pval, tmpInt);
field.SetValue(@PrefsObj, IntToStr(tmpInt));
end else if vtype = T_STRING then
begin
tmpString := '';
API.ValueStringData(pval, tmpString, tmpLen);
field.SetValue(@PrefsObj, tmpString);
end else ODS('[STR] Format mismatch: ' + keyStr);
end else if field.FieldType.TypeKind = tkFloat then
begin
if vtype = T_FLOAT then
begin
tmpFloat := 0;
API.ValueFloatData(pval, tmpFloat);
field.SetValue(@PrefsObj, tmpFloat);
end else if vtype = T_DATE then
begin
tmpInt64 := 0;
API.ValueInt64Data(pval, tmpInt64);
field.SetValue(@PrefsObj, FileTimeToDateTime(TFileTime(tmpInt64)));
end else ODS('[FLOAT] Format mismatch: ' + keyStr + ' | ' + inttostr(integer(vtype)));
end else if field.FieldType.TypeKind = tkArray then
begin // caps array only for now
sz := 0;
if pval.t = UINT(T_OBJECT) then
API.ValueIsolate(pval);
API.ValueElementsCount(pval, sz);
if sz > 16 then
sz := 16;
TValue.Make(nil, TypeInfo(TCaps), tmpCaps);
for i := 0 to sz - 1 do
begin
tmpString := '00';
API.ValueInit(@tmpVal);
API.ValueNthElementValue(pval, i, tmpVal);
API.ValueStringData(@tmpVal, tmpString, tmpLen);
API.ValueClear(@tmpVal);
tmpCaps.SetArrayElement(i, TValue.From(tmpString));
end;
field.SetValue(@PrefsObj, tmpCaps);
end else
ODS('Pref of unknown type: ' + keyStr);
Result := True;
end;
class procedure TPrefsMethods.RegisterMethods(var ReturnValue: TSciterValue);
begin
AddMethod('OnPrefsCreate', OnPrefsCreate);
AddMethod('OnPrefsClose', OnPrefsClose);
AddMethod('UpdatePrefsXY', UpdatePrefsXY);
AddMethod('SetViewMode', SetViewMode);
AddMethod('AddProfile', AddProfile);
AddMethod('DeleteProfile', DeleteProfile);
AddMethod('AddBotQuestion', AddBotQuestion);
AddMethod('DelBotQuestion', DelBotQuestion);
AddMethod('AddIgnoredContacts', AddIgnoredContacts);
AddMethod('AddIgnoredContactToSrv', AddIgnoredContactToSrv);
AddMethod('RemoveIgnoredContactFromSrv', RemoveIgnoredContactFromSrv);
AddMethod('DelIgnoredContact', DelIgnoredContact);
AddMethod('AddQuietContacts', AddQuietContacts);
AddMethod('DelQuietContact', DelQuietContact);
AddMethod('StoreProfile', StoreProfile);
AddMethod('StoreQuestion', StoreQuestion);
AddMethod('UpdateQuestions', UpdateQuestions);
AddMethod('UpdateMainProfile', UpdateMainProfile);
AddMethod('OpenContactChat', OpenContactChat);
AddMethod('ViewContactInfo', ViewContactInfo);
AddMethod('PrefsApply', PrefsApply);
AddMethod('PrefsReset', PrefsReset);
AddMethod('ResetPlugins', ResetPlugins);
AddMethod('IsOnline', IsOnline);
AddMethod('ApplyTransparency', ApplyTransp);
AddMethod('RefreshLangs', RefreshLangs);
AddMethod('ManageLangs', ManageLangs);
AddMethod('UserDicts', UserDicts);
AddMethod('SetMainSpellcheckLang', SetMainSpellcheckLang);
AddMethod('TestTips', TestTips);
AddMethod('GetCurrentAccountPath', GetCurrentAccountPath);
AddMethod('GetXStatusMsg', GetXStatusMsg);
AddMethod('GetMainStyles', GetMainStyles);
AddMethod('GetChatStyles', GetChatStyles);
AddMethod('GetKeyName', GetKeyName);
AddMethod('HotkeySelect', HotkeySelect);
AddMethod('HotkeyDefault', HotkeyDefault);
AddMethod('HotkeySave', HotkeySave);
AddMethod('HotkeyDelete', HotkeyDelete);
AddMethod('UpdateEventTriggers', UpdateEventTriggers);
AddMethod('StoreEventTrigger', StoreEventTrigger);
AddMethod('UpdateDisabledEvents', UpdateDisabledEvents);
AddMethod('StoreDisabledEvents', StoreDisabledEvents);
AddMethod('PlaySound', PlaySound);
AddMethod('SoundTest', SoundTest);
AddMethod('TimeTest', TimeTest);
AddMethod('IsAudioPresent', IsAudioPresent);
AddMethod('IsMasterMuted', IsMasterMuted);
AddMethod('BASSWarning', BASSWarning);
AddMethod('ReloadPlugins', ReloadPlugins);
AddMethod('OpenPluginPrefs', OpenPluginPrefs);
AddMethod('UpdateThemeEditProp', UpdateThemeEditProp);
AddMethod('AddThemeProp', AddThemeProp);
AddMethod('CheckPath', CheckPath);
AddMethod('HasMDLFont', HasMDLFont);
inherited;
end;
class procedure TPrefsMethods.AddProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
i: Integer;
begin
i := Length(v_proxyes);
SetLength(v_proxyes, i + 1);
with v_proxyes[i] do
begin
name := getTranslation('Profile') + ' ' + IntToStr(i + 1);
addr.host := '';
addr.port := 1080;
proto := PP_NONE;
auth := False;
NTLM := False;
end;
CopyProxy(MainProxy, v_proxyes[i]);
UI.Prefs.ResetConnection(True);
end;
class procedure TPrefsMethods.DeleteProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
profile, i: Integer;
pr: array of TProxy;
begin
profile := 0;
API.ValueIntData(argv, profile);
if Length(v_proxyes) > 1 then
if Length(v_proxyes) = profile + 1 then
begin
ClearProxy(v_proxyes[Length(v_proxyes) - 1]);
SetLength(v_proxyes, Length(v_proxyes) - 1);
UI.Prefs.ResetConnection(True);
end
else
begin
SetLength(pr, Length(v_proxyes) - profile - 1);
for i := profile + 1 to Length(v_proxyes) - 1 do
pr[i - profile - 1] := v_proxyes[i];
SetLength(v_proxyes, Length(v_proxyes) - 1);
for i := profile to Length(v_proxyes) - 1 do
v_proxyes[i] := pr[i - profile];
UI.Prefs.ResetConnection(True);
end;
end;
class procedure TPrefsMethods.AddBotQuestion(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
i: Integer;
begin
i := Length(qst);
SetLength(qst, i + 1);
with qst[i] do
begin
q := '';
SetLength(a, 0);
end;
UI.Prefs.ResetAntispam(True);
end;
class procedure TPrefsMethods.DelBotQuestion(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
i, j: Integer;
begin
i := -1;
API.ValueIntData(argv, i);
if (Length(qst) = 0) or (i = -1) then
Exit;
for j := i + 1 to Length(qst) - 1 do
qst[j - 1] := qst[j];
SetLength(qst, Length(qst) - 1);
UI.Prefs.ResetAntispam(True);
end;
class procedure TPrefsMethods.AddIgnoredContacts(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Tmp: Variant;
UINs: TParams;
I: Integer;
Contact: TICQContact;
Item: TListItem;
begin
S2V(argv, Tmp);
UINs := Tmp;
for I := Low(UINs) to High(UINs) do
begin
Contact := Account.AccProto.GetContact(TUID(UINs[I]));
if Contact = nil then
// MsgDlg('You must select contact', mtInformation)
else if AddToIgnorelist(Contact, True) then
with UI.Prefs do
begin
Item.s0 := Contact.Displayed;
if not (Item.s0 = Contact.UID) then
Item.s0 := Item.s0 + ' (' + Contact.UIN2Show + ')';
Item.s1 := Contact.UID;
Item.isSrv := Account.AccProto.IsInList(LT_SPAM, Contact);
Call('addIgnoreListItem', [UI.RecordToVar(Item)]);
end;
end;
end;
class procedure TPrefsMethods.AddIgnoredContactToSrv(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
if (s = '') or not OnlFeature(Account.AccProto) then
Exit;
cnt := Account.AccProto.GetContact(s);
if Assigned(cnt) and Account.AccProto.IsOnline then
begin
Account.AccProto.AddToList(LT_SPAM, cnt);
// UI.Prefs.Call('setIgnoreListItemToSrv', [String(s)]);
end;
end;
class procedure TPrefsMethods.RemoveIgnoredContactFromSrv(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
if (s = '') or not OnlFeature(Account.AccProto) then
Exit;
cnt := Account.AccProto.GetContact(s);
if Assigned(cnt) and Account.AccProto.IsOnline then
begin
Account.AccProto.RemFromList(LT_SPAM, cnt);
// UI.Prefs.Call('setIgnoreListItemToSrv', [String(s)]);
end;
end;
class procedure TPrefsMethods.DelIgnoredContact(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
cnt := IgnoreList.get(s);
RemoveFromIgnorelist(cnt);
end;
class procedure TPrefsMethods.AddQuietContacts(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Tmp: Variant;
I: Integer;
UINs: TParams;
Contact: TICQContact;
Item: TListItem;
begin
S2V(argv, Tmp);
UINs := Tmp;
for I := Low(UINs) to High(UINs) do
begin
Contact := Account.AccProto.GetContact(TUID(UINs[I]));
if Contact = nil then
// MsgDlg('You must select contact', mtInformation)
else if AddToQuietlist(Contact) then
with UI.Prefs do
begin
Item.s0 := Contact.Displayed;
if not (Item.s0 = Contact.UID) then
Item.s0 := item.s0 + ' (' + Contact.UIN2Show + ')';
Item.s1 := Contact.UID;
Item.isSrv := False;
Call('addQuietListItem', [UI.RecordToVar(Item)]);
end;
end;
end;
class procedure TPrefsMethods.DelQuietContact(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
cnt := quietList.get(s);
removeFromQuietlist(cnt);
end;
procedure StoreProfileData(profile: Integer);
begin
with v_proxyes[profile], PrefsObj do
begin
name := profile_name;
proto := Tproxyproto(profile_proxy);
addr.host := profile_proxyhost;
addr.port := BoundInt(profile_proxyport, 0, 65535);
user := profile_proxyuser;
pwd := profile_proxypasswd;
auth := profile_proxyauth;
NTLM := profile_proxyntlm;
end;
end;
procedure StoreQuestionData(lastqst: Integer);
var
answ: TStringList;
i: Integer;
begin
if (lastqst >= Low(qst)) and (lastqst <= High(qst)) then
with qst[lastqst], PrefsObj do
begin
q := spam_question;
SetLength(a, 0);
answ := TStringList.Create;
answ.Text := spam_answers;
for i := 0 to answ.Count - 1 do
if not (Trim(answ.Strings[i]) = '') then
a := a + [Trim(answ.Strings[i])];
answ.Free;
end;
end;
class procedure TPrefsMethods.StoreProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
profile: Integer;
begin
if argc = 2 then
begin
PrefsObj := Default(TPrefsObj);
API.ValueEnumElements(argv, @ObjToPrefs, nil);
Inc(argv);
profile := 0;
API.ValueIntData(argv, profile);
StoreProfileData(profile);
end;
end;
class procedure TPrefsMethods.StoreQuestion(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
lastqst: Integer;
begin
if argc = 2 then
begin
PrefsObj := Default(TPrefsObj);
API.ValueEnumElements(argv, @ObjToPrefs, nil);
lastqst := 0;
Inc(argv);
API.ValueIntData(argv, lastqst);
StoreQuestionData(lastqst);
end;
end;
class procedure TPrefsMethods.UpdateQuestions(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
UI.Prefs.ResetAntispam(True);
end;
class procedure TPrefsMethods.UpdateMainProfile(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
last: Integer;
begin
if argc = 0 then
Exit;
last := 0;
API.ValueIntData(argv, last);
CopyProxy(MainProxy, v_proxyes[last]);
UI.Prefs.ResetConnection(True);
end;
class procedure TPrefsMethods.OpenContactChat(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
if Assigned(UI.Chat) then
UI.Chat.OpenOn(Account.AccProto.GetContact(s));
end;
class procedure TPrefsMethods.ViewContactInfo(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
cnt := Account.AccProto.GetContact(s);
if Assigned(cnt) then
cnt.ViewInfo;
end;
class procedure TPrefsMethods.PrefsApply(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
function HexArr2Str(const caps: TCaps): String;
var
I, L: Integer;
begin
Result := '';
for L := 15 downto 0 do
if (caps[L] = '') or (caps[L] = '00') or (caps[L] = '0') or (caps[L] = #00) then else
Break;
for I := 0 to L do
if (caps[I] = '') or (caps[I] = '00') or (caps[I] = '0') or (caps[I] = #00) then
Result := Result + '20'
else
Result := Result + caps[i];
if Length(Result) < 32 then
for I := Length(Result) to 31 do
Result := Result + '00';
end;
function index2sb(i: Integer): TSortBy;
begin
Result := Low(TSortBy);
while Result <= High(TsortBy) do
if i = sb2index[Result] then
Exit
else
Inc(Result);
Result := SB_EVENT;
end;
var
i, j, k, profile, question, errClr, accentClr: Integer;
icq: TICQSession;
cnt: TICQContact;
MustUpdPerms, MustUpdSts,
MustApplyTransp, MustUpdCapt, MustLoadStickers, MustResetHistory,
MustApplySysSettings, MustRebuildCL, MustInitCL, MustInitTips: Boolean;
str: PWideChar;
sz, subsz, strLen: UINT;
tmpVal, tmpVal2: TSciterValue;
st: Byte;
disPlugins: TStringList;
begin
PrefsObj := Default(TPrefsObj);
API.ValueEnumElements(argv, @ObjToPrefs, nil);
MustInitCL := False;
MustRebuildCL := False;
MustResetHistory := False;
MustInitTips := False;
Inc(argv);
if UI.Prefs.HasPrefPage(5) then
begin
API.ValueElementsCount(argv, sz);
for i := 0 to sz - 1 do
begin
API.ValueNthElementValue(argv, i, tmpVal);
API.ValueElementsCount(@tmpVal, subsz);
if not (subsz = 2) then
Continue;
API.ValueNthElementValue(@tmpVal, 0, tmpVal2);
API.ValueIntData(@tmpVal2, j);
if not (SHOW_ICONS_ORDER[i] = TRnQCLIconsSet(j)) then
begin
MustRebuildCL := True;
SHOW_ICONS_ORDER[i] := TRnQCLIconsSet(j);
end;
API.ValueNthElementValue(@tmpVal, 1, tmpVal2);
API.ValueIntData(@tmpVal2, j);
if not (SHOW_ICONS_ORDER[i] = CNT_TEXT) and not (TO_SHOW_ICON[SHOW_ICONS_ORDER[i]] = (j = 1)) then
begin
MustRebuildCL := True;
TO_SHOW_ICON[SHOW_ICONS_ORDER[i]] := (j = 1);
end;
end;
end;
Inc(argv);
if UI.Prefs.HasPrefPage(6) then
begin
spellLanguages.Clear;
API.ValueElementsCount(argv, sz);
for i := 0 to sz - 1 do
begin
API.ValueNthElementValue(argv, i, tmpVal);
API.ValueStringData(@tmpVal, str, strLen);
spellLanguages.Add(str);
end;
end;
Inc(argv);
errClr := 0;
if UI.Prefs.HasPrefPage(6) then
API.ValueIntData(argv, errClr);
Inc(argv);
accentClr := 0;
if UI.Prefs.HasPrefPage(5) then
API.ValueIntData(argv, accentClr);
i := 0;
Inc(argv);
if UI.Prefs.HasPrefPage(30) then
begin
disPlugins := TStringList.Create;
with disPlugins do
begin
Sorted := True;
Duplicates := dupIgnore;
StrictDelimiter := True;
Delimiter := ';';
DelimitedText := disabledPlugins.Trim([';']);
end;
API.ValueElementsCount(argv, sz);
plugins.resetEnumeration;
while plugins.hasMore do
with plugins.getNext do
begin
API.ValueNthElementValue(argv, i, tmpVal);
j := 0;
API.ValueIntData(@tmpVal, j);
if j = 1 then
begin
activate;
for k := disPlugins.Count - 1 downto 0 do
if disPlugins.Strings[k] = filename then
disPlugins.Delete(k);
end
else
begin
disactivate;
disPlugins.Add(filename);
end;
Inc(i);
end;
disabledPlugins := disPlugins.DelimitedText;
disPlugins.Free;
end;
with PrefsObj do
for var page in UI.Prefs.ArrPages do
if page.idx = 1 then
begin
// Connection
profile := profile_index;
if (profile >= Low(v_proxyes)) and (profile <= High(v_proxyes)) then
begin
StoreProfileData(profile);
CopyProxy(MainProxy, v_proxyes[profile]);
end;
CopyProxyArr(AllProxies, v_proxyes);
AutoReconnect := net_auto;
ConnectOnConnection := net_whenavailable;
ShowDisconnectedDlg := net_lostdlg;
ShowTempConnectErrors := net_showtemp;
CheckAutoconnect;
end else if page.idx = 2 then
begin
// ICQ protocol
dontSavePwd := not icq_savepass;
clearPwdOnDSNCT := icq_clearpass and not icq_savepass;
MustUpdSts := False;
MustUpdPerms := False;
icq := Account.AccProto;
icq.SaveToken := icq_savetoken;
icq.setPwd(icq_password);
if not (sendBalloonOn = icq_birthremind) then
begin
sendBalloonOn := icq_birthremind;
icq.applyBalloon;
MustUpdSts := True;
end;
sendBalloonOnDate := icq_birthdate;
if not (icq.showclientid = icq_ident) then
begin
icq.showclientid := icq_ident;
MustUpdSts := True;
end;
if not (icq_addcap = AddExtCliCaps) then
begin
AddExtCliCaps := icq_addcap;
MustUpdSts := True;
end;
if not (ExtClientCaps = HexArr2Str(icq_addedcap)) then
begin
ExtClientCaps := HexArr2Str(icq_addedcap);
if AddExtCliCaps then
MustUpdSts := True;
end;
{
if not (showInvisSts = icq_showinvis) then
begin
if not showInvisSts and (icq.visibility in [VI_invisible, VI_privacy]) then
begin
icq.sendStatusCode(False);
MustUpdSts := False;
end;
showInvisSts := icq_showinvis;
end;
}
if not (icq.UseCryptMsg = icq_msgencrypt) then
begin
icq.UseCryptMsg := icq_msgencrypt;
MustUpdSts := True;
end;
if not (icq.SupportTypingNotif = icq_showtyping) then
begin
icq.SupportTypingNotif := icq_showtyping;
MustUpdSts := True;
end;
icq.IsSendTypingNotif := icq_sendtyping;
TypingInterval := BoundInt(icq_inactinterval, 3, 3600);
if not (RecentlyOfflineDelay = BoundInt(icq_recentlyofflinedelay, 1, 1440)) then
begin
RecentlyOfflineDelay := BoundInt(icq_recentlyofflinedelay, 1, 1440);
MustRebuildCL := True;
end;
if not (EnableRecentlyOffline = icq_recentlyoffline) then
begin
EnableRecentlyOffline := icq_recentlyoffline;
MustRebuildCL := True;
end;
if not (icq.AutoReqXStatus = icq_autoreqxstatus) then
begin
icq.AutoReqXStatus := icq_autoreqxstatus;
if icq.AutoReqXStatus then
icq.EventSubscribe;
end;
icq.AvatarsSupport := icq_enableavatars;
icq.AvatarsAutoGet := icq_autoavatars;
AvatarsNotDnlddInform := icq_failedavatars;
if icq.IsOnline then
begin
if MustUpdSts then
icq.SendPresenceState;
if MustUpdPerms then
begin
// icq.sendPrivacy(icq_shareinfo, icq_webaware, icq_reqauth);
// icq.sendAdvQueryInfo(Account.AccProto.MyAccNum, '');
// icq.sendFullQueryInfo(Account.AccProto.MyAccNum);
end;
end;
end else if page.idx = 3 then
begin
// Antispam
EnableIgnoreList := spam_ignorelist;
enableQuietlist := spam_quietlist;
SpamFilter.Warn := spam_warn;
SpamFilter.AddToHist := spam_zero;
cnt := icq.GetContact(spamsFilename);
if Assigned(cnt) then
if SpamFilter.AddToHist and not cnt.IsInRoster then
AddToRoster(cnt, True)
else if not SpamFilter.AddToHist and cnt.IsInRoster then
RemoveFromRoster(cnt);
SpamFilter.IgnoreNIL := spam_ignoreunk;
SpamFilter.IgnoreAuthNIL := spam_ignoreunkauth;
SpamFilter.MultiSend := spam_ignoremult;
SpamFilter.NotNIL := spam_ignoreunk2;
SpamFilter.NotEmpty := spam_ignorenohist;
SpamFilter.NoBadWords := spam_ignorebadwords;
SpamFilter.BadWords := ReplaceStr(Trim(spam_badwords), #10, ';');
SpamFilter.BotTriesCount := BoundInt(spam_botattempts, 2, 5);
if spam_ignoreuin then
SpamFilter.UINgt := BoundInt(spam_ignoreuinvalue, 0, 2000000000)
else
SpamFilter.UINgt := 0;
SpamFilter.UseBot := spam_botenable;
SpamFilter.UseBotFromFile := spam_botusequest;
question := spam_botquestion;
StoreQuestionData(question);
SpamFilter.Quests := Copy(qst);
end else if page.idx = 4 then
begin
// Autoaway
autoaway.away := autoaway_setaway;
autoaway.awayTime := BoundInt(autoaway_setawaydelay, 1, 120) * 10 * 60;
autoaway.na := autoaway_setna;
autoaway.naTime := BoundInt(autoaway_setnadelay, 1, 120) * 10 * 60;
autoaway.ss := autoaway_setnascreen;
autoaway.boss := autoaway_setnaboss;
autoaway.autoexit := autoaway_restore;
autoaway.setxstatus := autoaway_setxstatus;
autoaway.xstatus := autoaway_xstatus;
end else if page.idx = 5 then
begin
// Design
MustApplyTransp := False;
MustApplySysSettings := False;
BarPos := design_clbar;
FilterPos := design_clfilterbar;
rosterbarOnTop := design_clbar = 0;
filterBarOnTop := design_clfilterbar = 0;
AnimateWindows := design_animwindows;
NewSettingsDesign := design_newsettings;
showXStatusMnu := design_xbutton;
if not (UIAccentColor = design_uiaccent) or not (UIAccentColorVal = accentClr) then
MustApplySysSettings := True;
UIAccentColor := design_uiaccent;
UIAccentColorVal := accentClr;
if sortBy <> index2sb(design_clsort) then
begin
MustRebuildCL := True;
sortBy := index2sb(design_clsort);
end;
MustRebuildCL := MustRebuildCL or not (showOnlyOnline = design_onlineonly) or not (showGroups = design_enablegroups) or not (showUnkAsOffline = design_unauthasoff);
MustUpdCapt := not (ShowUINDelimiter = design_uindelim);
ShowUINDelimiter := design_uindelim;
SetContactsThemeUse(design_userthemes);
showOnlyOnline := design_onlineonly;
showUnkAsOffline := design_unauthasoff;
// XStatusInTray := design_xmain;
showGroups := design_enablegroups;
indentRoster := design_indentgrp;
collapseGroups := design_collapsegrp;
MustUpdCapt := MustUpdCapt or not (rosterTitle = design_wintitle);
rosterTitle := design_wintitle;
blinkSpeed := BoundInt(design_blinkspeed, 1, 15);
BlinkTimer.Interval := blinkSpeed * 150 + 250;
ShowHintsInCL := design_showtip;
case design_clautosizedown of
0:
autosizeRoster := False;
1:
begin
autosizeRoster := True;
autosizeFullRoster := False;
end;
2:
begin
autosizeRoster := True;
autosizeFullRoster := True;
end;
end;
autosizeUp := design_clautosizeup;
// snapToScreenEdges := design_snapwin;
// applySnap;
if not (showMainBorder = design_showborder) then
begin
ShowMainBorder := design_showborder;
ToggleMainFormBorder(True, ShowMainBorder);
end;
NoBorderWithShadow := design_noborderwithshadow;
alwaysOnTop := design_clontop;
useSingleClickTray := design_trayclick;
MustApplyTransp := MustApplyTransp or not (transparency.forRoster = design_transpcl) or
not (transparency.forChat = design_transpchat) or not (transparency.active = design_actopacity) or
not (transparency.inactive = design_inactopacity);
transparency.forRoster := design_transpcl;
transparency.forChat := design_transpchat;
transparency.active := BoundInt(design_actopacity, 0, 255);
transparency.inactive := BoundInt(design_inactopacity, 0, 255);
blinkWithStatus := design_blinkstatus;
showBalloons := design_btips;
avatarShowInChat := design_avchat;
avatarShowInHint := design_avhints;
avatarShowInTray := design_avtray;
avatarShowInTaskBar := design_avtaskbarbtn;
avatarUsePalette := design_avusepalette;
TipsMaxAvtSizeUse := design_avmaxsize;
TipsMaxAvtSize := BoundInt(design_avmaxsizeval, 0, 300);
if MustApplySysSettings then
UI.ApplySystemSettings;
if MustApplyTransp then
ApplyTransparency;
if MustUpdCapt then
UI.CL.UpdateCaption;
MustInitCL := True;
MustInitTips := True;
end else if page.idx = 6 then
begin
// Chat
fontstylecodes.enabled := chat_textformat;
autoCopyHist := chat_autocopy;
singleDefault := chat_singlemsg;
showStatusOnTabs := chat_tabstatus;
quoting.cursorBelow := chat_cursorquote;
sendonenter := BoundInt(chat_entercount, 0, 3);
quoting.quoteselected := chat_quoteselected;
chatAlwaysOnTop := chat_chatontop;
usePlugPanel := chat_pluginsabove;
showHintsInChat := chat_tabhints;
bViewTextWrap := chat_wrapinseparate;
CloseChatOnSend := chat_closeonempty;
ClosePageOnSingle := chat_closetabonsingle;
ShowSmileCaption := chat_smilescaptions;
EnableImgLinksIn := chat_inimg;
EnableImgLinksOut := chat_outimg;
LimitMaxChatImgWidth := chat_maximgwidth;
LimitMaxChatImgHeight := chat_maximgheight;
MaxChatImgWidthVal := BoundInt(chat_maximgwidthval, 128, 9999);
MaxChatImgHeightVal := BoundInt(chat_maximgheightval, 128, 9999);
MustLoadStickers := chat_enablestickers and not (EnableStickers = chat_enablestickers);
EnableStickers := chat_enablestickers;
PreviewResolution := chat_previewsize;
ChatImageQuality := chat_chatimgquality;
PreferredResolution := chat_videores;
EnableVideoLinks := chat_videothumbs;
ChatSmoothFontRendering := chat_smoothrender;
AnimatedScroll := chat_animatedscroll;
TrimMsgNewLines := chat_msgtrim;
ShowSmartReplies := chat_smartreplies;
ShowReactions := chat_reactions;
EnableSpellCheck := chat_spellcheck;
RelativeTimeInChatDays := BoundInt(chat_reldays, 2, 31);
RelativeTimeInChatHours := BoundInt(chat_relhours, 0, 24);
spellErrorColor := errClr;
spellErrorStyle := chat_spellcheckstyle;
ScreenshotFormat := chat_scrformat;
i := BoundInt(chat_msgbuffer, 10, 50);
if not (ChatLoadBuffer = i) then
begin
ChatLoadBuffer := i;
MustResetHistory := True;
end;
if Assigned(UI.Chat) then
with UI.Chat do
begin
InitSpellCheck;
SpellCheck;
if MustLoadStickers then
LoadStickers;
if Visible then
begin
SetupChatButtons;
SetupStickersButton;
end;
RedrawTabs;
UpdateStatusBar;
if RelativeTimeInChat then
UpdateRelTimes;
end;
end else if page.idx = 7 then
begin
// Tips
MustInitTips := True;
Transparency.ForTray := tips_transparency;
Transparency.Tray := BoundInt(tips_opacity, 0, 255);
TipsMaxCnt := BoundInt(tips_max, 0, 30);
TipsBtwSpace := BoundInt(tips_space, 0, 30);
TipsAlign := TTipsAlign(Byte(tips_position));
TipVerIndent := BoundInt(tips_vindent, -9999, 9999);
TipHorIndent := BoundInt(tips_hindent, -9999, 9999);
end else if page.idx = 10 then
begin
// Start
userspath := start_userpath;
reopenchats := start_reopenchats;
check4readonly := start_checkro;
autostartUIN := start_withuin;
startMinimized := start_minimized;
skipSplash := start_skipsplash;
autoconnect := start_autoconnect;
RnQStartingStatus := start_withstatus;
RnQStartingVisibility := start_withvis;
uselastStatus := start_firstonly;
lockOnStart := start_lock;
end else if page.idx = 15 then
begin
// Security
AskPassOnBossKeyOn := security_askboss;
logpref.writehistory := security_writehist;
MakeBackups := security_backup;
end else if page.idx = 20 then
begin
// Events
behaviour := tempBeh;
focusOnChatPopup := events_chatfocus;
minOnOff := events_inoutignore;
minOnOffTime := BoundInt(events_inoutdur, 1, 2000);
incomingOnAway := events_awayisonline;
AlertTopMost := events_infoontop;
Soundvolume := BoundInt(events_volume, 0, 100);
autoconsumeevents := events_skipseen;
playSounds := events_playsnd;
for st := Low(Account.AccProto.statuses) to High(Account.AccProto.statuses) do
with UI.Prefs do
begin
OnStatusDisable[st].tips := OnStatusDisableLocal[st].tips;
OnStatusDisable[st].blinking := OnStatusDisableLocal[st].blinking;
OnStatusDisable[st].sounds := OnStatusDisableLocal[st].sounds;
OnStatusDisable[st].OpenChat := OnStatusDisableLocal[st].OpenChat;
end;
DsblEvnt4ClsdGrp := events_notinclosed;
logpref.pkts.onWindow := events_logpacketswin;
logpref.pkts.onFile := events_logpacketsfile;
logpref.pkts.Clear := events_logpacketsclear;
logpref.evts.onWindow := events_logeventswin;
logpref.evts.onFile := events_logeventsfile;
logpref.evts.Clear := events_logeventsclear;
MainPrefs.addPrefBool(PrefIsShowBDFirst, events_bdinform);
MainPrefs.addPrefBool(PrefIsShowBDBefore, events_bdnotify);
MainPrefs.addPrefInt(PrefShowBDFirst, BoundInt(events_bdinformdur, 1, 15));
MainPrefs.addPrefInt(PrefShowBDBefore, BoundInt(events_bdnotifydur, 1, 15));
end else if page.idx = 95 then
begin
// Autoupdate
checkupdate.enabled := autoupdate_enable;
checkupdate.betas := autoupdate_beta;
checkupdate.every := BoundInt(autoupdate_period, 1, 9999);
end else if page.idx = 96 then
begin
// ThemeEdit
MustInitCL := True;
MainCSS := themeedit_maincss;
ChatCSS := themeedit_chatcss;
with UI.Prefs do
if ThemePropsIni.Modified or not (GetThemeProps = themeedit_contents) then
begin
SetThemeProps(themeedit_contents, True);
ReloadCurrentTheme;
end;
end else if page.idx = 99 then
begin
// Other
quitconfirmation := other_confirmexit;
browserCmdLine := other_mybrowser;
useDefaultBrowser := other_browser = 1;
autoswitchKL := other_autolayout;
NILdoWith := 2 - other_notinlist;
showIncomingDlg := other_indialog;
optimizeDB := other_vacuum;
wheelVelocity := BoundInt(other_mwheelspeed, 1, 30);
inactivehideTime := BoundInt(other_clautohideval, 1, 36000) * 10;
inactiveHide := other_clautohide;
InactiveTrim := other_trimws;
ServerToUpload := other_servertoupload;
HandleICQLinks := other_handleicqlinks;
SetICQLinksHandler(HandleICQLinks);
end;
UI.InitSettings;
// Updates
if MustInitCL then
begin
UI.CL.InitSettings;
UI.CL.InitMenus;
UI.CL.UpdateAdditionalImage;
UI.CL.UpdateVisibilityImage;
end;
if MustInitTips then
UI.Tips.InitSettings;
if MustRebuildCL then
roasterLib.RebuildCL;
if Assigned(UI.Chat) then
with UI.Chat do
begin
InitSettings;
if MustResetHistory then
ResetHistory;
end;
if Assigned(PreviewChat) then
PreviewChat.InitSettings;
ActionManager.Execute(AK_SAVEALL, SaveDelay);
SaveCommonCFG;
end;
class procedure TPrefsMethods.PrefsReset(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
UI.Prefs.Reset
end;
class procedure TPrefsMethods.ResetPlugins(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
UI.Prefs.ResetPlugins
end;
class procedure TPrefsMethods.IsOnline(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if Assigned(Account.AccProto) and Account.AccProto.IsOnline then
API.ValueIntDataSet(retval, 1, T_BOOL, 0)
else
API.ValueIntDataSet(retval, 0, T_BOOL, 0);
end;
class procedure TPrefsMethods.ApplyTransp(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
val: Integer;
begin
val := -1;
API.ValueIntData(argv, val);
ApplyTransparency(AW_BOTH, val);
end;
//class procedure TPrefsMethods.GetFont(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
//var
// openDlg: Integer;
// cclr: String;
// tmpVal: TSciterValue;
//begin
// if not Running then
// Exit;
//
// openDlg := 0;
// API.ValueIntData(argv, openDlg);
//
// with UI.Prefs do
// begin
// if (openDlg = 0) or ((openDlg = 1) and FontDialog.Execute(Window)) then
// begin
// API.ValueInit(@tmpVal);
// API.ValueStringDataSet(@tmpVal, PWideChar(FontDialog.Font.Name), Length(FontDialog.Font.Name), 0);
// API.ValueNthElementValueSet(retval, 0, @tmpVal);
// API.ValueIntDataSet(@tmpVal, FontDialog.Font.Size, T_INT, 0);
// API.ValueNthElementValueSet(retval, 1, @tmpVal);
// cclr := Color2HTML(FontDialog.Font.Color);
// API.ValueStringDataSet(@tmpVal, PWideChar(cclr), Length(cclr), 0);
// API.ValueNthElementValueSet(retval, 2, @tmpVal);
// API.ValueIntDataSet(@tmpVal, RDUtils.IfThen(fsBold in FontDialog.Font.Style, 1), T_BOOL, 0);
// API.ValueNthElementValueSet(retval, 3, @tmpVal);
// API.ValueIntDataSet(@tmpVal, RDUtils.IfThen(fsItalic in FontDialog.Font.Style, 1), T_BOOL, 0);
// API.ValueNthElementValueSet(retval, 4, @tmpVal);
// API.ValueIntDataSet(@tmpVal, RDUtils.IfThen(fsUnderline in FontDialog.Font.Style, 1), T_BOOL, 0);
// API.ValueNthElementValueSet(retval, 5, @tmpVal);
// API.ValueClear(@tmpVal);
// end else
// API.ValueIntDataSet(retval, 0, T_BOOL, 0);
// end;
//end;
//
//class procedure TPrefsMethods.SetFontProps(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
//var
// fsize, fcolor: Integer;
//begin
// if not Running then
// Exit;
//
// fsize := 14;
// fcolor := 0;
// API.ValueIntData(argv, fsize);
// Inc(argv);
// API.ValueIntData(argv, fcolor);
//
// with UI.Prefs do
// begin
// FontDialog.Font.Size := fsize;
// FontDialog.Font.Color := fcolor;
// end;
//end;
class procedure TPrefsMethods.RefreshLangs(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if not Running then
Exit;
UI.Prefs.RefreshLangList;
UI.Prefs.ResetLangs;
end;
class procedure TPrefsMethods.ManageLangs(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
path: String;
begin
if not Running then
Exit;
with UI.Prefs do
if TOSVersion.Check(10) then
ShellExecute(Window, 'open', 'ms-settings:regionlanguage', '', '', SW_SHOWNORMAL)
else
begin
path := expandEnv('%LocalAppData%') + '\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\%s\AAA_SystemSettings_Language_Add_Profile.settingcontent-ms';
if ShellExecute(Window, 'open', PChar(Format(path, ['ru-RU'])), '', '', SW_SHOWNORMAL) <= 32 then
ShellExecute(Window, 'open', PChar(Format(path, ['en-US'])), '', '', SW_SHOWNORMAL);
end;
end;
class procedure TPrefsMethods.UserDicts(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if not Running then
Exit;
ShellExecute(UI.Prefs.Window, 'open', PChar(expandEnv('%AppData%') + '\Microsoft\Spelling'), '', '', SW_SHOWNORMAL);
end;
class procedure TPrefsMethods.SetMainSpellcheckLang(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
str: PWideChar;
strLen: UINT;
begin
if argc = 0 then
Exit;
str := '';
API.ValueStringData(argv, str, strLen);
spellLanguageMain := str;
end;
class procedure TPrefsMethods.TestTips(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
e: Thevent;
begin
e := Thevent.new(EK_msg, nil, Account.AccProto.GetMyInfo, Now, GetTranslation('Testing') + CRLF + 'Second row ------- :)', [], 0);
//e := SQLDB.GetByMsgID('230490', 6829340988138324771, False);
UI.Tips.Add(e);
e.Free;
end;
class procedure TPrefsMethods.GetCurrentAccountPath(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Path: String;
begin
Path := ExtractFileName(ExcludeTrailingPathDelimiter(AccPath));
API.ValueStringDataSet(retval, PWideChar(Path), Length(Path), 0);
end;
class procedure TPrefsMethods.GetXStatusMsg(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
st: Integer;
msg: String;
begin
if argc = 0 then
Exit;
API.ValueIntData(argv, st);
msg := ExtStsStrings[st].Desc;
if msg = '' then
msg := GetTranslation('');
API.ValueStringDataSet(retval, PWideChar(msg), Length(msg), 0);
end;
class procedure TPrefsMethods.GetMainStyles(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
SR: TSearchRec;
CSSThemes: TParams;
begin
SetLength(CSSThemes, 0);
if FindFirst(MyPath + themesPath + 'CSS\Main_*.css', faAnyFile, SR) = 0 then
repeat
if SR.Name[1] <> '.' then
CSSThemes := CSSThemes + [MyPath + themesPath + 'CSS\' + SR.Name];
until FindNext(SR) <> 0;
FindClose(SR);
V2S(CSSThemes, retval);
end;
class procedure TPrefsMethods.GetChatStyles(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
SR: TSearchRec;
CSSThemes: TParams;
begin
SetLength(CSSThemes, 0);
if FindFirst(MyPath + themesPath + 'CSS\Chat_*.css', faAnyFile, SR) = 0 then
repeat
if SR.Name[1] <> '.' then
CSSThemes := CSSThemes + [MyPath + themesPath + 'CSS\' + SR.Name];
until FindNext(SR) <> 0;
FindClose(SR);
V2S(CSSThemes, retval);
end;
class procedure TPrefsMethods.GetKeyName(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
code: Integer;
key: String;
begin
if argc = 0 then
Exit;
API.ValueIntData(argv, code);
key := shortcutToText(code);
API.ValueStringDataSet(retval, PWideChar(key), Length(key), 0);
end;
class procedure TPrefsMethods.HotkeySelect(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
aRow: integer;
begin
if (argc = 0) or not Running then
Exit;
aRow := -1;
API.ValueIntData(argv, aRow);
if (aRow < 0) or (aRow > Length(macros) - 1) then
Exit;
with macros[aRow] do
UI.Prefs.Call('setCurrentHotkey', [hk and not scCommand, shortcutToText(hk), sw, hk and scCommand <> 0, opcode - 1]);
end;
class procedure TPrefsMethods.HotkeyDefault(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if not Running then
Exit;
SetLength(macros, 0);
addMacro(TextToShortCut('ctrl+shift+i'), TRUE, OP_TRAY);
addMacro(TextToShortCut('ctrl+shift+o'), TRUE, OP_CHAT);
addMacro(TextToShortCut('ctrl+o'), FALSE, OP_OFFLINECONTACTS);
addMacro(TextToShortCut('ctrl+g'), FALSE, OP_GROUPS);
addMacro(TextToShortCut('ctrl+a'), FALSE, OP_AUTOSIZE);
addMacro(TextToShortCut('ctrl+p'), FALSE, OP_PREFERENCES);
addMacro(TextToShortCut('alt+i'), FALSE, OP_VIEWINFO);
addMacro(TextToShortCut('F11'), FALSE, OP_TOGGLEBORDER);
addMacro(TextToShortCut('F3'), FALSE, OP_HINT);
addMacro(TextToShortCut('ctrl+shift+m'), FALSE, OP_MAINMENU);
UI.Prefs.ResetHotkeys;
end;
class procedure TPrefsMethods.HotkeySave(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
hotkey, sw, index: Integer;
begin
if (argc = 0) or not Running then
Exit;
hotkey := 0;
API.ValueIntData(argv, hotkey);
sw := 0;
Inc(argv);
API.ValueIntData(argv, sw);
index := 0;
Inc(argv);
API.ValueIntData(argv, index);
if index = -1 then
Exit;
if addMacro(hotkey, sw = 1, index + 1) then
API.ValueIntDataSet(retval, 1, T_BOOL, 0)
else
API.ValueIntDataSet(retval, 0, T_BOOL, 0);
UI.Prefs.ResetHotkeys;
end;
class procedure TPrefsMethods.HotkeyDelete(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
aRow: Integer;
begin
aRow := -1;
API.ValueIntData(argv, aRow);
removeMacro(aRow);
end;
class procedure TPrefsMethods.UpdateEventTriggers(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
ev, i: Integer;
ac: Tbehaction;
triggers: TParams;
begin
if (argc = 0) or not Running then
Exit;
ev := -1;
API.ValueIntData(argv, ev);
if ev >= 0 then
begin
Inc(ev);
i := 0;
for ac := Low(ac) to High(ac) do
begin
SetLength(triggers, i + 1);
triggers[i] := VarArrayCreate([0, 3], varVariant);
triggers[i][0] := ac;
triggers[i][1] := ac in supportedBehactions[ev];
triggers[i][2] := ac in tempBeh[ev].trig;
triggers[i][3] := behactionName(ac);
Inc(i);
end;
UI.Prefs.Call('updateEventTriggers', [triggers, BE_tip in supportedBehactions[ev], tempBeh[ev].tiptimes, tempBeh[ev].tiptime / 10, tempBeh[ev].tiptimeplus / 10]);
end;
end;
class procedure TPrefsMethods.StoreEventTrigger(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
ev, tmp: Integer;
ac: Tbehaction;
dur, plus: Double;
chk, multiply: Boolean;
begin
if (argc < 6) then
Exit;
ev := -1;
API.ValueIntData(argv, ev);
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
ac := Tbehaction(tmp);
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
chk := tmp = 1;
dur := 0;
Inc(argv);
API.ValueFloatData(argv, dur);
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
multiply := tmp = 1;
plus := 0;
Inc(argv);
API.ValueFloatData(argv, plus);
if ev >= 0 then
begin
Inc(ev);
if ev in [1 .. EK_last] then
if chk then
Include(tempBeh[ev].trig, ac)
else
Exclude(tempBeh[ev].trig, ac);
tempBeh[ev].tiptime := Round(dur * 10);
tempBeh[ev].tiptimes := multiply;
tempBeh[ev].tiptimeplus := Round(plus * 10)
end;
end;
class procedure TPrefsMethods.UpdateDisabledEvents(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
status: Integer;
events: TParams;
begin
if (argc = 0) or not Running then
Exit;
status := -1;
API.ValueIntData(argv, status);
if status >= 0 then
with UI.Prefs do
begin
SetLength(events, 4);
events[0] := OnStatusDisableLocal[status].tips;
events[1] := OnStatusDisableLocal[status].blinking;
events[2] := OnStatusDisableLocal[status].sounds;
events[3] := OnStatusDisableLocal[status].OpenChat;
Call('updateDisabledEvents', [events]);
end;
end;
class procedure TPrefsMethods.StoreDisabledEvents(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
status, tmp: Integer;
tips, blink, sound, chat: Boolean;
begin
if (argc < 5) or not Running then
Exit;
status := -1;
API.ValueIntData(argv, status);
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
tips := tmp = 1;
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
blink := tmp = 1;
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
sound := tmp = 1;
tmp := 0;
Inc(argv);
API.ValueIntData(argv, tmp);
chat := tmp = 1;
if status >= 0 then
with UI.Prefs do
begin
OnStatusDisableLocal[status].tips := tips;
OnStatusDisableLocal[status].blinking := blink;
OnStatusDisableLocal[status].sounds := sound;
OnStatusDisableLocal[status].OpenChat := chat;
end;
end;
class procedure TPrefsMethods.PlaySound(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
str: PWideChar;
strLen: Cardinal;
begin
if argc = 0 then
Exit;
str := '';
API.ValueStringData(argv, str, strLen);
try
SoundPlay(str);
except end;
end;
class procedure TPrefsMethods.SoundTest(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
vol: Integer;
begin
if argc = 0 then
Exit;
vol := 0;
API.ValueIntData(argv, vol);
Soundvolume := vol;
try
theme.PlaySound('incoming');
except end;
end;
class procedure TPrefsMethods.TimeTest(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
ev: Integer;
e: Thevent;
s: AnsiString;
begin
if argc = 0 then
Exit;
ev := -1;
API.ValueIntData(argv, ev);
if ev >= 0 then
begin
Inc(ev);
s := '';
if (ev = EK_statuschange) or (ev = EK_incoming) then
e := Thevent.new(ev, nil, Account.AccProto.GetMyInfo, Now, '', [Integer(SC_ONLINE), Byte(True), Byte(20)], 0)
else if ev = EK_XstatusMsg then
e := Thevent.new(ev, nil, Account.AccProto.GetMyInfo, Now, 'Status' + AnsiString(#00#00#00#00) + 'Status description', [Byte(SC_ONLINE)], 0)
else
e := Thevent.new(ev, nil, Account.AccProto.GetMyInfo, Now, s + 'Testing' + CRLF + 'Second row ------- :)', [], 0);
UI.Tips.Add(e);
e.Free;
end;
end;
class procedure TPrefsMethods.IsAudioPresent(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if audioPresent then
API.ValueIntDataSet(retval, 1, T_BOOL, 0)
else
API.ValueIntDataSet(retval, 0, T_BOOL, 0);
end;
class procedure TPrefsMethods.IsMasterMuted(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if MasterMute then
API.ValueIntDataSet(retval, 1, T_BOOL, 0)
else
API.ValueIntDataSet(retval, 0, T_BOOL, 0);
end;
class procedure TPrefsMethods.BASSWarning(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
str: String;
begin
str := getTranslation('Need bass.dll version %s', [intToStr(HiByte(BASSVERSION)) + '.' + intToStr(loByte(BASSVERSION))]);
API.ValueStringDataSet(retval, PWideChar(str), Length(str), 0);
end;
class procedure TPrefsMethods.ReloadPlugins(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if not Running then
Exit;
plugins.unload;
plugins.load;
UI.Prefs.ResetPlugins;
end;
class procedure TPrefsMethods.OpenPluginPrefs(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
index: Integer;
begin
if not Running then
Exit;
index := -1;
API.ValueIntData(argv, index);
if index >= 0 then
UI.Prefs.pluginList[index].cast_preferences
end;
class procedure TPrefsMethods.UpdateThemeEditProp(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
index: Integer;
p: ^Tthemeproperty;
data: Variant;
begin
if not Running then
Exit;
index := -1;
API.ValueIntData(argv, index);
if index >= 0 then
with UI.Prefs do
begin
p := @themeprops[index];
case p.kind of
TP_font:
begin
//FontDialog.Font.Assign(Screen.MenuFont);
//theme.ApplyFont(Copy(p.name, 1, Length(p.name) - 5), FontDialog.Font);
end;
TP_color:
data := Color2HTML(theme.GetColor(Copy(p.name, 1, Length(p.name) - 6)));
TP_pic, TP_ico:
data := p.name;
TP_string:
data := theme.GetString(p.name);
TP_sound:
data := theme.GetSound(p.name);
end;
Call('refreshThemeEdit', [p.kind, data]);
end;
end;
class procedure TPrefsMethods.AddThemeProp(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
index, tmpInt: Integer;
props, tmpStr: PWideChar;
strLen: Cardinal;
p: ^Tthemeproperty;
chrst: String;
begin
if not Running then
Exit;
props := '';
API.ValueStringData(argv, props, strLen);
Inc(argv);
index := -1;
API.ValueIntData(argv, index);
if index >= 0 then
with UI.Prefs do
begin
SetThemeProps(props);
p := @themeprops[index];
case p.kind of
TP_font:
with ThemePropsIni do
begin
// WriteString(p.section, p.name + '.color', color2str(FontDialog.Font.Color));
// WriteInteger(p.section, p.name + '.size', FontDialog.Font.Size);
// WriteString(p.section, p.name + '.name', FontDialog.Font.Name);
// if CharsetToIdent(FontDialog.Font.Charset, chrst) then
// WriteString(p.section, p.name + '.charset', chrst)
// else
// DeleteKey(p.section, p.name + '.charset');
// if fontstyle2str(FontDialog.Font.Style) = '' then
// DeleteKey(p.section, p.name + '.style')
// else
// WriteString(p.section, p.name + '.style', fontstyle2str(FontDialog.Font.Style));
end;
TP_color:
begin
Inc(argv);
tmpInt := 0;
API.ValueIntData(argv, tmpInt);
ThemePropsIni.WriteString(p.section, p.name, color2str(tmpInt));
end;
TP_pic, TP_ico, TP_sound:
begin
Inc(argv);
tmpStr := '';
API.ValueStringData(argv, tmpStr, strLen);
ThemePropsIni.WriteString(p.section, p.name, tmpStr);
end;
TP_string:
begin
Inc(argv);
tmpStr := '';
API.ValueStringData(argv, tmpStr, strLen);
ThemePropsIni.WriteString(p.section, p.name, newline2slashn(tmpStr));
end;
end;
props := PWideChar(GetThemeProps);
API.ValueStringDataSet(retval, props, Length(props), 0);
end else
API.ValueIntDataSet(retval, 0, T_BOOL, 0);
end;
class procedure TPrefsMethods.CheckPath(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
path: PWideChar;
fpath: String;
strLen: Cardinal;
begin
path := '';
API.ValueStringData(argv, path, strLen);
fpath := Template(path, [
'%userpath%', ExcludeTrailingPathDelimiter(AccPath),
'%rnqpath%', ExcludeTrailingPathDelimiter(mypath),
'%uid%', 'UID',
'%nick%', 'NICK'
]);
fpath := IncludeTrailingPathDelimiter(fpath) + 'FILE';
API.ValueStringDataSet(retval, PWideChar(fpath), Length(fpath), 0);
end;
class procedure TPrefsMethods.HasMDLFont(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
V2S(Screen.Fonts.IndexOf('Segoe MDL2 Assets') >= 0, retval);
end;
class procedure TPrefsMethods.OnPrefsCreate(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
RootVar: Variant;
begin
UI.Prefs := TPrefs.Create;
S2V(argv, RootVar);
UI.Prefs.Root := Pointer(NativeInt(RootVar));
API.SciterGetElementHwnd(UI.Prefs.Root, UI.Prefs.Window, True);
HotkeysEnabled := False;
UI.Prefs.ThemePropsIni := nil;
UI.Prefs.LoadThemeProps;
UI.Prefs.SetBounds(PrefsXY);
V2S(GetTranslation('Preferences for %s', [RnQUser]), retval);
end;
class procedure TPrefsMethods.OnPrefsClose(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
UpdateSWhotkeys;
HotkeysEnabled := True;
if Assigned(UI) and Assigned(UI.Prefs) then
FreeAndNil(UI.Prefs);
end;
constructor TPrefs.Create;
begin
end;
destructor TPrefs.Destroy;
var
I: Integer;
begin
for I := Low(ArrPages) to High(ArrPages) do
FreeAndNil(ArrPages[I]);
SetLength(ArrPages, 0);
FreeAndNil(ThemePropsIni);
SetLength(OnStatusDisableLocal, 0);
SetLength(pluginList, 0);
SetLength(themeprops, 0);
inherited;
end;
procedure TPrefs.InitConnection;
begin
// Call('initConnection');
end;
procedure TPrefs.InitChat;
begin
if CheckWin32Version(6, 2) then
RefreshLangList
else begin
EnableSpellCheck := False;
Call('hideSpellcheck');
end;
end;
procedure TPrefs.InitAutoaway;
var
x: Integer;
xstatuses: TParams;
begin
for x := Low(XStatusArray) to High(XStatusArray) do
begin
SetLength(xstatuses, Length(xstatuses) + 1);
xstatuses[High(xstatuses)] := VarArrayCreate([0, 2], varVariant);
xstatuses[High(xstatuses)][0] := x;
xstatuses[High(xstatuses)][1] := IfThen(x = 0, '⬜', XStatusArray[x].Status);
xstatuses[High(xstatuses)][2] := GetTranslation(XStatusArray[x].Text);
end;
Call('initAutoaway', [xstatuses]);
end;
procedure TPrefs.InitStart;
var
i: Integer;
status, vis: TParams;
smenu: TStatusMenu;
begin
smenu := Account.AccProto.getStatusMenu;
SetLength(status, Length(smenu) + 1);
status[0] := VarArrayCreate([0, 1], varVariant);
status[0][0] := -1;
status[0][1] := getTranslation('Use last set status');
for i := 0 to Length(smenu) - 1 do
begin
status[i + 1] := VarArrayCreate([0, 1], varVariant);
status[i + 1][0] := smenu[i];
status[i + 1][1] := getTranslation(status2ShowStr[TICQStatus(smenu[i])]);
end;
smenu := Account.AccProto.getVisMenu;
SetLength(vis, Length(smenu));
for i := 0 to Length(smenu) - 1 do
begin
vis[i] := VarArrayCreate([0, 1], varVariant);
vis[i][0] := smenu[i];
vis[i][1] := getTranslation(visibility2ShowStr[Tvisibility(smenu[i])]);
end;
Call('initStart', [status, vis]);
end;
procedure TPrefs.InitHotkeys;
var
actions: TParams;
i: Integer;
begin
RemoveSWHotkeys;
SetLength(actions, OP_last - succ(OP_none) + 1);
for i := succ(OP_none) to OP_last do
actions[i - succ(OP_none)] := GetTranslation(macro2str[i]);
Call('initHotkeys', [actions]);
end;
procedure TPrefs.InitEvents;
var
i, j: Integer;
events, statuses: TParams;
begin
SetLength(OnStatusDisableLocal, High(Account.AccProto.statuses) + 1);
SetLength(events, EK_last);
for i := 1 to EK_last do
for j := 0 to Length(ActiveEvents) - 1 do
if i = ActiveEvents[j] then
events[i - 1] := getTranslation(event2ShowStr[i]);
i := 0;
for var st in Account.AccProto.getStatusMenu do
if not (st = Byte(SC_OFFLINE)) and not (st = Byte(SC_UNK)) then
begin
SetLength(statuses, i + 1);
statuses[i] := VarArrayCreate([0, 1], varVariant);
statuses[i][0] := Account.AccProto.getStatuses[st].idx;
statuses[i][1] := getTranslation(Account.AccProto.getStatuses[st].Cptn);
Inc(i);
end;
Call('initEvents', [events, statuses]);
end;
procedure TPrefs.InitThemeEdit;
var
I: Integer;
Props: TParams;
begin
theme.getprops(themeprops);
SetLength(Props, Length(themeprops));
for I := 0 to Length(themeprops) - 1 do
begin
Props[I] := VarArrayCreate([0, 1], varVariant);
Props[I][0] := themeprops[I].kind;
Props[I][1] := Format('[%s] %s', [themeprops[I].section, themeprops[I].name]);
end;
Call('initThemeEdit', [Props]);
end;
procedure TPrefs.InitOther;
begin
Call('initOther');
end;
{
function EscapeQuotes(text: String): String;
begin
Result := text.Replace('\', '\\', [rfReplaceAll]).Replace('"', '\"', [rfReplaceAll]);
end;
}
procedure TPrefs.ResetConnection(ProfileOnly: Boolean = False);
var
profiles: TParams;
foundProxy: Boolean;
i, index: Integer;
obj: TPrefsObj;
begin
index := 0;
if not ProfileOnly then
CopyProxyArr(v_proxyes, AllProxies);
if Length(v_proxyes) = 0 then
begin
MainProxy.name := 'Default';
SetLength(v_proxyes, 1);
CopyProxy(v_proxyes[0], MainProxy);
end
else
begin
foundProxy := False;
for i := 0 to Length(v_proxyes) - 1 do
if v_proxyes[i].name = MainProxy.name then
begin
index := i;
foundProxy := True;
break;
end;
if not foundProxy then
index := 0;
if (index >= Low(v_proxyes)) and (index <= High(v_proxyes)) then
CopyProxy(MainProxy, v_proxyes[index]);
end;
SetLength(profiles, Length(v_proxyes));
for i := 0 to Length(v_proxyes) - 1 do
profiles[i] := v_proxyes[i].name;
obj := Default(TPrefsObj);
if (index >= Low(v_proxyes)) and (index <= High(v_proxyes)) then
with obj, v_proxyes[index] do
begin
profile_index := index;
profile_name := name;
profile_proxy := ord(proto);
profile_proxyauth := auth;
profile_proxyhost := addr.host;
profile_proxyport := addr.port;
profile_proxyuser := user;
profile_proxypasswd := pwd;
profile_proxyntlm := NTLM;
if not ProfileOnly then
begin
net_auto := AutoReconnect;
net_whenavailable := ConnectOnConnection;
net_lostdlg := ShowDisconnectedDlg;
net_showtemp := ShowTempConnectErrors;
end;
Call('resetConnection', [profiles, ProfileOnly, UI.RecordToVar(obj)]);
end;
end;
procedure TPrefs.ResetICQ;
function Str2HexArr(const Str: String): TCaps;
var
StartIndex, Remaining, I: Integer;
begin
Remaining := Length(Str);
StartIndex := 1;
I := 0;
while (Remaining > 0) and (I <= 15) do
begin
Result[I] := Copy(Str, StartIndex, 2);
Inc(StartIndex, 2);
Dec(Remaining, 2);
Inc(I);
end;
end;
var
icq: TICQSession;
obj: TPrefsObj;
begin
if not Assigned(Account.AccProto) then
Exit;
icq := Account.AccProto;
obj := Default(TPrefsObj);
with obj do
begin
icq_password := icq.pwd;
icq_savepass := not dontSavePwd;
icq_clearpass := clearPwdOnDSNCT;
icq_savetoken:= icq.SaveToken;
icq_birthremind := sendBalloonOn;
icq_birthdate := sendBalloonOnDate;
icq_ident := icq.ShowClientID;
icq_addcap := AddExtCliCaps;
icq_addedcap := Str2HexArr(ExtClientCaps);
icq_msgencrypt := icq.UseCryptMsg;
// icq_showinvis := showInvisSts;
// icq_webaware := icq.webaware;
// icq_shareinfo := icq.showInfo;
// icq_reqauth := icq.authNeeded;
icq_showtyping := icq.SupportTypingNotif;
icq_sendtyping := icq.isSendTypingNotif;
icq_inactinterval := TypingInterval;
icq_recentlyoffline := EnableRecentlyOffline;
icq_recentlyofflinedelay := RecentlyOfflineDelay;
icq_autoreqxstatus := icq.AutoReqXStatus;
icq_enableavatars := icq.AvatarsSupport;
icq_autoavatars := icq.AvatarsAutoGet;
icq_failedavatars := AvatarsNotDnlddInform;
end;
Call('resetICQ', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetAntispam(QuestionsOnly: Boolean = False);
var
obj: TPrefsObj;
questions: TParams;
ignores, quiets: TParams;
ign, qts: array of TListItem;
cnt: TICQContact;
i: Integer;
begin
obj := Default(TPrefsObj);
if not QuestionsOnly then
with obj do
begin
spam_warn := SpamFilter.Warn;
spam_ignoreunk := SpamFilter.IgnoreNIL;
spam_ignoreunkauth := SpamFilter.IgnoreAuthNIL;
spam_zero := SpamFilter.AddToHist;
spam_ignoremult := SpamFilter.MultiSend;
spam_ignoreunk2 := SpamFilter.NotNIL;
spam_ignorenohist := SpamFilter.NotEmpty;
spam_ignorebadwords := SpamFilter.NoBadWords;
spam_badwords := ReplaceStr(SpamFilter.BadWords, ';', #10);
spam_ignoreuin := SpamFilter.UINgt > 0;
if SpamFilter.UINgt = 0 then
spam_ignoreuinvalue := 150000000
else
spam_ignoreuinvalue := SpamFilter.UINgt;
spam_botenable := SpamFilter.UseBot;
spam_botusequest := SpamFilter.UseBotFromFile;
spam_botattempts := SpamFilter.BotTriesCount;
spam_ignorelist := EnableIgnoreList;
IgnoreList.resetEnumeration;
SetLength(ign, IgnoreList.Count);
i := 0;
while IgnoreList.hasMore do
with ign[i] do
begin
cnt := IgnoreList.getNext;
s0 := cnt.displayed;
if not (s0 = cnt.UID) then
s0 := s0 + ' (' + cnt.uin2Show + ')';
s1 := cnt.UID;
isSrv := Account.AccProto.IsInList(LT_SPAM, cnt);
Inc(i);
end;
SetLength(ignores, Length(ign));
for i := 0 to Length(ign) - 1 do
ignores[i] := UI.RecordToVar(ign[i]);
spam_quietlist := enableQuietlist;
quietList.resetEnumeration;
SetLength(qts, quietList.Count);
i := 0;
while quietList.hasMore do
with qts[i] do
begin
cnt := quietList.getNext;
s0 := cnt.displayed;
if not (s0 = cnt.UID) then
s0 := s0 + ' (' + cnt.uin2Show + ')';
s1 := cnt.UID;
isSrv := False;
Inc(i);
end;
SetLength(quiets, Length(qts));
for i := 0 to Length(qts) - 1 do
quiets[i] := UI.RecordToVar(qts[i]);
qst := Copy(SpamFilter.Quests);
end;
SetLength(questions, Length(qst));
for i := 0 to Length(qst) - 1 do
questions[i] := UI.RecordToVar(qst[i]);
Call('resetAntispam', [questions, QuestionsOnly, ignores, quiets, UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetAutoaway;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
autoaway_setaway := autoaway.away;
autoaway_setawaydelay := autoaway.awayTime div (10 * 60);
autoaway_setna := autoaway.na;
autoaway_setnadelay := autoaway.naTime div (10 * 60);
autoaway_setnascreen := autoaway.ss;
autoaway_setnaboss := autoaway.boss;
autoaway_restore := autoaway.autoexit;
autoaway_setxstatus := autoaway.setxstatus;
autoaway_xstatus := autoaway.xstatus;
end;
Call('resetAutoaway', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetDesign;
var
obj: TPrefsObj;
items: TParams;
i: Integer;
begin
obj := Default(TPrefsObj);
with obj do
begin
design_clontop := alwaysOnTop;
design_trayclick := useSingleClickTray;
// design_snapwin := snapToScreenEdges;
design_xbutton := showXStatusMnu;
design_blinkspeed := blinkSpeed;
design_blinkstatus := blinkWithStatus;
// design_xmain := XStatusInTray;
design_btips := showBalloons;
design_userthemes := UseContactThemes;
StatusIcon.Update;
if not autosizeRoster then
design_clautosizedown := 0
else if not autosizeFullRoster then
design_clautosizedown := 1
else
design_clautosizedown := 2;
design_clbar := BarPos;
design_clfilterbar := FilterPos;
design_clsort := sb2index[sortBy];
design_uiaccent := UIAccentColor;
design_wintitle := rosterTitle;
design_clautosizeup := autosizeUp;
design_showtip := ShowHintsInCL;
design_animwindows := AnimateWindows;
design_newsettings := NewSettingsDesign;
design_uindelim := ShowUINDelimiter;
design_showborder := showMainBorder;
design_noborderwithshadow := NoBorderWithShadow;
design_enablegroups := showGroups;
design_indentgrp := indentRoster;
design_collapsegrp := collapseGroups;
design_onlineonly := showOnlyOnline;
design_unauthasoff := showUnkAsOffline;
design_transpcl := transparency.forRoster;
design_transpchat := transparency.forChat;
design_actopacity := transparency.active;
design_inactopacity := transparency.inactive;
design_avchat := avatarShowInChat;
design_avhints := avatarShowInHint;
design_avtray := avatarShowInTray;
design_avtaskbarbtn := avatarShowInTaskBar;
design_avusepalette := avatarUsePalette;
design_avmaxsize := TipsMaxAvtSizeUse;
design_avmaxsizeval := TipsMaxAvtSize;
end;
SetLength(items, Length(SHOW_ICONS_ORDER));
for i := 0 to Length(items) - 1 do
begin
items[i] := VarArrayCreate([0, 1], varVariant);
items[i][0] := UI.RecordToVar(RnQCLIcons[SHOW_ICONS_ORDER[i]]);
items[i][1] := TO_SHOW_ICON[SHOW_ICONS_ORDER[i]];
end;
Call('resetDesign', [items, Color2HTML(UIAccentColorVal), UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetChat;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
chat_textformat := fontstylecodes.enabled;
chat_autocopy := autoCopyHist;
chat_singlemsg := singleDefault;
chat_tabstatus := showStatusOnTabs;
chat_cursorquote := quoting.cursorBelow;
chat_msgbuffer := ChatLoadBuffer;
chat_entercount := sendonenter;
chat_quoteselected := quoting.quoteselected;
chat_chatontop := chatAlwaysOnTop;
chat_pluginsabove := usePlugPanel;
chat_tabhints := showHintsInChat;
chat_wrapinseparate := bViewTextWrap;
chat_closeonempty := closeChatOnSend;
chat_smilescaptions := ShowSmileCaption;
chat_inimg := EnableImgLinksIn;
chat_outimg := EnableImgLinksOut;
chat_maximgwidth := LimitMaxChatImgWidth;
chat_maximgheight := LimitMaxChatImgHeight;
chat_enablestickers := EnableStickers;
chat_previewsize := PreviewResolution;
chat_chatimgquality := ChatImageQuality;
chat_videores := PreferredResolution;
chat_videothumbs := EnableVideoLinks;
chat_smoothrender := ChatSmoothFontRendering;
chat_animatedscroll := AnimatedScroll;
chat_msgtrim := TrimMsgNewLines;
chat_smartreplies := ShowSmartReplies;
chat_reactions := ShowReactions;
chat_spellcheck := EnableSpellCheck;
chat_maximgwidthval := MaxChatImgWidthVal;
chat_maximgheightval := MaxChatImgHeightVal;
chat_closetabonsingle := ClosePageOnSingle;
chat_spellcheckstyle := spellErrorStyle;
chat_reldays := RelativeTimeInChatDays;
chat_relhours := RelativeTimeInChatHours;
chat_scrformat := ScreenshotFormat;
end;
Call('resetChat', [Color2HTML(spellErrorColor), UI.RecordToVar(obj)]);
ResetLangs;
end;
procedure TPrefs.ResetTips;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
tips_transparency := transparency.forTray;
tips_opacity := transparency.tray;
tips_max := TipsMaxCnt;
tips_space := TipsBtwSpace;
tips_vindent := TipVerIndent;
tips_hindent := TipHorIndent;
tips_position := byte(TipsAlign);
end;
Call('resetTips', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetStart;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
start_userpath := userspath;
start_reopenchats := reopenchats;
start_checkro := check4readonly;
if autostartUIN = '' then
start_withuin := ''
else
start_withuin := autostartUIN;
start_minimized := startMinimized;
start_autoconnect := autoconnect;
start_withstatus := RnQStartingStatus;
start_withvis := RnQStartingVisibility;
start_firstonly := uselastStatus;
start_skipsplash := skipSplash;
start_lock := lockOnStart;
end;
Call('resetStart', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetSecurity;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
security_askboss := AskPassOnBossKeyOn;
security_writehist := logpref.writehistory;
security_backup := MakeBackups;
end;
Call('resetSecurity', [SQLDB.ManageSecurity(SA_CHECK), UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetHotkeys;
var
i: integer;
hotkeys: TParams;
begin
SetLength(hotkeys, Length(macros));
for i := 0 to Length(macros) - 1 do
begin
hotkeys[i] := VarArrayCreate([0, 3], varVariant);
hotkeys[i][0] := getTranslation(macro2str[macros[i].opcode]);
hotkeys[i][1] := IfThen(macros[i].hk and scCommand <> 0, 'Win+', '') + shortcutToText(macros[i].hk);
if macros[i].sw then
hotkeys[i][2] := getTranslation('Yes')
else
hotkeys[i][2] := getTranslation('No');
hotkeys[i][3] := macros[i].hk;
end;
Call('resetHotkeys', [hotkeys]);
end;
procedure TPrefs.ResetEvents;
var
obj: TPrefsObj;
st: Byte;
begin
obj := Default(TPrefsObj);
with obj do
begin
events_chatfocus := focusOnChatPopup;
events_inoutdur := minOnOffTime;
events_inoutignore := minOnOff;
events_awayisonline := incomingOnAway;
tempBeh := behaviour;
events_infoontop := AlertTopMost;
events_volume := Soundvolume;
events_skipseen := autoconsumeevents;
events_playsnd := playSounds;
for st := Low(Account.AccProto.Statuses) to High(Account.AccProto.Statuses) do
begin
OnStatusDisableLocal[st].tips := OnStatusDisable[st].tips;
OnStatusDisableLocal[st].blinking := OnStatusDisable[st].blinking;
OnStatusDisableLocal[st].sounds := OnStatusDisable[st].sounds;
OnStatusDisableLocal[st].OpenChat := OnStatusDisable[st].OpenChat;
end;
events_notinclosed := DsblEvnt4ClsdGrp;
events_logpacketswin := logpref.pkts.onWindow;
events_logpacketsfile := logpref.pkts.onFile;
events_logpacketsclear := logpref.pkts.Clear;
events_logeventswin := logpref.evts.onWindow;
events_logeventsfile := logpref.evts.onFile;
events_logeventsclear := logpref.evts.Clear;
events_bdinform := MainPrefs.getPrefBoolDef(PrefIsShowBDFirst, True);
events_bdnotify := MainPrefs.getPrefBoolDef(PrefIsShowBDBefore, True);
events_bdinformdur := MainPrefs.getPrefIntDef(PrefShowBDFirst, 7);
events_bdnotifydur := MainPrefs.getPrefIntDef(PrefShowBDBefore, 3);
end;
Call('resetEvents', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetPlugins;
var
i: Integer;
pls: TParams;
begin
i := 0;
plugins.resetEnumeration;
while plugins.hasMore do
begin
Inc(i);
SetLength(pls, i);
SetLength(pluginList, i);
pls[i-1] := VarArrayCreate([0, 2], varVariant);
pluginList[i-1] := plugins.getNext;
if pluginList[i-1].screenname = '' then
pls[i-1][0] := '(' + getTranslation('Not loaded') + ')'
else
pls[i-1][0] := pluginList[i-1].screenname;
pls[i-1][1] := pluginList[i-1].filename;
pls[i-1][2] := 0 = pos(pluginList[i-1].filename, disabledPlugins);
end;
Call('resetPlugins', [pls]);
end;
procedure TPrefs.ResetAutoupdate;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
autoupdate_beta := checkupdate.betas;
autoupdate_enable := checkupdate.enabled;
autoupdate_period := checkupdate.every;
end;
Call('resetAutoupdate', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.ResetThemeEdit;
var
ThemeObj: TPrefsObj;
begin
LoadThemeProps;
ThemeObj := Default(TPrefsObj);
ThemeObj.themeedit_contents := GetThemeProps;
ThemeObj.themeedit_maincss := MainCSS;
ThemeObj.themeedit_chatcss := ChatCSS;
Call('resetThemeEdit', [UI.RecordToVar(ThemeObj)]);
end;
procedure TPrefs.ResetOther;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
other_confirmexit := quitconfirmation;
other_autolayout := autoswitchKL;
other_notinlist := 2 - NILdoWith;
other_vacuum := optimizeDB;
other_indialog := showIncomingDlg;
other_mwheelspeed := wheelVelocity;
other_clautohide := inactiveHide;
other_clautohideval := inactivehideTime div 10;
other_trimws := InactiveTrim;
other_handleicqlinks := HandleICQLinks;
other_mybrowser := browserCmdLine;
other_browser := RDUtils.IfThen(useDefaultBrowser, 1);
other_servertoupload := ServerToUpload;
end;
Call('resetOther', [UI.RecordToVar(obj)]);
end;
procedure TPrefs.Init;
begin
for var Page in ArrPages do
case Page.idx of
1: InitConnection;
4: InitAutoaway;
6: InitChat;
10: InitStart;
16: InitHotkeys;
20: InitEvents;
96: InitThemeEdit;
99: InitOther;
end;
end;
procedure TPrefs.Reset;
begin
for var Page in ArrPages do
case page.idx of
1: ResetConnection;
2: ResetICQ;
3: ResetAntispam;
4: ResetAutoaway;
5: ResetDesign;
6: ResetChat;
7: ResetTips;
10: ResetStart;
15: ResetSecurity;
16: ResetHotkeys;
20: ResetEvents;
30: ResetPlugins;
95: ResetAutoupdate;
96: ResetThemeEdit;
99: ResetOther;
end;
end;
procedure TPrefs.SetViewMode(pages: array of TPrefPage);
var
i, j: Integer;
args: TParams;
begin
for I := Low(ArrPages) to High(ArrPages) do
FreeAndNil(ArrPages[I]);
if Length(pages) = 0 then
begin
j := Length(prefPages);
SetLength(ArrPages, j);
for i := 0 to j - 1 do
ArrPages[i] := prefPages[i].Clone;
end
else
begin
SetLength(ArrPages, Length(pages));
for i := 0 to Length(pages) - 1 do
ArrPages[i] := pages[i].Clone;
end;
SortPrefPages;
try
SetLength(args, Length(ArrPages));
for i := 0 to Length(ArrPages) - 1 do
begin
args[i] := VarArrayCreate([0, 2], varVariant);
args[i][0] := ArrPages[i].idx;
args[i][1] := ArrPages[i].Name;
args[i][2] := ArrPages[i].Caption;
end;
Call('setPages', [args]);
//SetActivePage(0);
except end;
Init;
Reset;
end;
procedure TPrefs.LoadThemeProps;
begin
FreeAndNil(ThemePropsIni);
ThemePropsIni := TMemIniFile.Create(AccPath + userthemeFilename);
ThemePropsIni.AutoSave := False;
end;
procedure TPrefs.SetThemeProps(const props: String; doUpdate: Boolean = False);
var
propsList: TStringList;
begin
propsList := TStringList.Create;
propsList.Text := props;
ThemePropsIni.SetStrings(propsList);
if doUpdate then
ThemePropsIni.UpdateFile;
propsList.Free;
end;
function TPrefs.GetThemeProps: String;
var
propsList: TStringList;
begin
propsList := TStringList.Create;
ThemePropsIni.GetStrings(propsList);
Result := propsList.Text;
propsList.Free;
end;
procedure TPrefs.SortPrefPages;
var
i: Integer;
pp: TPrefPage;
bool: Boolean;
begin
for i := Low(ArrPages) to High(ArrPages) do
begin
if ArrPages[i].idx = 0 then
ArrPages[i].idx := 100;
ArrPages[i].Caption := getTranslation(ArrPages[i].Caption);
end;
repeat
bool := True;
for i := 0 to High(ArrPages) - 1 do
if ArrPages[i].idx > ArrPages[i + 1].idx then
begin
pp := ArrPages[i];
ArrPages[i] := ArrPages[i + 1];
ArrPages[i + 1] := pp;
bool := False
end;
until bool;
end;
function TPrefs.HasPrefPage(pidx: Byte): Boolean;
begin
Result := False;
for var Page in ArrPages do
if Page.idx = pidx then
Result := True;
end;
procedure TPrefs.RefreshLangList;
var
iscf: ISpellCheckerFactory;
langs: IEnumString;
lang: PChar;
fetched: Cardinal;
LangItem: TLangItem;
locid: Cardinal;
LangItemArr: array of TLangItem;
LangArr: TParams;
i: Integer;
begin
langs := nil;
try
iscf := CoSpellCheckerFactory.Create;
iscf.Get_SupportedLanguages(langs);
except
Exit;
end;
if Assigned(langs) then
while langs.RemoteNext(1, lang, fetched) = S_OK do
begin
LangItem.lang := lang;
locid := Languages.LocaleIDFromName[lang];
if locid = 0 then
LangItem.locale := lang
else
LangItem.locale := Languages.NameFromLocaleID[locid];
SetLength(LangItemArr, Length(LangItemArr)+1);
LangItemArr[Length(LangItemArr)-1] := LangItem;
end;
SetLength(LangArr, Length(LangItemArr));
for i := 0 to Length(LangItemArr) - 1 do
LangArr[i] := UI.RecordToVar(LangItemArr[i]);
Call('refreshLangList', [LangArr])
end;
procedure TPrefs.ResetLangs;
begin
Call('resetLangs', [spellLanguages.ToStringArray]);
Call('resetMainLang', [spellLanguageMain]);
end;
procedure TPrefs.SetActivePage(i: Integer);
begin
Call('setActivePageByIndex', [i]);
end;
procedure TPrefs.SetActivePage(const pn: String);
begin
Call('setActivePageByName', [pn]);
end;
procedure TPrefs.FinishLoading;
begin
Call('finishLoading');
end;
class procedure TPrefsMethods.UpdatePrefsXY(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Rect: Variant;
begin
S2V(argv, Rect);
PrefsXY.Left := Rect[0];
PrefsXY.Top := Rect[1];
PrefsXY.Width := Rect[2];
PrefsXY.Height := Rect[3];
end;
class procedure TPrefsMethods.SetViewMode(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Arr: array of TPrefPage;
Page: String;
FullMode: Boolean;
I: Integer;
begin
Page := SciterVarToString(argv);
Inc(argv);
I := 0;
API.ValueIntData(argv, I);
FullMode := I = 1;
SetLength(Arr, 0);
if not (Page = '') then
if not FullMode then
for I := 0 to Length(prefPages) - 1 do
if prefPages[i].name = Page then
begin
SetLength(arr, 1);
Arr[0] := prefPages[i];
Break;
end;
UI.Prefs.SetViewMode(arr);
UI.Prefs.SetActivePage(Page);
UI.Prefs.FinishLoading;
SetLength(arr, 0);
end;
initialization
AddPrefPage(1, 'Connection');
AddPrefPage(2, 'ICQ');
AddPrefPage(3, 'Anti-spam');
AddPrefPage(4, 'Auto-away');
AddPrefPage(5, 'Design');
AddPrefPage(6, 'Chat');
AddPrefPage(7, 'Tips');
AddPrefPage(10, 'Start');
AddPrefPage(15, 'Security');
AddPrefPage(16, 'Hotkeys');
AddPrefPage(20, 'Events');
AddPrefPage(30, 'Plugins');
AddPrefPage(95, 'Updates');
AddPrefPage(96, 'Theme editor');
AddPrefPage(99, 'Other');
end.