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

3087 lines
90 KiB
Plaintext

{
This file is part of R&Q.
Under same license
}
unit prefSheet;
{$I RnQConfig.inc}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, System.Variants, System.IniFiles,
Vcl.Forms, Vcl.Controls, Vcl.StdCtrls, Vcl.Graphics, Vcl.Dialogs, Vcl.Imaging.PNGImage,
RnQPrefsLib, RQThemes, RQUtil, ICQCommon, Sciter, SciterApi, pluginLib;
{$I PubRTTI.inc}
type
TCaps = array [0.. 15] of String;
TPrefsObj = record
profile_index, profile_proxy, profile_proxyport,
icq_birthremind, icq_shareinfo, icq_inactinterval, icq_recentlyofflinedelay,
spam_ignoreuinvalue, spam_botattempts, spam_botquestion,
autoaway_setawaydelay, autoaway_setnadelay,
design_blinkspeed, design_clsort, design_clautosizedown, design_docking, 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_stickersize, chat_videores, chat_spellcheckstyle,
tips_max, tips_space, tips_opacity, tips_position, tips_hindent, tips_vindent,
start_withstatus,
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,
icq_savepass, icq_clearpass, icq_savetoken, icq_ident, icq_addcap,
icq_msgencrypt, icq_webaware,
icq_reqauth, icq_showtyping, icq_sendtyping, icq_recentlyoffline, 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_xnew,
design_trayclick, design_btips, design_blinkstatus, design_userthemes, design_snapwin, design_leveling, design_animwindows,
design_onlineonly, design_showtip, design_unauthasoff, design_enablegroups,
design_indentgrp, design_collapsegrp, design_animgrp, design_showborder, 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_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,
security_savehistpass,
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_minbeforehide, other_confirmexit, other_autolayout, other_vacuum, other_fixwin, other_indialog,
other_clautohide, 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_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;
TPrefSheet = class(TForm)
Sheet: TSciter;
ColorDialog: TColorDialog;
FontDialog: TFontDialog;
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure SheetScriptingCall(ASender: TObject; const Args: TElementOnScriptingCallArgs);
procedure FormDestroy(Sender: TObject);
procedure SheetLoadData(ASender: TObject; const url: WideString; resType: SciterResourceType; requestId: Pointer;
out discard, delay: Boolean);
protected
procedure WndProc(var msg: TMessage); override;
procedure WMNCActivate(var msg: TWMNCActivate); message WM_NCACTIVATE;
private
histPwd: String;
vOnStatusDisable: array of TOnStatusDisable;
pluginList: array of TPlugin;
themeprops: aTthemeproperty;
themepropsIni: TMemIniFile;
procedure SortPrefPages;
function HasPrefPage(pidx: Byte): Boolean;
procedure RefreshLangList;
procedure ResetLangs;
procedure AddToIgnoreAction(Sender: TObject);
procedure AddToQuietAction(Sender: TObject);
procedure LoadThemeProps;
procedure SetThemeProps(const props: String; doUpdate: Boolean = False);
function GetThemeProps: String;
public
arrPages: array of TPrefPage;
procedure InitConnection;
procedure InitChat;
procedure InitAutoaway;
procedure InitStart;
procedure InitHotkeys;
procedure InitEvents;
procedure InitThemeEdit;
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 ApplyFormXY;
procedure UpdateFormXY;
end;
PLangItem = ^TLangItem;
TLangItem = record
lang: String;
locale: String;
end;
var
PrefSheetFrm: TPrefSheet = nil;
implementation
uses
System.Generics.Collections, System.Rtti, System.NetEncoding, System.AnsiStrings, System.StrUtils,
Vcl.ComCtrls, Vcl.Menus, Winapi.ActiveX, Winapi.ShellAPI,
RDGlobal, RDUtils, RDFileUtil, RnQGlobal, RnQSysUtils, RnQLangs, RnQPics, RnQNet, RnQCrypt, RnQTips, RnQDialogs, RnQMacros,
events, globalLib, utilLib, themesLib, iniLib, roasterLib, langLib, SciterLib, Protocols_all, ICQSession, ICQConsts, ICQContacts,
mainDlg, selectcontactsDlg, chatDlg, tipDlg, HistAllSearch, Dynamic_Bass,
MsSpellCheckLib_TLB, RnQGraphics32, SQLiteDB;
{$R *.dfm}
var
PrefsObj: TPrefsObj;
v_proxyes: TArrProxy;
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
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;
procedure FormCloseCustom(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if Assigned(tag) then
TPrefSheet(tag).Close;
end;
procedure AddProfile(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
i: Integer;
begin
if tag = nil then
Exit;
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]);
TPrefSheet(tag).ResetConnection(True);
end;
procedure DeleteProfile(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
profile, i: Integer;
pr: array of TProxy;
begin
if tag = nil then
Exit;
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);
TPrefSheet(tag).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];
TPrefSheet(tag).ResetConnection(True);
end;
end;
procedure AddBotQuestion(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
i: Integer;
begin
if tag = nil then
Exit;
i := Length(qst);
SetLength(qst, i + 1);
with qst[i] do
begin
q := '';
SetLength(a, 0);
end;
TPrefSheet(tag).ResetAntispam(True);
end;
procedure DelBotQuestion(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
i, j: Integer;
begin
if tag = nil then
Exit;
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);
TPrefSheet(tag).ResetAntispam(True);
end;
procedure TPrefSheet.AddToIgnoreAction(Sender: TObject);
var
wnd: TselectCntsFrm;
cntct: TICQContact;
item: TListItem;
begin
if (not(Sender is Tcontrol)) or (not((Sender as Tcontrol).parent is TselectCntsFrm)) then
Exit;
wnd := (Sender as Tcontrol).parent as TselectCntsFrm;
cntct := wnd.current;
if cntct = nil then
// msgDlg('You must select contact', mtInformation)
else if AddToIgnorelist(cntct, True) then
begin
item.s0 := cntct.displayed;
if item.s0 <> cntct.UID then
item.s0 := item.s0 + ' (' + cntct.uin2Show + ')';
item.s1 := cntct.UID;
item.isSrv := Account.AccProto.IsInList(LT_SPAM, cntct);
Sheet.Call('addIgnoreListItem', [Sheet.RecordToVar(item)]);
end;
wnd.Close;
Self.SetFocus;
end;
procedure AddIgnoredContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cntcts: TselectCntsFrm;
begin
if tag = nil then
Exit;
cntcts := TselectCntsFrm.doAll(TPrefSheet(tag), 'Select contacts to ignore', 'Select', Account.AccProto,
notInList.clone.add(Account.AccProto.readList(LT_ROSTER)), TPrefSheet(tag).AddToIgnoreAction, [sco_groups], @cntcts);
end;
procedure AddIgnoredContactToSrv(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
if tag = nil then
Exit;
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);
// TPrefSheet(tag).Sheet.Call('setIgnoreListItemToSrv', [String(s)]);
end;
end;
procedure RemoveIgnoredContactFromSrv(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cnt: TICQContact;
s: PWideChar;
len: Cardinal;
begin
if tag = nil then
Exit;
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);
// TPrefSheet(tag).Sheet.Call('setIgnoreListItemToSrv', [String(s)]);
end;
end;
procedure DelIgnoredContact(tag: Pointer; 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;
procedure TPrefSheet.AddToQuietAction(Sender: TObject);
var
wnd: TselectCntsFrm;
cntct: TICQContact;
item: TListItem;
begin
if (not (Sender is TControl)) or (not ((Sender as TControl).parent is TselectCntsFrm)) then
Exit;
wnd := (Sender as TControl).parent as TselectCntsFrm;
cntct := wnd.current;
if cntct = nil then
// msgDlg('You must select contact', mtInformation)
else if addToQuietlist(cntct) then
begin
item.s0 := cntct.displayed;
if item.s0 <> cntct.UID then
item.s0 := item.s0 + ' (' + cntct.uin2Show + ')';
item.s1 := cntct.UID;
item.isSrv := False;
Sheet.Call('addQuietListItem', [Sheet.RecordToVar(item)]);
end;
wnd.Close;
Self.SetFocus;
end;
procedure AddQuietContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
cntcts: TselectCntsFrm;
begin
if tag = nil then
Exit;
cntcts := TselectCntsFrm.doAll(TPrefSheet(tag), 'Select contacts to quiet', 'Select', Account.AccProto,
notInList.clone.add(Account.AccProto.readList(LT_ROSTER)), TPrefSheet(tag).AddToQuietAction, [sco_groups], @cntcts);
end;
procedure DelQuietContact(tag: Pointer; 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
begin
SetLength(a, Length(a) + 1);
a[Length(a) - 1] := Trim(answ.Strings[i]);
end;
answ.Free;
end;
end;
procedure StoreProfile(tag: Pointer; 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;
procedure StoreQuestion(tag: Pointer; 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;
procedure UpdateQuestions(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if tag = nil then
Exit;
TPrefSheet(tag).ResetAntispam(True);
end;
procedure UpdateMainProfile(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
last: Integer;
begin
if (tag = nil) or (argc = 0) then
Exit;
last := 0;
API.ValueIntData(argv, last);
CopyProxy(MainProxy, v_proxyes[last]);
TPrefSheet(tag).ResetConnection(True);
end;
procedure OpenContactChat(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
s: PWideChar;
len: Cardinal;
begin
s := '';
API.ValueStringData(argv, s, len);
if Assigned(chatFrm) then
chatFrm.openOn(Account.AccProto.GetContact(s));
end;
procedure ViewContactInfo(tag: Pointer; 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;
procedure PrefsApply(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
function HexArr2Str(const caps: TCaps): RawByteString;
var
i: Integer;
begin
Result := '';
for i := 0 to 15 do
if (caps[i] = '') or (caps[i] = '00') or (caps[i] = '0') or (caps[i] = #00) then
Result := Result + #32
else
Result := Result + Char(StrToInt('$' + caps[i]));
Result := String(Result).TrimRight([#32]);
if Length(Result) < 16 then
for i := Length(Result) to 15 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: Integer;
icq: TICQSession;
cnt: TICQContact;
prefs: TPrefSheet;
sheet: TSciter;
page: TPrefPage;
mustUpdPerms, mustUpdSts,
mustApplyTransp, mustRebuildCL, mustUpdCapt, mustLoadStickers, mustResetHistory: Boolean;
str: PWideChar;
sz, strLen: UINT;
tmpVal, tmpVal2: TSciterValue;
st: Byte;
disPlugins: TStringList;
begin
if Assigned(tag) then
begin
prefs := TPrefSheet(tag);
sheet := prefs.Sheet;
end else
Exit;
PrefsObj := Default(TPrefsObj);
API.ValueEnumElements(argv, @ObjToPrefs, nil);
// mustRepaintCL := False;
mustRebuildCL := False;
mustResetHistory := False;
Inc(argv);
if prefs.HasPrefPage(5) then
begin
API.ValueElementsCount(argv, sz);
for i := 0 to sz - 1 do
begin
API.ValueNthElementValue(argv, i, tmpVal);
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 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 prefs.HasPrefPage(6) then
API.ValueIntData(argv, errClr);
i := 0;
Inc(argv);
if 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 prefs, 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 page in 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;
end else if page.idx = 2 then
begin
// ICQ protocol
// if not Assigned(Account.AccProto) or not (Account.AccProto.ProtoName = 'ICQ') then
// Exit;
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.webaware = icq_webaware) then
begin
icq.webaware := icq_webaware;
mustUpdPerms := True;
mustUpdSts := True;
end;
if not (icq.showInfo = icq_shareinfo) then
begin
icq.showInfo := icq_shareinfo;
mustUpdPerms := True;
// mustUpdSts := True;
end;
if not (icq.authNeeded = icq_reqauth) then
begin
icq.authNeeded := icq_reqauth;
mustUpdPerms := True;
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;
icq.AvatarsSupport := icq_enableavatars;
icq.AvatarsAutoGet := icq_autoavatars;
AvatarsNotDnlddInform := icq_failedavatars;
AutoRequestXsts := icq_autoxstatus;
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);
SaveListsDelayed := True;
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;
BarPos := design_clbar;
FilterPos := design_clfilterbar;
rosterbarOnTop := design_clbar = 0;
filterBarOnTop := design_clfilterbar = 0;
animatedRoster := design_animgrp;
AnimateWindows := design_animwindows;
showXStatusMnu := design_xbutton;
if sortBy <> index2sb(design_clsort) then
begin
mustRebuildCL := True;
sortBy := index2sb(design_clsort);
end;
// mustRepaintCL := mustRepaintCL or not (ShowUINDelimiter = design_uindelim) or
// not (UseContactThemes = design_userthemes) or not (indentRoster = design_indentgrp);
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;
showNewXStatuses := design_xnew;
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);
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;
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);
docking.enabled := design_docking > 0;
docking.appBar := design_docking = 2;
dockSet;
if mustApplyTransp then
applyTransparency;
if mustUpdCapt then
RnQmain.UpdateCaption;
RnQmain.FormResize(nil);
RnQmain.CLBox.InitSettings;
RnQmain.CLBox.InitMenus;
RnQmain.CLBox.UpdateAdditionalImage;
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;
StickerResolution := chat_stickersize;
ChatImageQuality := chat_chatimgquality;
PreferredResolution := chat_videores;
EnableVideoLinks := chat_videothumbs;
ChatSmoothFontRendering := chat_smoothrender;
AnimatedScroll := chat_animatedscroll;
TrimMsgNewLines := chat_msgtrim;
EnableSpellCheck := chat_spellcheck;
RelativeTimeInChatDays := BoundInt(chat_reldays, 2, 31);
RelativeTimeInChatHours := BoundInt(chat_relhours, 0, 24);
spellErrorColor := errClr;
spellErrorStyle := chat_spellcheckstyle;
i := BoundInt(chat_msgbuffer, 10, 50);
if not (ChatLoadBuffer = i) then
begin
ChatLoadBuffer := i;
mustResetHistory := True;
end;
if Assigned(chatFrm) then
with chatFrm do
begin
InitSpellCheck;
SpellCheck;
if mustLoadStickers then
LoadChatStickers;
if Visible then
begin
SetupChatButtons;
SetupStickersButton;
end;
RedrawTabs;
if RelativeTimeInChat then
UpdateRelTimes;
end;
end else if page.idx = 7 then
begin
// Tips
transparency.forTray := tips_transparency;
transparency.tray := BoundInt(tips_opacity, 0, 255);
tipstransparency.enabled := tips_transparency;
tipstransparency.alpha := 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 := 0;
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;
histcrypt.savePwd := security_savehistpass;
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;
BringInfoFrgd := 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 prefs do
begin
OnStatusDisable[st].tips := vOnStatusDisable[st].tips;
OnStatusDisable[st].blinking := vOnStatusDisable[st].blinking;
OnStatusDisable[st].sounds := vOnStatusDisable[st].sounds;
OnStatusDisable[st].OpenChat := vOnStatusDisable[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
ChatCSS := themeedit_chatcss;
with 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;
minimizeroster := other_minbeforehide;
browserCmdLine := other_mybrowser;
useDefaultBrowser := other_browser = 1;
autoswitchKL := other_autolayout;
NILdoWith := 2 - other_notinlist;
showIncomingDlg := other_indialog;
optimizeDB := other_vacuum;
doFixWindows := other_fixwin;
wheelVelocity := BoundInt(other_mwheelspeed, 1, 30);
inactivehideTime := BoundInt(other_clautohideval, 0, 36000) * 10;
inactiveHide := other_clautohide;
ServerToUpload := other_servertoupload;
HandleICQLinks := other_handleicqlinks;
SetICQLinksHandler(HandleICQLinks);
end;
CommonMethods.InitSettings;
// Updates
if mustRebuildCL then
roasterLib.rebuild;
// else if mustRepaintCL then
// RosterRepaintDelayed := True;
if Assigned(chatFrm) then
with chatFrm do
begin
UpdateChatSettings;
if mustResetHistory then
ResetHistory;
end;
if Assigned(AllHistSrchForm) then
AllHistSrchForm.UpdateChatSettings;
if Assigned(RnQmain) then
SaveCfgDelayed := True;
SaveCommonCFG;
end;
procedure PrefsReset(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if Assigned(tag) then
TPrefSheet(tag).Reset;
end;
procedure IsOnline(tag: Pointer; 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;
procedure ApplyTransp(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
val: Integer;
begin
val := -1;
API.ValueIntData(argv, val);
applyTransparency(val);
end;
procedure ChooseColor(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
clr: Integer;
cclr: String;
begin
if (tag = nil) or not running then
Exit;
clr := 0;
if argc > 0 then
API.ValueIntData(argv, clr);
with TPrefSheet(tag) do
begin
ColorDialog.Color := clr;
if ColorDialog.Execute(Handle) then
begin
cclr := Color2HTML(ColorDialog.Color);
API.ValueStringDataSet(retval, PWideChar(cclr), Length(cclr), 0);
end else
API.ValueIntDataSet(retval, 0, T_BOOL, 0);
end;
end;
procedure GetFont(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
openDlg: Integer;
cclr: String;
tmpVal: TSciterValue;
begin
if (tag = nil) or not running then
Exit;
openDlg := 0;
API.ValueIntData(argv, openDlg);
with TPrefSheet(tag) do
begin
if (openDlg = 0) or ((openDlg = 1) and FontDialog.Execute(Handle)) 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;
procedure SetFontProps(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
fsize, fcolor: Integer;
begin
if (tag = nil) or not running then
Exit;
fsize := 14;
fcolor := 0;
API.ValueIntData(argv, fsize);
Inc(argv);
API.ValueIntData(argv, fcolor);
with TPrefSheet(tag) do
begin
FontDialog.Font.Size := fsize;
FontDialog.Font.Color := fcolor;
end;
end;
procedure RefreshLangs(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if (tag = nil) or not running then
Exit;
TPrefSheet(tag).RefreshLangList;
TPrefSheet(tag).ResetLangs;
end;
procedure ManageLangs(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
path: String;
begin
if (tag = nil) or not running then
Exit;
with TPrefSheet(tag) do
if TOSVersion.Check(10) then
ShellExecute(Handle, '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(Handle, 'open', PChar(Format(path, ['ru-RU'])), '', '', SW_SHOWNORMAL) <= 32 then
ShellExecute(Handle, 'open', PChar(Format(path, ['en-US'])), '', '', SW_SHOWNORMAL);
end;
end;
procedure UserDicts(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if (tag = nil) or not running then
Exit;
ShellExecute(TPrefSheet(tag).Handle, 'open', PChar(expandEnv('%AppData%') + '\Microsoft\Spelling'), '', '', SW_SHOWNORMAL);
end;
procedure SetMainSpellcheckLang(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
str: PWideChar;
strLen: UINT;
begin
if (tag = nil) or (argc = 0) then
Exit;
str := '';
API.ValueStringData(argv, str, strLen);
spellLanguageMain := str;
end;
procedure TestTips(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
e: Thevent;
i: Integer;
s: AnsiString;
begin
i := EK_msg;
s := '';
e := Thevent.new(i, nil, Account.AccProto.getMyInfo, now, s + getTranslation('Testing') + CRLF + 'Second row ------- :)', [], 0);
TipAdd3(e);
e.Free;
end;
procedure GetCurrentUIN(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
uin: String;
begin
uin := Account.AccProto.MyAccNum;
API.ValueStringDataSet(retval, PWideChar(uin), Length(uin), 0);
end;
procedure GetXStatusMsg(tag: Pointer; 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;
procedure GetChatStyles(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
SR: TSearchRec;
CSSThemes: array of Variant;
begin
SetLength(CSSThemes, 0);
if FindFirst(MyPath + themesPath + 'CSS\Chat_*.css', faAnyFile, SR) = 0 then
repeat
if SR.Name[1] <> '.' then
begin
SetLength(CSSThemes, Length(CSSThemes) + 1);
CSSThemes[Length(CSSThemes) - 1] := MyPath + themesPath + 'CSS\' + SR.Name;
end;
until FindNext(SR) <> 0;
FindClose(SR);
V2S(CSSThemes, retval);
end;
procedure EncryptHistory(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if (tag = nil) or not running then
Exit;
with TPrefSheet(tag) do
begin
histPwd := CommonMethods.EnterPassword(GetTranslation('History password'), 0);
if histPwd = '' then
Exit;
if histcrypt.enabled then
begin
if MessageDlg(GetTranslation('Are you sure want to change the history password?'), mtConfirmation, [mbYes, mbCancel]) = ID_Cancel then
Exit;
if SQLDB.ManageSecurity(SA_CHANGEPASS, histPwd) and histcrypt.enabled then
MessageDlg(GetTranslation('History password was modified!'), mtInformation, [mbOK])
else
MessageDlg(GetTranslation('History password wasn''t modified!'), mtError, [mbOK]);
end
else
begin
if MessageDlg(GetTranslation('Are you sure want to encrypt the entire history?'), mtConfirmation, [mbYes, mbCancel]) = ID_Cancel then
Exit;
if SQLDB.ManageSecurity(SA_ENCRYPT, histPwd) and histcrypt.enabled then
MessageDlg(GetTranslation('History was successfully encrypted!'), mtInformation, [mbOK])
else
MessageDlg(GetTranslation('History was not encrypted!'), mtError, [mbOK]);
end;
ResetSecurity;
end;
end;
procedure DecryptHistory(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if (tag = nil) or not running then
Exit;
with TPrefSheet(tag) do
begin
if histPwd = '' then
histPwd := CommonMethods.EnterPassword(GetTranslation('History password'), 0);
if histPwd = '' then
Exit;
if MessageDlg(GetTranslation('Are you sure want to decrypt the history?'), mtConfirmation, [mbYes, mbCancel]) = ID_Cancel then
Exit;
if SQLDB.ManageSecurity(SA_DECRYPT, histPwd) and not histcrypt.enabled then
MessageDlg(GetTranslation('History was successfully decrypted!'), mtInformation, [mbOK])
else
MessageDlg(GetTranslation('History was not decrypted!'), mtError, [mbOK]);
ResetSecurity;
end;
end;
procedure GetKeyName(tag: Pointer; 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;
procedure HotkeySelect(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
aRow: integer;
begin
if (tag = nil) or (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
TPrefSheet(tag).Sheet.Call('setCurrentHotkey', [hk and not $1000, shortcutToText(hk), sw, hk and $1000 > 0, opcode - 1]);
end;
procedure HotkeyDefault(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if (tag = nil) or 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);
TPrefSheet(tag).ResetHotkeys;
end;
procedure HotkeySave(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
hotkey, sw, index: Integer;
begin
if (tag = nil) or (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);
TPrefSheet(tag).ResetHotkeys;
end;
procedure HotkeyDelete(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
aRow: Integer;
begin
aRow := -1;
API.ValueIntData(argv, aRow);
removeMacro(aRow);
end;
procedure UpdateEventTriggers(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
ev, i: Integer;
ac: Tbehaction;
triggers: array of Variant;
begin
if (tag = nil) or (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;
TPrefSheet(tag).Sheet.Call('updateEventTriggers', [triggers, BE_tip in supportedBehactions[ev], tempBeh[ev].tiptimes, tempBeh[ev].tiptime / 10, tempBeh[ev].tiptimeplus / 10]);
end;
end;
procedure StoreEventTrigger(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
ev, tmp: Integer;
ac: Tbehaction;
dur, plus: Double;
chk, multiply: Boolean;
begin
if (tag = nil) or (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;
procedure UpdateDisabledEvents(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
status: Integer;
events: array of Variant;
begin
if (tag = nil) or (argc = 0) or not running then
Exit;
status := -1;
API.ValueIntData(argv, status);
if status >= 0 then
with TPrefSheet(tag) do
begin
SetLength(events, 4);
events[0] := vOnStatusDisable[status].tips;
events[1] := vOnStatusDisable[status].blinking;
events[2] := vOnStatusDisable[status].sounds;
events[3] := vOnStatusDisable[status].OpenChat;
Sheet.Call('updateDisabledEvents', [events]);
end;
end;
procedure StoreDisabledEvents(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
status, tmp: Integer;
tips, blink, sound, chat: Boolean;
begin
if (tag = nil) or (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 TPrefSheet(tag) do
begin
vOnStatusDisable[status].tips := tips;
vOnStatusDisable[status].blinking := blink;
vOnStatusDisable[status].sounds := sound;
vOnStatusDisable[status].OpenChat := chat;
end;
end;
procedure PlaySound(tag: Pointer; 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;
procedure SoundTest(tag: Pointer; 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;
procedure TimeTest(tag: Pointer; 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);
TipAdd3(e);
e.Free;
end;
end;
procedure IsAudioPresent(tag: Pointer; 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;
procedure BASSWarning(tag: Pointer; 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;
procedure ReloadPlugins(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
begin
if (tag = nil) or not running then
Exit;
plugins.unload;
plugins.load;
TPrefSheet(tag).ResetPlugins;
end;
procedure OpenPluginPrefs(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
index: Integer;
begin
if (tag = nil) or not running then
Exit;
index := -1;
API.ValueIntData(argv, index);
if index >= 0 then
TPrefSheet(tag).pluginList[index].cast_preferences
end;
procedure UpdateThemeEditProp(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
index: Integer;
p: ^Tthemeproperty;
data: Variant;
begin
if (tag = nil) or not running then
Exit;
index := -1;
API.ValueIntData(argv, index);
if index >= 0 then
with TPrefSheet(tag) 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;
Sheet.Call('refreshThemeEdit', [p.kind, data]);
end;
end;
procedure AddThemeProp(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
index, tmpInt: Integer;
props, tmpStr: PWideChar;
strLen: Cardinal;
p: ^Tthemeproperty;
chrst: String;
begin
if (tag = nil) or not running then
Exit;
props := '';
API.ValueStringData(argv, props, strLen);
Inc(argv);
index := -1;
API.ValueIntData(argv, index);
if index >= 0 then
with TPrefSheet(tag) 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;
procedure CheckPath(tag: Pointer; 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;
procedure TPrefSheet.FormClose(Sender: TObject; var Action: TCloseAction);
var
i: Integer;
begin
UpdateFormXY;
updateSWhotkeys;
hotkeysEnabled := True;
Action := caFree;
PrefSheetFrm := nil;
for i := Low(arrPages) to High(arrPages) do
FreeAndNil(arrPages[i]);
SetLength(arrPages, 0);
end;
procedure TPrefSheet.FormCreate(Sender: TObject);
begin
Icon.Handle := LoadIcon(hInstance, 'rnqnewsmallico');
themepropsIni := nil;
LoadThemeProps;
ApplyFormXY;
Sheet.LoadTemplate('template', 'preferences.htm');
end;
procedure TPrefSheet.FormDestroy(Sender: TObject);
begin
FreeAndNil(themepropsIni);
SetLength(vOnStatusDisable, 0);
SetLength(pluginList, 0);
SetLength(themeprops, 0);
if Assigned(Sheet) then
Sheet.Call('unInit', []);
end;
procedure TPrefSheet.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = VK_ESCAPE) or ((ssCtrl in Shift) and (key = VK_W))then
Close
end;
procedure TPrefSheet.FormResize(Sender: TObject);
begin
UpdateFormXY
end;
procedure TPrefSheet.FormShow(Sender: TObject);
begin
ApplyFormXY;
applyTaskButton(Self);
Caption := getTranslation('Preferences for %s', [RnQUser]);
end;
procedure TPrefSheet.InitConnection;
begin
// Sheet.Call('initConnection', []);
end;
procedure TPrefSheet.InitChat;
begin
if CheckWin32Version(6, 2) then
RefreshLangList
else begin
EnableSpellCheck := False;
Sheet.Call('hideSpellcheck', []);
end;
end;
procedure TPrefSheet.InitAutoaway;
var
x: Integer;
xstatuses: array of Variant;
begin
for x := Low(XStatusArray) to High(XStatusArray) do
if (xsf_6 in XStatusArray[x].flags) then
if not(StartsText('status_', XStatusArray[X].pid6)) then
begin
SetLength(xstatuses, Length(xstatuses) + 1);
xstatuses[Length(xstatuses) - 1] := VarArrayCreate([0, 2], varVariant);
xstatuses[Length(xstatuses) - 1][0] := x;
xstatuses[Length(xstatuses) - 1][1] := XStatusArray[x].PicName;
xstatuses[Length(xstatuses) - 1][2] := GetTranslation(XStatusArray[x].Caption);
end;
Sheet.Call('initAutoaway', [xstatuses]);
end;
procedure TPrefSheet.InitStart;
var
i: Integer;
status, vis: array of Variant;
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;
Sheet.Call('initStart', [status, vis]);
end;
procedure TPrefSheet.InitHotkeys;
var
actions: array of Variant;
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]);
Sheet.Call('initHotkeys', [actions]);
end;
procedure TPrefSheet.InitEvents;
var
i, j: Integer;
st: Byte;
events, statuses: array of Variant;
begin
SetLength(vOnStatusDisable, 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 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;
Sheet.Call('initEvents', [events, statuses]);
end;
procedure TPrefSheet.InitThemeEdit;
var
i: Integer;
Props: array of Variant;
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;
Sheet.Call('initThemeEdit', [Props, ChatCSS]);
end;
{
function EscapeQuotes(text: String): String;
begin
Result := text.Replace('\', '\\', [rfReplaceAll]).Replace('"', '\"', [rfReplaceAll]);
end;
}
function FromHTML(const text: String): String;
begin
Result := THTMLEncoding.HTML.Decode(text);
end;
procedure TPrefSheet.ResetConnection(ProfileOnly: Boolean = False);
var
profiles: array of Variant;
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;
end;
Sheet.Call('resetConnection', [profiles, ProfileOnly, Sheet.RecordToVar(obj)]);
end;
end;
procedure TPrefSheet.ResetICQ;
function Str2HexArr(const s: RawByteString): TCaps;
var
i: Integer;
begin
for i := 1 to Length(s) do
Result[i-1] := IntToHex(ord(s[i]), 2);
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_enableavatars := icq.AvatarsSupport;
icq_autoavatars := icq.AvatarsAutoGet;
icq_failedavatars := AvatarsNotDnlddInform;
icq_autoxstatus := AutoRequestXsts;
end;
Sheet.Call('resetICQ', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetAntispam(QuestionsOnly: Boolean = False);
var
obj: TPrefsObj;
questions: array of Variant;
ignores, quiets: array of Variant;
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] := Sheet.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] := Sheet.RecordToVar(qts[i]);
qst := Copy(SpamFilter.Quests);
end;
SetLength(questions, Length(qst));
for i := 0 to Length(qst) - 1 do
questions[i] := Sheet.RecordToVar(qst[i]);
Sheet.Call('resetAntispam', [questions, QuestionsOnly, ignores, quiets, Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.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;
Sheet.Call('resetAutoaway', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetDesign;
var
obj: TPrefsObj;
items: array of Variant;
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_xnew := showNewXStatuses;
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;
if not docking.enabled then
design_docking := 0
else if not docking.appBar then
design_docking := 1
else
design_docking := 2;
design_clbar := BarPos;
design_clfilterbar := FilterPos;
design_clsort := sb2index[sortBy];
design_wintitle := rosterTitle;
design_clautosizeup := autosizeUp;
design_showtip := ShowHintsInCL;
design_animgrp := animatedRoster;
design_animwindows := AnimateWindows;
design_uindelim := ShowUINDelimiter;
design_showborder := showMainBorder;
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] := Sheet.RecordToVar(RnQCLIcons[SHOW_ICONS_ORDER[i]]);
items[i][1] := TO_SHOW_ICON[SHOW_ICONS_ORDER[i]];
end;
Sheet.Call('resetDesign', [items, Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.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_stickersize := StickerResolution;
chat_chatimgquality := ChatImageQuality;
chat_videores := PreferredResolution;
chat_videothumbs := EnableVideoLinks;
chat_smoothrender := ChatSmoothFontRendering;
chat_animatedscroll := AnimatedScroll;
chat_msgtrim := TrimMsgNewLines;
chat_spellcheck := EnableSpellCheck;
chat_maximgwidthval := MaxChatImgWidthVal;
chat_maximgheightval := MaxChatImgHeightVal;
chat_closetabonsingle := ClosePageOnSingle;
chat_spellcheckstyle := spellErrorStyle;
chat_reldays := RelativeTimeInChatDays;
chat_relhours := RelativeTimeInChatHours;
end;
Sheet.Call('resetChat', [Color2HTML(spellErrorColor), Sheet.RecordToVar(obj)]);
ResetLangs;
end;
procedure TPrefSheet.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;
Sheet.Call('resetTips', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.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_firstonly := uselastStatus;
start_skipsplash := skipSplash;
start_lock := lockOnStart;
end;
Sheet.Call('resetStart', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetSecurity;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
security_askboss := AskPassOnBossKeyOn;
security_writehist := logpref.writehistory;
security_backup := MakeBackups;
histPwd := histcrypt.pwd;
security_savehistpass := histcrypt.savePwd;
end;
Sheet.Call('resetSecurity', [histcrypt.Enabled, Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetHotkeys;
var
i: integer;
hotkeys: array of Variant;
begin
SetLength(hotkeys, Length(macros));
for i := 0 to Length(macros) - 1 do
begin
hotkeys[i] := VarArrayCreate([0, 2], varVariant);
hotkeys[i][0] := getTranslation(macro2str[macros[i].opcode]);
hotkeys[i][1] := RDUtils.IfThen(macros[i].hk and $1000 > 0, 'Win+', '') + shortcutToText(macros[i].hk);
if macros[i].sw then
hotkeys[i][2] := getTranslation('Yes')
else
hotkeys[i][2] := getTranslation('No');
end;
Sheet.Call('resetHotkeys', [hotkeys]);
end;
procedure TPrefSheet.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 := BringInfoFrgd;
events_volume := Soundvolume;
events_skipseen := autoconsumeevents;
events_playsnd := playSounds;
for st := Low(Account.AccProto.Statuses) to High(Account.AccProto.Statuses) do
begin
vOnStatusDisable[st].tips := OnStatusDisable[st].tips;
vOnStatusDisable[st].blinking := OnStatusDisable[st].blinking;
vOnStatusDisable[st].sounds := OnStatusDisable[st].sounds;
vOnStatusDisable[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;
Sheet.Call('resetEvents', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetPlugins;
var
i: Integer;
pls: array of Variant;
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;
Sheet.Call('resetPlugins', [pls]);
end;
procedure TPrefSheet.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;
Sheet.Call('resetAutoupdate', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetThemeEdit;
var
obj: TPrefsObj;
begin
LoadThemeProps;
obj := Default(TPrefsObj);
obj.themeedit_contents := GetThemeProps;
obj.themeedit_chatcss := ChatCSS;
Sheet.Call('resetThemeEdit', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.ResetOther;
var
obj: TPrefsObj;
begin
obj := Default(TPrefsObj);
with obj do
begin
other_confirmexit := quitconfirmation;
other_minbeforehide := minimizeroster;
other_autolayout := autoswitchKL;
other_notinlist := 2 - NILdoWith;
other_vacuum := optimizeDB;
other_fixwin := doFixWindows;
other_indialog := showIncomingDlg;
other_mwheelspeed := wheelVelocity;
other_clautohide := inactiveHide;
other_clautohideval := inactivehideTime div 10;
other_handleicqlinks := HandleICQLinks;
other_mybrowser := browserCmdLine;
other_browser := RDUtils.IfThen(useDefaultBrowser, 1);
other_servertoupload := ServerToUpload;
end;
Sheet.Call('resetOther', [Sheet.RecordToVar(obj)]);
end;
procedure TPrefSheet.Init;
var
page: TPrefPage;
begin
for page in arrPages do
case page.idx of
1: InitConnection;
6: InitChat;
4: InitAutoaway;
10: InitStart;
16: InitHotkeys;
20: InitEvents;
96: InitThemeEdit;
end;
end;
procedure TPrefSheet.Reset;
var
page: TPrefPage;
begin
for 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 TPrefSheet.SetViewMode(pages: array of TPrefPage);
var
i, j: Integer;
args: array of Variant;
begin
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;
Sheet.Call('setPages', [args]);
SetActivePage(0);
except
PrefSheetFrm := nil;
end;
Init;
Reset;
end;
procedure TPrefSheet.SheetLoadData(ASender: TObject; const url: WideString; resType: SciterResourceType; requestId: Pointer; out discard, delay: Boolean);
begin
Sheet.InitRequest(ASender, url, resType, requestId, discard, delay);
end;
procedure TPrefSheet.SheetScriptingCall(ASender: TObject; const Args: TElementOnScriptingCallArgs);
begin
if Args.Method = 'getNativeApi' then
with TSciter do
begin
RegisterNativeFunctor(Args.ReturnSciterValue, 'FormClose', @FormCloseCustom, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'PrefsReset', @PrefsReset, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'PrefsApply', @PrefsApply, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'AddProfile', @AddProfile, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'DeleteProfile', @DeleteProfile, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'AddBotQuestion', @AddBotQuestion, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'DelBotQuestion', @DelBotQuestion, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'AddIgnoredContact', @AddIgnoredContact, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'AddIgnoredContactToSrv', @AddIgnoredContactToSrv, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'RemoveIgnoredContactFromSrv', @RemoveIgnoredContactFromSrv, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'DelIgnoredContact', @DelIgnoredContact);
RegisterNativeFunctor(Args.ReturnSciterValue, 'AddQuietContact', @AddQuietContact, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'DelQuietContact', @DelQuietContact);
RegisterNativeFunctor(Args.ReturnSciterValue, 'StoreProfile', @StoreProfile);
RegisterNativeFunctor(Args.ReturnSciterValue, 'StoreQuestion', @StoreQuestion);
RegisterNativeFunctor(Args.ReturnSciterValue, 'UpdateMainProfile', @UpdateMainProfile, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'UpdateQuestions', @UpdateQuestions, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'ViewContactInfo', @ViewContactInfo);
RegisterNativeFunctor(Args.ReturnSciterValue, 'OpenContactChat', @OpenContactChat);
RegisterNativeFunctor(Args.ReturnSciterValue, 'IsOnline', @IsOnline);
RegisterNativeFunctor(Args.ReturnSciterValue, 'ApplyTransparency', @ApplyTransp);
RegisterNativeFunctor(Args.ReturnSciterValue, 'ChooseColor', @ChooseColor, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'GetFont', @GetFont, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'SetFontProps', @SetFontProps, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'RefreshLangs', @RefreshLangs, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'ManageLangs', @ManageLangs, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'UserDicts', @UserDicts, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'SetMainSpellcheckLang', @SetMainSpellcheckLang, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'TestTips', @TestTips, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'GetCurrentUIN', @GetCurrentUIN);
RegisterNativeFunctor(Args.ReturnSciterValue, 'EncryptHistory', @EncryptHistory, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'DecryptHistory', @DecryptHistory, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'GetKeyName', @GetKeyName);
RegisterNativeFunctor(Args.ReturnSciterValue, 'HotkeySelect', @HotkeySelect, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'HotkeyDefault', @HotkeyDefault, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'HotkeySave', @HotkeySave, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'HotkeyDelete', @HotkeyDelete);
RegisterNativeFunctor(Args.ReturnSciterValue, 'UpdateEventTriggers', @UpdateEventTriggers, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'StoreEventTrigger', @StoreEventTrigger, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'UpdateDisabledEvents', @UpdateDisabledEvents, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'StoreDisabledEvents', @StoreDisabledEvents, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'SoundTest', @SoundTest);
RegisterNativeFunctor(Args.ReturnSciterValue, 'PlaySound', @PlaySound);
RegisterNativeFunctor(Args.ReturnSciterValue, 'TimeTest', @TimeTest);
RegisterNativeFunctor(Args.ReturnSciterValue, 'IsAudioPresent', @IsAudioPresent);
RegisterNativeFunctor(Args.ReturnSciterValue, 'BASSWarning', @BASSWarning);
RegisterNativeFunctor(Args.ReturnSciterValue, 'ReloadPlugins', @ReloadPlugins, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'OpenPluginPrefs', @OpenPluginPrefs, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'UpdateThemeEditProp', @UpdateThemeEditProp, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'AddThemeProp', @AddThemeProp, Self);
RegisterNativeFunctor(Args.ReturnSciterValue, 'CheckPath', @CheckPath);
RegisterNativeFunctor(Args.ReturnSciterValue, 'GetXStatusMsg', @GetXStatusMsg);
RegisterNativeFunctor(Args.ReturnSciterValue, 'GetChatStyles', @GetChatStyles);
Args.Handled := True;
end;
end;
procedure TPrefSheet.LoadThemeProps;
begin
FreeAndNil(themepropsIni);
themepropsIni := TMemIniFile.Create(AccPath + userthemeFilename);
themepropsIni.AutoSave := False;
end;
procedure TPrefSheet.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 TPrefSheet.GetThemeProps: String;
var
propsList: TStringList;
begin
propsList := TStringList.Create;
themepropsIni.GetStrings(propsList);
Result := propsList.Text;
propsList.Free;
end;
procedure TPrefSheet.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 TPrefSheet.HasPrefPage(pidx: Byte): Boolean;
var
page: TPrefPage;
begin
Result := False;
for page in arrPages do
if page.idx = pidx then
Result := True;
end;
procedure TPrefSheet.RefreshLangList;
var
iscf: ISpellCheckerFactory;
langs: IEnumString;
lang: PChar;
fetched: Cardinal;
LangItem: TLangItem;
locid: Cardinal;
LangItemArr: array of TLangItem;
LangArr: array of Variant;
i: Integer;
begin
iscf := nil;
if Succeeded(CoCreateInstance(CLASS_SpellCheckerFactory, nil, CLSCTX_INPROC_SERVER, IID_ISpellCheckerFactory, iscf)) and Assigned(iscf) then
begin
langs := nil;
iscf.Get_SupportedLanguages(langs);
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] := Sheet.RecordToVar(LangItemArr[i]);
Sheet.Call('refreshLangList', [LangArr])
end;
end;
procedure TPrefSheet.ResetLangs;
begin
Sheet.Call('resetLangs', [spellLanguages.ToStringArray]);
Sheet.Call('resetMainLang', [spellLanguageMain]);
end;
procedure TPrefSheet.SetActivePage(i: Integer);
begin
Sheet.Call('setActivePageByIndex', [i]);
end;
procedure TPrefSheet.SetActivePage(const pn: String);
begin
Sheet.Call('setActivePageByName', [pn]);
end;
procedure TPrefSheet.ApplyFormXY;
begin
with settingsfrmXY do
if Width > 0 then
if maximized then
begin
SetBounds(Left, Top, Width, Height);
WindowState := wsMaximized;
end
else
begin
SetBounds(Left, Top, Width, Height);
WindowState := wsNormal
end;
end;
procedure TPrefSheet.UpdateFormXY;
begin
if not Visible then
Exit;
if WindowState <> wsMaximized then
begin
settingsfrmXY.Top := Top;
settingsfrmXY.Left := Left;
settingsfrmXY.Height := Height;
settingsfrmXY.Width := Width;
end;
if WindowState <> wsMinimized then
settingsfrmXY.maximized := WindowState = wsMaximized;
end;
procedure TPrefSheet.WndProc(var msg: TMessage);
begin
inherited;
if Msg.msg = WM_SYSCOMMAND then
UpdateFormXY;
end;
procedure TPrefSheet.WMNCActivate(var msg: TWMNCActivate);
begin
inherited;
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, 'Privacy & Security');
AddPrefPage(16, 'Hotkeys');
AddPrefPage(20, 'Events');
//AddPrefPage(21, 'Log packets & events');
AddPrefPage(30, 'Plugins');
AddPrefPage(95, 'Updates');
AddPrefPage(96, 'Theme editor');
AddPrefPage(99, 'Other');
end.