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/iniLib.pas

2204 lines
70 KiB
Plaintext

{
This file is part of R&Q.
Under same license
}
unit iniLib;
{$I RnQConfig.inc}
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
RnQZip, ICQCommon, IniFiles, SQLiteDB, RQCodes;
{$I NoRTTI.inc}
procedure beforeWindowsCreation;
procedure afterWindowsCreation;
procedure quit;
procedure startUser(const UID: TUID = '');
procedure quitUser;
procedure resetCFG;
procedure UpdateProperties;
function getCFG: RawByteString;
procedure loadCFG(zp: TZipFile);
// procedure saveCFG;
function getCommonCFG: AnsiString;
procedure loadCommonCFG;
procedure saveCommonCFG;
procedure loadMacros(zp: TZipFile);
// procedure saveMacros;
// procedure testBall;
// procedure testNTLM;
var
ImgCacheInfo: TMemIniFile;
CacheDir: String;
implementation
uses
Windows, Graphics, Classes, SysUtils, Forms, Menus, ShellAPI, Controls, Types, StrUtils, SysConst,
RnQDialogs, RnQLangs, RnQNet, RnQTrayLib, RnQGlobal, RnQPrefsLib, RDUtils, RnQMacros, RnQStrings, RnQCrypt, RnQSysUtils,
RQUtil, RDGlobal, RQThemes, RDFileUtil, RnQGraphics32,
roasterlib, usersDlg,
utilLib, events, chatDlg, HistAllSearch, globalLib, themesLib,
RQlog, pluginLib, outboxLib, uinlistlib,
mainDlg, prefSheet, tipDlg,
{$IFDEF RNQ_AVATARS}
RnQ_Avatars,
{$ENDIF}
groupsLib, langLib, hook,
{$IFDEF UNICODE}
AnsiStrings,
{$ENDIF UNICODE}
RnQBinUtils, wpDlg,
OverbyteIcsSSLEAY,
RnQTips, history,
menusUnit,
Protocols_All, Protocol_ICQ,
ICQContacts, ICQConsts, ICQSession,
SciterApi, SpellCheck;
var
initOnce: boolean;
uin2Bstarted: TUID;
Previous: HWND;
procedure resetCFG;
var
i: integer;
// pp:Tproxyproto;
begin
rosterTitle := '%uin% %nick%';
showMainBorder := True;
ShowUINDelimiter := True;
ResetThemePaths;
UseContactThemes := False;
FileSavePath := '%userpath%\Received\%uid%\';
sendOnEnter := 0;
skipSplash := False;
autoSwitchKL := False;
// resetTheme;
sortBy := SB_event;
FillChar(OnStatusDisable, sizeOf(OnStatusDisable), 0);
if Assigned(Account.AccProto) then
Account.AccProto.ResetPrefs;
{ with proxy do
begin
enabled:=FALSE;
// for pp:=low(pp) to high(pp) do addr[pp].host:='';
addr.host:='';
// addr[PP_SOCKS4].port:='1080';
// addr[PP_SOCKS5].port:='1080';
// addr[PP_HTTPS].port:='3128';
addr.port:=1080;
proto:=PP_NONE;
auth:=FALSE;
NTLM := False;
serv.host := DefLoginServer;
serv.port := DefLoginPort;
end; }
EnableIgnoreList := True;
IgnoreList.Clear;
EnableQuietList := False;
QuietList.Clear;
NotInList.Clear;
RecentList.Clear;
connectOnConnection := False;
InitMacroses;
with RnQmain do
begin
width := 120;
height := 250;
left := screen.width - width - 30;
end;
with transparency do
begin
forRoster := False;
forChat := False;
active := 200;
inactive := 86;
chgOnMouse := True;
forTray := False;
tray := 220;
end;
with tipstransparency do
begin
enabled := False;
alpha := 220;
end;
splitX := 100;
splitY := -1;
tempBlinkTime := 80;
useLastStatus := True;
// loginServer:='login.icq.com';
lastStatusUserSet := byte(SC_UNK);
// RnQStartingStatus:= byte(SC_ONLINE);
RnQStartingStatus := -1; // Last used
RnQStartingVisibility := 0; // VI_NORMAL;
quoting.cursorBelow := False;
quoting.width := 300;
quoting.quoteselected := True;
// icqdebug := false;
inactivehide := False;
inactivehideTime := 50;
HandleICQLinks := False;
focusOnChatPopup := True;
bringInfoFrgd := True; // By Rapid D
CheckUpdate.Betas := False;
CheckUpdate.Enabled := False;
CheckUpdate.Every := 24;
prefHeight := 390;
minOnOff := False;
minOnOffTime := 30;
showVisAndLevelling := False;
for i := 0 to byte(High(TRnQCLIconsSet)) do
begin
TO_SHOW_ICON[TRnQCLIconsSet(i)] := True;
SHOW_ICONS_ORDER[i] := TRnQCLIconsSet(i);
end;
TO_SHOW_ICON[CNT_ICON_AVT] := False;
XStatusInTray := False;
SetLength(spamfilter.quests, 0);
showXStatusMnu := True;
showNewXStatuses := False;
autoRequestXsts := False;
blinkWithStatus := True;
showRQP := False;
{$IFDEF Use_Baloons}
showBalloons := True;
{$ELSE Use_Baloons}
showBalloons := False;
{$ENDIF Use_Baloons}
usePlugPanel := True;
rosterbarOnTop := False;
filterbarOnTop := True;
RnQmain.FilterBar.Visible := False;
optimizeDB := True;
doFixWindows := True;
animatedRoster := False;
blinkSpeed := 5;
userCharSet := -1;
logpref.writehistory := True;
logpref.pkts.onWindow := False;
logpref.pkts.onFile := False;
logpref.pkts.clear := False;
logpref.evts.onWindow := False;
logpref.evts.onFile := False;
logpref.evts.clear := False;
rosterItalic := RI_list;
incomingOnAway := False;
showOnlyOnline := False;
showOnlyImVisibleTo := False;
OnlOfflInOne := False;
showUnkAsOffline := True;
closeAuthAfterReply := True;
CloseFTWndAuto := False;
autoConsumeEvents := True;
DsblEvnt4ClsdGrp := False;
RnQmain.roster.ShowHint := True;
showStatusOnTabs := True;
indentRoster := True;
NILdoWith := 0;
dontSavePwd := True;
clearPwdOnDSNCT := False;
askPassOnBossKeyOn := False;
MakeBackups := False;
startMinimized := False;
autoReconnect := True;
quitconfirmation := False;
minimizeRoster := True;
ShowHintsInChat := True;
closeChatOnSend := True;
ClosePageOnSingle := False;
RelativeTimeInChat := False;
RelativeTimeInChatDays := 7;
RelativeTimeInChatHours := 6;
lockOnStart := False;
autocopyhist := True;
bViewTextWrap := True;
useSmiles := True;
ShowSmileCaption := False;
EnableImgLinksIn := True;
EnableImgLinksOut := True;
LimitMaxChatImgWidth := True;
LimitMaxChatImgHeight := True;
EnableStickers := True;
ResamplingFilter := 1;
ChatImageQuality := 0;
PreferredResolution := 0;
EnableVideoLinks := True;
ChatSmoothFontRendering := True;
TrimMsgNewLines := True;
AnimatedScroll := True;
EnableSpellCheck := False;
MaxChatImgWidthVal := 512;
MaxChatImgheightVal := 512;
StickerResolution := 0;
ServerToUpload := 0;
UseWebProtocol := False;
ChatLoadBuffer := 20;
MenuDrawExt := True;
showIncomingDlg := False;
autoSizeRoster := False;
autosizeFullRoster := False;
autosizeUp := False;
snapToScreenEdges := True;
ShowDisconnectedDlg := True;
fontstylecodes.enabled := True;
playSounds := True;
SoundReset;
Autoconnect := False;
ShowGroups := True;
ShowEmptyGroups := False;
alwaysOnTop := True;
chatAlwaysOnTop := False;
avatarShowInChat := True;
avatarShowInHint := True;
avatarShowInTray := True;
avatarShowInTaskBar := False;
avatarUsePalette := False;
useSingleClickTray := True;
wheelVelocity := 1;
useDefaultBrowser := True;
browserCmdLine := '';
trayIconGuid := GUID_NULL;
with spamfilter do
begin
ignoreNIL := False;
warn := False;
addToHist := True;
ignoreauthNIL := False; // By Rapid D
useBot := False;
useBotInInvis := False;
UseBotFromFile := False;
BotTriesCount := 3;
notNIL := False;
notEmpty := False;
nobadwords := False;
multisend := False;
badwords := '';
uingt := 0;
end;
with histcrypt do
begin
enabled := False;
savePwd := False;
pwd := '';
end;
autoaway.autoexit := True;
autoaway.away := True;
autoaway.na := True;
autoaway.ss := True;
autoaway.boss := True;
autoaway.awayTime := 15 * (10 * 60);
autoaway.naTime := 30 * (10 * 60);
autoaway.setxstatus := True;
autoaway.xstatus := 7;
docking.enabled := True;
docking.appbar := True;
docking.Dock2Chat := False;
docking.Docked2chat := False;
behaviour[EK_incoming].trig := [BE_tray, BE_sound, BE_tip, BE_history];
behaviour[EK_outgoing].trig := [BE_history, BE_tip];
behaviour[EK_msg].trig := [BE_tray, BE_openchat, BE_save, BE_sound, BE_history, BE_tip, BE_FLASHCHAT];
behaviour[EK_contacts] := behaviour[EK_msg];
behaviour[EK_auth] := behaviour[EK_msg];
behaviour[EK_authDenied] := behaviour[EK_msg];
behaviour[EK_authreq] := behaviour[EK_msg];
behaviour[EK_addedyou] := behaviour[EK_msg];
behaviour[EK_statuschange].trig := [BE_history];
{$IFDEF Use_Baloons}
behaviour[EK_typingBeg].trig := [BE_tip, BE_BALLOON];
behaviour[EK_typingFin].trig := [BE_tip, BE_BALLOON];
{$ELSE not Use_Baloons}
behaviour[EK_typingBeg].trig := [BE_tip];
behaviour[EK_typingFin].trig := [BE_tip];
{$ENDIF Use_Baloons}
behaviour[EK_XstatusMsg].trig := [BE_history];
behaviour[EK_buzz].trig := [BE_OPENCHAT, BE_HISTORY, BE_TIP, BE_FLASHCHAT, BE_SOUND];
for i := 1 to EK_last do
begin
behaviour[i].tiptimes := False;
behaviour[i].tiptime := 50;
behaviour[i].tiptimeplus := 50;
end;
behaviour[EK_msg].tiptimes := True;
behaviour[EK_msg].tiptime := 1;
behaviour[EK_typingBeg].tiptime := 20;
behaviour[EK_typingFin].tiptime := 20;
tipsSetCFG(NIL);
// TipsMaxCnt := 20;
// TipsBtwSpace := 2;
// TipsAlign := alBottomRight;
TipsMaxAvtSizeUse := True;
TipsMaxAvtSize := 100;
FreeAndNil(spellLanguages);
spellLanguages := TStringList.Create;
spellLanguages.Delimiter := ',';
spellLanguages.StrictDelimiter := True;
spellLanguageMain := '';
spellErrorColor := clRed;
spellErrorStyle := 0;
end; // resetCFG
procedure UpdateProperties;
var
pp: TRnQPref;
// l : RawByteString;
sU: String;
i: integer;
myInf: TICQContact;
mainRect: TRect;
WinRect: TRect;
begin
// pp := TRnQPref.Create;
pp := MainPrefs;
// if Assigned(Account.AccProto) and Assigned(Account.AccProto.getMyInfo) and (Account.AccProto.getMyInfo.UID > '') then
if Assigned(Account.AccProto) and
// Assigned(Account.AccProto.MyInfo) and (Account.AccProto.getMyInfo.UID > '') then
(Account.AccProto.MyAccNum > '') then
begin
// l := StrToUTF8(MainProto.getMyInfo.displayed)
myInf := Account.AccProto.getMyInfo;
if Assigned(myInf) then
pp.addPrefStr('account-name', myInf.displayed);
end;
// else
// l := '';
// pp.addPrefBlob('account-name', l);
pp.addPrefInt('version', RnQBuild);
if histcrypt.savePwd then
begin
// pp.addPrefBlob('history-crypt-password', passcrypt(histcrypt.pwd));
pp.addPrefBlob64('history-crypt-password64', passcrypt(histcrypt.pwd));
end
else
begin
pp.DeletePref('history-crypt-password64');
end;
pp.DeletePref('history-crypt-password');
for i := 1 to EK_last do
begin
sU := String(event2str[i]) + '-behaviour';
pp.addPrefStr(sU, beh2str(i));
end;
if Assigned(RnQmain) then
begin
if Assigned(RnQmain.Parent) then
mainRect.TopLeft := RnQmain.Parent.ClientToScreen(Point(RnQmain.Left, RnQmain.Top))
else
mainRect.TopLeft := Point(RnQmain.Left, RnQmain.Top);
mainRect.Right := mainRect.Left + RnQmain.Width;
mainRect.Bottom := mainRect.Top + RnQmain.Height;
end else
mainRect := Rect(0, 0, 0, 0);
WinRect := screen.DesktopRect;
sU := '-' + IntToStr(WinRect.Width) + 'x' + IntToStr(WinRect.Height);
pp.addPrefInt('window-top' + sU, mainRect.Top);
pp.addPrefInt('window-height' + sU, mainRect.Height);
pp.addPrefInt('window-left' + sU, mainRect.Left);
pp.addPrefInt('window-width' + sU, mainRect.Width);
pp.addPrefInt('window-top', mainRect.Top);
pp.addPrefInt('window-height', mainRect.Height);
pp.addPrefInt('window-left', mainRect.Left);
pp.addPrefInt('window-width', mainRect.Width);
pp.addPrefInt('chat-top', chatfrmXY.Top);
pp.addPrefInt('chat-height', chatfrmXY.Height);
pp.addPrefInt('chat-left', chatfrmXY.Left);
pp.addPrefInt('chat-width', chatfrmXY.Width);
pp.addPrefBool('chat-maximized', chatfrmXY.maximized);
pp.addPrefInt('search-top', searchfrmXY.Top);
pp.addPrefInt('search-height', searchfrmXY.Height);
pp.addPrefInt('search-left', searchfrmXY.Left);
pp.addPrefInt('search-width', searchfrmXY.Width);
pp.addPrefBool('search-maximized', searchfrmXY.maximized);
pp.addPrefInt('settings-top', settingsfrmXY.Top);
pp.addPrefInt('settings-height', settingsfrmXY.Height);
pp.addPrefInt('settings-left', settingsfrmXY.Left);
pp.addPrefInt('settings-width', settingsfrmXY.Width);
pp.addPrefBool('settings-maximized', settingsfrmXY.maximized);
pp.addPrefBool('transparency', transparency.forRoster);
pp.addPrefBool('transparency-chat', transparency.forChat);
pp.addPrefBool('transparency-tray', transparency.forTray);
pp.addPrefBool('transparency-chgonmouse', transparency.chgOnMouse);
pp.addPrefInt('transparency-active', transparency.active);
pp.addPrefInt('transparency-inactive', transparency.inactive);
pp.addPrefInt('transparency-vtray', transparency.tray);
pp.addPrefStr('proxy-name', MainProxy.name);
pp.addPrefStr('proxy-host', MainProxy.addr.host);
pp.addPrefInt('proxy-port', MainProxy.addr.port);
pp.addPrefBool('proxy-auth', MainProxy.auth);
pp.addPrefStr('proxy-user', MainProxy.user);
// pp.addPrefBlob('proxy-pass', passCrypt(UTF(MainProxy.pwd)));
pp.addPrefBlob64('proxy-pass64', passcrypt(UTF(MainProxy.pwd)));
pp.addPrefBool('proxy-NTLM', MainProxy.NTLM);
pp.addPrefStr('proxy-proto', proxyproto2str[MainProxy.proto]);
pp.addPrefBool('auto-size', autoSizeRoster);
pp.addPrefBool('auto-size-full', autosizeFullRoster);
pp.addPrefBool('auto-size-up', autosizeUp);
pp.addPrefBool('snap-to-screen-edges', snapToScreenEdges);
pp.addPrefBool('reopen-chats-on-start', reopenchats);
pp.addPrefBool('skip-splash', skipSplash);
pp.addPrefBool('optimize-database', optimizeDB);
pp.addPrefBool('fix-windows-position', doFixWindows);
pp.addPrefBool('start-minimized', startMinimized);
pp.addPrefBool('auto-reconnect', autoReconnect);
pp.addPrefBool('use-last-status', useLastStatus);
pp.addPrefBool('close-auth-after-reply', closeAuthAfterReply);
pp.addPrefBool('close-ft-after-end', CloseFTWndAuto);
pp.addPrefBool('inactive-hide', inactivehide);
pp.addPrefBool('check-betas', checkupdate.betas);
pp.addPrefBool('roaster-bar-on-top', rosterbarOnTop);
pp.addPrefBool('filter-bar-on-top', filterbarOnTop);
pp.addPrefBool('handle-icq-links', HandleICQLinks);
pp.addPrefBool('dont-save-password', dontSavePwd);
pp.addPrefBool('clear-password-on-disconnect', clearPwdOnDSNCT);
pp.addPrefBool('ask-password-after-bossmode', askPassOnBossKeyOn);
pp.addPrefBool('make-bakups-on-save', MakeBackups);
pp.addPrefBool('oncoming-on-away', incomingOnAway);
pp.addPrefTime('last-update-check-time', checkupdate.last);
// +'last-update-check-time='+dateToStr(checkupdate.last)+CRLF
pp.addPrefInt('wheel-velocity', wheelVelocity);
pp.addPrefInt('inactive-hide-time', inactivehideTime);
pp.addPrefBool('auto-connect', autoconnect);
pp.addPrefBool('minimize-roaster', minimizeRoster);
pp.addPrefBool('connect-on-connection', connectOnConnection);
pp.addPrefBool('quit-confirmation', quitconfirmation);
pp.addPrefBool('min-on-off', minOnOff);
pp.addPrefInt('min-on-off-time', minOnOffTime);
pp.addPrefInt('sound-volume', Soundvolume);
pp.addPrefBool('play-sounds', playSounds);
pp.addPrefBool('lock-on-start', lockOnStart);
pp.addPrefBool('auto-check-update', checkupdate.enabled);
pp.addPrefBool('show-only-online-contacts', showOnlyOnline);
pp.addPrefBool('show-only-im-visible-to-contacts', showOnlyImVisibleTo);
pp.addPrefBool('show-all-contacts-in-one', OnlOfflInOne);
pp.addPrefBool('show-unk-as-offline', showUnkAsOffline);
pp.addPrefBool('show-oncoming-dialog', showIncomingDlg);
pp.addPrefBool('always-on-top', alwaysOnTop);
pp.addPrefBool('chat-always-on-top', chatAlwaysOnTop);
pp.addPrefBool('chat-show-avatars-chat', avatarShowInChat);
pp.addPrefBool('chat-show-avatars-hint', avatarShowInHint);
pp.addPrefBool('chat-show-avatars-tray', avatarShowInTray);
pp.addPrefBool('chat-show-avatars-taskbar', avatarShowInTaskBar);
pp.addPrefBool('chat-use-avatar-palette', avatarUsePalette);
pp.addPrefBool('use-single-click-tray', useSingleClickTray);
pp.addPrefInt('split-x', splitX);
pp.addPrefInt('split-y', splitY);
pp.addPrefInt('blink-speed', blinkSpeed);
pp.addPrefInt('temp-blink-time', tempBlinkTime);
pp.addPrefBool('show-statusbar', RnQmain.bar.Visible);
pp.addPrefBool('show-filterbar', RnQmain.FilterBar.Visible);
pp.addPrefBool('show-contact-tip', RnQmain.roster.ShowHint);
pp.addPrefInt('show-tips-count', TipsMaxCnt);
pp.addPrefInt('show-tips-align', byte(TipsAlign));
pp.addPrefInt('show-tips-btw-space', TipsBtwSpace);
pp.addPrefInt('show-tips-ver-indent', TipVerIndent);
pp.addPrefInt('show-tips-hor-indent', TipHorIndent);
pp.addPrefBool('show-tips-use-avt-size', TipsMaxAvtSizeUse);
pp.addPrefInt('show-tips-avt-size', TipsMaxAvtSize);
// +'save-not-in-list='+yesno[saveNIL]+CRLF
pp.addPrefInt('not-in-list-do', NILdoWith);
pp.addPrefBool('animated-roaster', animatedRoster);
pp.addPrefBool('show-groups', ShowGroups);
pp.addPrefBool('show-empty-groups', ShowEmptyGroups);
pp.addPrefBool('visibility-level-flag', showVisAndLevelling);
// +'send-interests='+yesno[sendInterests]+CRLF
for i := 0 to byte(High(TRnQCLIconsSet)) do
if TRnQCLIconsSet(i) <> CNT_TEXT then
pp.addPrefBool(RnQCLIcons[TRnQCLIconsSet(i)].PrefText, TO_SHOW_ICON[TRnQCLIconsSet(i)]);
pp.addPrefStr('show-cl-icons-order', ICON_ORDER_PREF);
pp.addPrefBool('show-xstatus-in-menu-flag', showXStatusMnu);
pp.addPrefBool('show-new-xstatuses', showNewXStatuses);
pp.addPrefBool('show-balloons-flag', showBalloons);
pp.addPrefBool('use-plugin-panel', usePlugPanel);
pp.addPrefBool('use-smiles', useSmiles);
pp.addPrefBool('smiles-captions', ShowSmileCaption);
pp.addPrefBool('menu-draw-ext', MenuDrawExt);
pp.addPrefInt('send-on-enter', sendOnEnter);
pp.addPrefBool('chat-parse-image-links-in', EnableImgLinksIn);
pp.addPrefBool('chat-parse-image-links-out', EnableImgLinksOut);
pp.addPrefBool('chat-images-limit-width', LimitMaxChatImgWidth);
pp.addPrefBool('chat-images-limit-height', LimitMaxChatImgHeight);
pp.addPrefInt('chat-images-width-value', MaxChatImgWidthVal);
pp.addPrefInt('chat-images-height-value', MaxChatImgheightVal);
pp.addPrefInt('chat-images-resample-filter', ResamplingFilter);
pp.addPrefInt('chat-images-resample-preset', ChatImageQuality);
pp.addPrefInt('chat-video-preferred-resolution', PreferredResolution);
pp.addPrefBool('chat-video-links-thumbnails', EnableVideoLinks);
pp.addPrefBool('chat-font-rendering', ChatSmoothFontRendering);
pp.addPrefBool('chat-trim-newlines', TrimMsgNewLines);
pp.addPrefBool('chat-animated-scroll', AnimatedScroll);
pp.addPrefBool('chat-spellcheck', EnableSpellCheck);
pp.addPrefBool('chat-images-enable-stickers', EnableStickers);
pp.addPrefInt('chat-images-sticker-size', StickerResolution);
pp.addPrefInt('file-transfer-upload-server', ServerToUpload);
pp.addPrefBool('use-web-protocol', useWebProtocol);
pp.addPrefStr('disabled-plugins', disabledPlugins);
pp.addPrefBool('show-status-on-tabs', showStatusOnTabs);
pp.addPrefBool('single-message-by-default', singledefault);
pp.addPrefBool('auto-copy', autocopyhist);
pp.addPrefBool('hist-msg-view-wrap', bViewTextWrap);
pp.addPrefBool('indent-contact-list', indentRoster);
pp.addPrefBool('auto-consume-events', autoConsumeEvents);
pp.addPrefBool('disable-events-on-closed-groups', DsblEvnt4ClsdGrp);
pp.addPrefBool('show-disconnected-dialog', ShowDisconnectedDlg);
pp.addPrefInt('italic-mode', rosterItalic);
pp.addPrefBool('focus-on-chat-popup', focusOnChatPopup);
pp.addPrefBool('bring-info-frgd', bringInfoFrgd);
pp.addPrefBool('enable-ignore-list', enableIgnoreList);
pp.addPrefBool('enable-quiet-list', enableQuietlist);
pp.addPrefBool('use-contacts-themes', UseContactThemes);
pp.addPrefInt('preferences-height', prefHeight);
pp.addPrefBool('docking-enabled', docking.enabled);
pp.addPrefBool('docking-active', docking.active);
pp.addPrefBool('docking-resize', docking.appbar);
pp.addPrefBool('docking-right', docking.pos = DP_right);
pp.addPrefInt('docking-bak-x', docking.bakOfs.x);
pp.addPrefInt('docking-bak-y', docking.bakOfs.y);
pp.addPrefInt('docking-bak-width', docking.bakSize.x);
pp.addPrefInt('docking-bak-height', docking.bakSize.y);
pp.addPrefBool('docking-dock2chat', docking.Dock2Chat);
pp.addPrefBool('docking-docked2chat', docking.Docked2chat);
pp.addPrefBool('autoaway-exit', autoaway.autoexit);
pp.addPrefBool('autoaway-away', autoaway.away);
pp.addPrefInt('autoaway-away-time', autoaway.awayTime);
pp.addPrefBool('autoaway-na', autoaway.na);
pp.addPrefBool('autoaway-ss', autoaway.ss);
pp.addPrefBool('autoaway-boss', autoaway.boss);
pp.addPrefInt('autoaway-na-time', autoaway.naTime);
pp.addPrefBool('autoaway-set-xstatus', autoaway.setxstatus);
pp.addPrefInt('autoaway-xstatus', autoaway.xstatus);
pp.addPrefBool('ignore-not-in-list', spamfilter.ignoreNIL);
pp.addPrefBool('ignore-authreq-notinlist', spamfilter.ignoreauthNIL);
pp.addPrefBool('spam-ignore-not-in-list', spamfilter.notNIL);
pp.addPrefBool('spam-ignore-empty-history', spamfilter.notEmpty);
pp.addPrefBool('spam-ignore-bad-words', spamfilter.nobadwords);
pp.addPrefBool('spam-ignore-multisend', spamfilter.multisend);
pp.addPrefBool('spam-warn', spamfilter.warn);
pp.addPrefBool('spam-add-history', spamfilter.addToHist);
pp.addPrefInt('spam-uin-greater-than', spamfilter.uingt);
pp.addPrefBool('spam-use-bot', spamfilter.useBot);
pp.addPrefBool('spam-use-bot-in-invis', spamfilter.useBotInInvis);
pp.addPrefBool('spam-use-bot-file', spamfilter.UseBotFromFile);
pp.addPrefInt('spam-bot-tries', spamfilter.BotTriesCount);
pp.addPrefBool('history-crypt-save-password', histcrypt.savePwd);
pp.addPrefBool('chat-hints-show', ShowHintsInChat);
pp.addPrefBool('chat-close-on-send', closeChatOnSend);
pp.addPrefBool('chat-close-page-on-single', ClosePageOnSingle);
pp.addPrefBool('chat-relative-time', RelativeTimeInChat);
pp.addPrefInt('chat-relative-time-days', RelativeTimeInChatDays);
pp.addPrefInt('chat-relative-time-hours', RelativeTimeInChatHours);
pp.addPrefInt('chat-load-buffer', ChatLoadBuffer);
pp.addPrefBool('use-default-browser', useDefaultBrowser);
pp.addPrefStr('browser-command-line', browserCmdLine);
pp.addPrefGuid('tray-icon-guid', trayIconGuid);
pp.addPrefStr('sort-by', sortby2str[sortBy]);
// pp.addPrefBlob('starting-status', status2Img[TICQStatus(startingStatus)]);
// +'xstatusstr'+curXStatusStr+CRLF
// +'xstatus-desc'+curXStatusDesc+CRLF
pp.addPrefBool('xstatus-auto-request', autoRequestXsts);
pp.addPrefBool('xstatus-in-tray', XStatusInTray);
pp.addPrefBool('blink-with-status', blinkWithStatus);
pp.addPrefBool('log-events-file', logpref.evts.onFile);
pp.addPrefBool('log-events-window', logpref.evts.onWindow);
pp.addPrefBool('log-events-clear', logpref.evts.clear);
pp.addPrefBool('log-packets-file', logpref.pkts.onFile);
pp.addPrefBool('log-packets-window', logpref.pkts.onWindow);
pp.addPrefBool('log-packets-clear', logpref.pkts.clear);
pp.addPrefBool('font-style-codes', fontstylecodes.enabled);
pp.addPrefBool('write-history', logpref.writehistory);
pp.addPrefBool('quote-selected', quoting.quoteselected);
pp.addPrefInt('quoting-width', quoting.width);
pp.addPrefBool('quoting-cursor-below', quoting.cursorBelow);
pp.addPrefBool('show-main-border', showMainBorder);
pp.addPrefBool('show-uin-delimiter', ShowUINDelimiter);
pp.addPrefBool('auto-switch-keyboard-layout', autoSwitchKL);
pp.addPrefStr('files-recv-path', FileSavePath);
pp.addPrefStr('roaster-title', rosterTitle);
pp.addPrefStr('spam-bad-words', spamfilter.badwords);
pp.addPrefStr('theme', theme.ThemePath.fn);
pp.addPrefStr('theme-sub', theme.ThemePath.subfn);
pp.addPrefStr('theme-smiles', RQSmilesPath.fn);
pp.addPrefStr('theme-smiles-sub', RQSmilesPath.subfn);
pp.addPrefStr('theme-sounds', RQSoundsPath.fn);
pp.addPrefStr('theme-sounds-sub', RQSoundsPath.subfn);
pp.addPrefStrList('spellcheck-languages', spellLanguages);
pp.addPrefStr('spellcheck-language-main', spellLanguageMain);
pp.addPrefStr('spellcheck-error-color', ColorToString(spellErrorColor));
pp.addPrefInt('spellcheck-error-style', spellErrorStyle);
if Assigned(Account.AccProto) then
Account.AccProto.GetPrefs(pp);
plugins.castEv(PE_PROPERTIES_CHANGED);
// pp.Free;
end;
function getCFG: RawByteString;
// var
// pp : TRnQPref;
begin
{
pp := TRnQPref.Create;
ApplyProp(pp);
Result := pp.getAllPrefs;
pp.Free;
}
Result := MainPrefs.getAllPrefs;
end; // getCFG
(*
procedure saveCFG;
var
s : String;
// zf : TZipFile;
begin
if fantomWork then Exit;
s := getCFG;
// if FileExists(userPath+oldconfigFileName) then
// DeleteFile(userPath+oldconfigFileName);
savefile(userPath+configFileName, s, True);
{
zf := TZipFile.Create;
zf.AddFile(configFileName);
zf.Data[0] := s;
zf.SaveToFile(userPath+configFileName + '.zip');
zf.Free;
}
end; *)
procedure setcommoncfg(cfg: RawByteString);
var
l, h, v: RawByteString;
function yesno: boolean;
begin
Result := l = 'yes'
end;
function int: integer;
var
bb: integer;
begin
// if not tryStrToInt(l, result) then
// result:= 0;
Val(l, Result, bb);
if bb <> 0 then
Result := 0;
end;
begin
if cfg = '' then
exit;
docking.pos := DP_right;
while cfg > '' do
begin
// l:=chop(CRLF,cfg);
// h:=chop('=',l);
l := chop(CRLF, cfg);
h := LowerCase(Trim(chop(AnsiString('='), l)));
v := Trim(l);
l := LowerCase(v);
try
if h = 'auto-start-uin' then
autostartUIN := UnUTF(l)
else if h = 'last-user' then
lastUser := UnUTF(l)
else if h = 'users-path' then
usersPath := UnUTF(v)
else if h = 'main-path' then
RnQMainPath := UnUTF(v)
else if h = 'langs-filename' then
gLangFile := UnUTF(v)
else if h = 'langs-sub-filename' then
gLangSubFile := UnUTF(v);
except
end
end;
end; // setcommoncfg
function getCommonCFG: AnsiString;
begin
Result :=
'auto-start-uin=' + UTF(autostartUIN) + CRLF +
'users-path=' + UTF(usersPath) + CRLF +
'main-path=' + UTF(RnQMainPath) + CRLF +
'last-user=' + UTF(lastUser) + CRLF +
'langs-filename=' + UTF(gLangFile) + CRLF +
'langs-sub-filename=' + UTF(gLangSubFile) + CRLF;
end;
procedure resetCommonCFG;
begin
autostartUIN := '';
lastUser := '';
usersPath := cmdLinePar.userPath;
RnQMainPath := cmdLinePar.mainPath;
gLangFile := '';
gLangSubFile := '';
end; // resetCommonCFG
procedure SetCFG(pp: TRnQPref);
var
l // ,h
: AnsiString;
// lastVersion:integer;
i: integer;
// st:TICQstatus;
// pp:Tproxyproto;
{
function yesno:boolean;
begin result:=comparetext(l,AnsiString('yes'))=0 end;
function int:integer;
var
bb : Integer;
begin
// if not tryStrToInt(l, result) then
// result:= 0;
Val(l, Result, bb);
if bb <> 0 then
Result := 0;
end;
function dt:Tdatetime;
var
df : TFormatSettings;
begin
GetLocaleFormatSettings(0, df);
df.ShortDateFormat := 'dd.mm.yyyy';
df.DateSeparator := '.';
result:=StrToDate(l, df);
end;
function dtt:Tdatetime;
var
df : TFormatSettings;
begin
GetLocaleFormatSettings(0, df);
// df.LongDateFormat := 'dd.mm.yyyy';
df.ShortDateFormat := 'dd.mm.yyyy';
df.DateSeparator := '.';
df.LongTimeFormat := 'hh:mm:ss';
df.ShortTimeFormat := 'hh:mm:ss';
df.TimeSeparator := ':';
result:=StrToDateTime(l, df);
end;
function sc:TShortCut;
begin
if comparetext(l,AnsiString('none'))=0 then result:=0
else result:=textToShortCut(l);
end;
}
var
// pp : TRnQPref;
sU: String;
sR: RawByteString;
WinRect: TRect;
FormPos: TformXY;
// sU2
begin
// if cfg = '' then exit;
// lastVersion:=0;
// docking.pos:=DP_right;
// pp := TRnQPref.Create;
// pp := MainPrefs;
// pp.Load(cfg);
// pPublicEmail := pp.getPrefBool('public-email', True);
pp.getPrefStr('theme', theme.ThemePath.fn);
pp.getPrefStr('theme-sub', theme.ThemePath.subfn);
pp.getPrefStr('theme-smiles', RQSmilesPath.fn);
pp.getPrefStr('theme-smiles-sub', RQSmilesPath.subfn);
pp.getPrefStr('theme-sounds', RQSoundsPath.fn);
pp.getPrefStr('theme-sounds-sub', RQSoundsPath.subfn);
pp.getPrefBool('use-contacts-themes', UseContactThemes);
pp.getPrefStr('roaster-title', rosterTitle);
pp.getPrefBool('show-main-border', showMainBorder);
pp.getPrefBool('show-uin-delimiter', ShowUINDelimiter);
pp.getPrefBool('optimize-database', optimizeDB);
pp.getPrefBool('fix-windows-position', doFixWindows);
pp.getPrefBool('reopen-chats-on-start', reopenchats);
pp.getPrefBool('connect-on-connection', connectOnConnection);
pp.getPrefBool('minimize-roaster', minimizeRoster);
pp.getPrefBool('use-default-browser', useDefaultBrowser);
pp.getPrefStr('browser-command-line', browserCmdLine);
pp.getPrefGuid('tray-icon-guid', trayIconGuid);
pp.getPrefStr('disabled-plugins', disabledPlugins);
pp.getPrefInt('wheel-velocity', wheelVelocity);
pp.getPrefInt('split-x', splitX);
pp.getPrefInt('split-y', splitY);
pp.getPrefBool('auto-switch-keyboard-layout', autoSwitchKL);
pp.getPrefDateTime('last-update-check-time', checkupdate.last);
pp.getPrefBool('skip-splash', skipSplash);
pp.getPrefBool('start-minimized', startMinimized);
pp.getPrefBool('auto-reconnect', autoReconnect);
pp.getPrefBool('auto-check-update', checkupdate.enabled);
pp.getPrefBool('lock-on-start', lockOnStart);
pp.getPrefBool('chat-hints-show', ShowHintsInChat);
pp.getPrefBool('chat-close-on-send', closeChatOnSend);
pp.getPrefBool('chat-close-page-on-single', ClosePageOnSingle);
pp.getPrefBool('chat-relative-time', RelativeTimeInChat);
pp.getPrefInt('chat-relative-time-days', RelativeTimeInChatDays);
pp.getPrefInt('chat-relative-time-hours', RelativeTimeInChatHours);
pp.getPrefInt('chat-load-buffer', ChatLoadBuffer);
pp.getPrefBool('animated-roaster', animatedRoster);
pp.getPrefBool('inactive-hide', inactivehide);
pp.getPrefBool('font-style-codes', fontstylecodes.enabled);
pp.getPrefBool('roaster-bar-on-top', rosterbarOnTop);
pp.getPrefBool('filter-bar-on-top', filterbarOnTop);
pp.getPrefBool('oncoming-on-away', incomingOnAway);
pp.getPrefBool('use-last-status', useLastStatus);
pp.getPrefBool('handle-icq-links', HandleICQLinks);
for i := 1 to EK_last do
begin
sU := event2str[i] + '-behaviour';
l := beh2str(i);
pp.getPrefBlob(sU, RawByteString(l));
// if l <> '' then
behaviour[i] := str2beh(l)
end;
pp.getPrefInt('inactive-hide-time', inactivehideTime);
pp.getPrefInt('blink-speed', blinkSpeed);
pp.getPrefBool('dont-save-password', dontSavePwd);
pp.getPrefBool('clear-password-on-disconnect', clearPwdOnDSNCT);
pp.getPrefBool('ask-password-after-bossmode', askPassOnBossKeyOn);
pp.getPrefBool('make-bakups-on-save', MakeBackups);
pp.getPrefBool('always-on-top', alwaysOnTop);
pp.getPrefBool('chat-always-on-top', chatAlwaysOnTop);
pp.getPrefBool('chat-show-avatars-chat', avatarShowInChat);
pp.getPrefBool('chat-show-avatars-hint', avatarShowInHint);
pp.getPrefBool('chat-show-avatars-tray', avatarShowInTray);
pp.getPrefBool('chat-show-avatars-taskbar', avatarShowInTaskBar);
pp.getPrefBool('chat-use-avatar-palette', avatarUsePalette);
pp.getPrefBool('use-single-click-tray', useSingleClickTray);
pp.getPrefBool('check-betas', checkupdate.betas);
pp.getPrefBool('show-groups', ShowGroups);
pp.getPrefBool('show-empty-groups', ShowEmptyGroups);
RnQmain.roster.ShowHint := pp.getPrefBoolDef('show-contact-tip', RnQmain.roster.ShowHint);
pp.getPrefInt('show-tips-count', TipsMaxCnt);
TipsAlign := TtipsAlign(byte(pp.getPrefIntDef('show-tips-align', byte(TipsAlign))));
pp.getPrefInt('show-tips-btw-space', TipsBtwSpace);
pp.getPrefInt('show-tips-ver-indent', TipVerIndent);
pp.getPrefInt('show-tips-hor-indent', TipHorIndent);
pp.getPrefBool('show-tips-use-avt-size', TipsMaxAvtSizeUse);
pp.getPrefInt('show-tips-avt-size', TipsMaxAvtSize);
pp.getPrefBool('close-auth-after-reply', closeAuthAfterReply);
pp.getPrefBool('close-ft-after-end', CloseFTWndAuto);
pp.getPrefBool('quoting-cursor-below', quoting.cursorBelow);
pp.getPrefBool('quote-selected', quoting.quoteselected);
pp.getPrefInt('quoting-width', quoting.width);
pp.getPrefBool('quit-confirmation', quitconfirmation);
pp.getPrefBool('log-events-file', logpref.evts.onFile);
pp.getPrefBool('log-events-window', logpref.evts.onWindow);
pp.getPrefBool('log-events-clear', logpref.evts.clear);
pp.getPrefBool('log-packets-file', logpref.pkts.onFile);
pp.getPrefBool('log-packets-window', logpref.pkts.onWindow);
pp.getPrefBool('log-packets-clear', logpref.pkts.clear);
pp.getPrefBool('write-history', logpref.writehistory);
pp.getPrefBool('indent-contact-list', indentRoster);
pp.getPrefBool('auto-consume-events', autoConsumeEvents);
pp.getPrefBool('disable-events-on-closed-groups', DsblEvnt4ClsdGrp);
pp.getPrefBool('focus-on-chat-popup', focusOnChatPopup);
pp.getPrefBool('bring-info-frgd', bringInfoFrgd);
pp.getPrefBool('show-status-on-tabs', showStatusOnTabs);
pp.getPrefBool('show-disconnected-dialog', ShowDisconnectedDlg);
RnQmain.bar.Visible := pp.getPrefBoolDef('show-statusbar', True);
RnQmain.FilterBar.Visible := pp.getPrefBoolDef('show-filterbar', False);
pp.getPrefBool('use-smiles', useSmiles);
pp.getPrefBool('smiles-captions', ShowSmileCaption);
pp.getPrefBool('chat-parse-image-links-in', EnableImgLinksIn);
pp.getPrefBool('chat-parse-image-links-out', EnableImgLinksOut);
pp.getPrefBool('chat-images-limit-width', LimitMaxChatImgWidth);
pp.getPrefBool('chat-images-limit-height', LimitMaxChatImgHeight);
pp.getPrefInt('chat-images-width-value', MaxChatImgWidthVal);
pp.getPrefInt('chat-images-height-value', MaxChatImgheightVal);
pp.getPrefInt('chat-images-resample-filter', ResamplingFilter);
pp.getPrefInt('chat-images-resample-preset', ChatImageQuality);
pp.getPrefInt('chat-video-preferred-resolution', PreferredResolution);
pp.getPrefBool('chat-video-links-thumbnails', EnableVideoLinks);
pp.getPrefBool('chat-font-rendering', ChatSmoothFontRendering);
pp.getPrefBool('chat-trim-newlines', TrimMsgNewLines);
pp.getPrefBool('chat-animated-scroll', AnimatedScroll);
pp.getPrefBool('chat-spellcheck', EnableSpellCheck);
pp.getPrefBool('chat-images-enable-stickers', EnableStickers);
pp.getPrefInt('chat-images-sticker-size', StickerResolution);
pp.getPrefInt('file-transfer-upload-server', ServerToUpload);
pp.getPrefBool('use-web-protocol', useWebProtocol);
pp.getPrefBool('menu-draw-ext', MenuDrawExt);
NILdoWith := pp.getPrefIntDef('not-in-list-do', 0);
pp.getPrefInt('italic-mode', rosterItalic);
pp.getPrefBool('auto-copy', autocopyhist);
pp.getPrefBool('hist-msg-view-wrap', bViewTextWrap);
for i := 0 to byte(High(TRnQCLIconsSet)) do
if TRnQCLIconsSet(i) <> CNT_TEXT then
pp.getPrefBool(RnQCLIcons[TRnQCLIconsSet(i)].PrefText, TO_SHOW_ICON[TRnQCLIconsSet(i)]);
pp.getPrefBlob('show-cl-icons-order', sR);
ICON_ORDER_PREF_parse(sR);
pp.getPrefBool('visibility-level-flag', showVisAndLevelling);
pp.getPrefBool('show-xstatus-in-menu-flag', showXStatusMnu);
pp.getPrefBool('show-new-xstatuses', showNewXStatuses);
pp.getPrefBool('show-balloons-flag', showBalloons);
pp.getPrefBool('use-plugin-panel', usePlugPanel);
pp.getPrefBool('single-message-by-default', singledefault);
pp.getPrefBool('show-oncoming-dialog', showIncomingDlg);
pp.getPrefBool('min-on-off', minOnOff);
pp.getPrefInt('min-on-off-time', minOnOffTime);
pp.getPrefBool('enable-ignore-list', enableIgnoreList);
pp.getPrefBool('enable-quiet-list', enableQuietlist);
pp.getPrefBool('ignore-not-in-list', spamfilter.ignoreNIL);
pp.getPrefBool('ignore-authreq-notinlist', spamfilter.ignoreauthNIL);
pp.getPrefBool('spam-warn', spamfilter.warn);
pp.getPrefBool('spam-add-history', spamfilter.addToHist);
pp.getPrefBool('spam-ignore-not-in-list', spamfilter.notNIL);
pp.getPrefBool('spam-ignore-empty-history', spamfilter.notEmpty);
pp.getPrefBool('spam-ignore-bad-words', spamfilter.nobadwords);
pp.getPrefBool('spam-ignore-multisend', spamfilter.multisend);
// l := pp.getPrefBlobDef('spam-bad-words');
// spamfilter.badwords:=ansiReplaceStr(l,CRLF, AnsiChar(';'));
spamfilter.badwords := ansiReplaceStr(pp.getPrefStrDef('spam-bad-words'), CRLF, AnsiChar(';'));
pp.getPrefInt('spam-uin-greater-than', spamfilter.uingt);
pp.getPrefBool('spam-use-bot', spamfilter.useBot);
pp.getPrefBool('spam-use-bot-in-invis', spamfilter.useBotInInvis);
pp.getPrefBool('spam-use-bot-file', spamfilter.UseBotFromFile);
pp.getPrefInt('spam-bot-tries', spamfilter.BotTriesCount);
boundInt(spamfilter.BotTriesCount, 2, 6);
pp.getPrefBool('history-crypt-save-password', histcrypt.savePwd);
if pp.prefExists('history-crypt-password64') then
histcrypt.pwd := passDecrypt(pp.getPrefBlob64Def('history-crypt-password64'))
else
histcrypt.pwd := passDecrypt(pp.getPrefBlobDef('history-crypt-password'));
WinRect := screen.DesktopRect;
sU := '-' + IntToStr(WinRect.Width) + 'x' + IntToStr(WinRect.Height);
FormPos.Top := pp.getPrefIntDef('window-top' + sU);
FormPos.Left := pp.getPrefIntDef('window-left' + sU);
FormPos.Width := pp.getPrefIntDef('window-width' + sU);
FormPos.Height := pp.getPrefIntDef('window-height' + sU);
if (FormPos.Top = -1) or (FormPos.Left = -1) then
begin
FormPos.Top := pp.getPrefIntDef('window-top', RnQmain.Top);
FormPos.Left := pp.getPrefIntDef('window-left', RnQmain.Left);
end;
if (FormPos.Width = -1) or (FormPos.Height = -1) then
begin
FormPos.Width := pp.getPrefIntDef('window-width', RnQmain.Width);
FormPos.Height := pp.getPrefIntDef('window-height', RnQmain.Height);
end;
RnQmain.Top := FormPos.Top;
RnQmain.Left := FormPos.Left;
RnQmain.Width := FormPos.Width;
RnQmain.Height := FormPos.Height;
RnQMain.SaveFormPositionForCurrentMonitorCount;
pp.getPrefBool('auto-size-up', autosizeUp);
pp.getPrefBool('auto-size', autoSizeRoster);
pp.getPrefBool('auto-size-full', autosizeFullRoster);
pp.getPrefBool('snap-to-screen-edges', snapToScreenEdges);
pp.getPrefInt('preferences-height', prefHeight);
pp.getPrefBool('docking-enabled', docking.enabled);
pp.getPrefBool('docking-active', docking.active);
pp.getPrefBool('docking-resize', docking.appbar);
pp.getPrefInt('docking-bak-x', docking.bakOfs.x);
pp.getPrefInt('docking-bak-y', docking.bakOfs.y);
pp.getPrefInt('docking-bak-width', docking.bakSize.x);
pp.getPrefInt('docking-bak-height', docking.bakSize.y);
if pp.getPrefBoolDef('docking-right', True) then
docking.pos := DP_right
else
docking.pos := DP_left;
pp.getPrefBool('docking-Dock2Chat', docking.Dock2Chat);
pp.getPrefBool('docking-Docked2chat', docking.Docked2chat);
pp.getPrefInt('chat-top', chatfrmXY.Top);
pp.getPrefInt('chat-height', chatfrmXY.Height);
pp.getPrefInt('chat-left', chatfrmXY.Left);
pp.getPrefInt('chat-width', chatfrmXY.Width);
pp.getPrefBool('chat-maximized', chatfrmXY.maximized);
pp.getPrefInt('search-top', searchfrmXY.Top);
pp.getPrefInt('search-height', searchfrmXY.Height);
pp.getPrefInt('search-left', searchfrmXY.Left);
pp.getPrefInt('search-width', searchfrmXY.Width);
pp.getPrefBool('search-maximized', searchfrmXY.maximized);
pp.getPrefInt('settings-top', settingsfrmXY.Top);
pp.getPrefInt('settings-height', settingsfrmXY.Height);
pp.getPrefInt('settings-left', settingsfrmXY.Left);
pp.getPrefInt('settings-width', settingsfrmXY.Width);
pp.getPrefBool('settings-maximized', settingsfrmXY.maximized);
pp.getPrefBool('auto-connect', autoconnect);
pp.getPrefBool('play-sounds', playSounds);
pp.getPrefInt('sound-volume', Soundvolume);
pp.getPrefBool('show-only-online-contacts', showOnlyOnline);
pp.getPrefBool('show-only-im-visible-to-contacts', showOnlyImVisibleTo);
pp.getPrefBool('show-all-contacts-in-one', OnlOfflInOne);
pp.getPrefBool('show-unk-as-offline', showUnkAsOffline);
l := pp.getPrefBlobDef('sort-by');
sortBy := str2sortby(l);
pp.getPrefInt('temp-blink-time', tempBlinkTime);
pp.getPrefBool('transparency', transparency.forRoster);
pp.getPrefBool('transparency-chat', transparency.forChat);
pp.getPrefBool('transparency-tray', transparency.forTray);
pp.getPrefBool('transparency-chgonmouse', transparency.chgOnMouse);
pp.getPrefInt('transparency-active', transparency.active);
pp.getPrefInt('transparency-inactive', transparency.inactive);
pp.getPrefInt('transparency-vtray', transparency.tray);
pp.getPrefBool('autoaway-exit', autoaway.autoexit);
pp.getPrefBool('autoaway-away', autoaway.away);
pp.getPrefInt('autoaway-away-time', autoaway.awayTime);
pp.getPrefBool('autoaway-na', autoaway.na);
pp.getPrefInt('autoaway-na-time', autoaway.naTime);
pp.getPrefBool('autoaway-set-xstatus', autoaway.setxstatus);
pp.getPrefInt('autoaway-xstatus', autoaway.xstatus);
pp.getPrefBool('autoaway-ss', autoaway.ss);
pp.getPrefBool('autoaway-boss', autoaway.boss);
pp.getPrefBool('xstatus-auto-request', autoRequestXsts);
pp.getPrefBool('xstatus-in-tray', XStatusInTray);
pp.getPrefBool('blink-with-status', blinkWithStatus);
pp.getPrefStr('files-recv-path', FileSavePath);
pp.getPrefStr('proxy-host', MainProxy.addr.host);
pp.getPrefInt('proxy-port', MainProxy.addr.port);
if pp.getPrefBoolDef('proxy-ver5', True) then
MainProxy.proto := PP_SOCKS5
else
MainProxy.proto := PP_SOCKS4;
if not pp.getPrefBoolDef('proxy', False) then
MainProxy.proto := PP_NONE;
pp.getPrefStr('proxy-name', MainProxy.name);
pp.getPrefBool('proxy-auth', MainProxy.auth);
pp.getPrefBool('proxy-ntlm', MainProxy.NTLM);
pp.getPrefStr('proxy-user', MainProxy.user);
// MainProxy.user := pp.getPrefStrDef('proxy-user');
if pp.prefExists('proxy-pass64') then
l := pp.getPrefBlob64Def('proxy-pass64')
else
l := pp.getPrefBlobDef('proxy-pass');
MainProxy.pwd := UnUTF(passDecrypt(l));
l := pp.getPrefBlobDef('proxy-proto');
i := IndexStr(l, proxyproto2str);
if i < 0 then
begin
MainProxy.proto := PP_NONE;
end
else
begin
MainProxy.proto := TproxyProto(i);
end;
pp.getPrefInt('send-on-enter', sendOnEnter);
sU := '';
pp.getPrefStrList('spellcheck-languages', spellLanguages);
pp.getPrefStr('spellcheck-language-main', spellLanguageMain);
pp.getPrefInt('spellcheck-error-style', spellErrorStyle);
pp.getPrefStr('spellcheck-error-color', sU);
try
if not (sU = '') then
spellErrorColor := StringToColor(sU)
else
spellErrorColor := clRed;
except
spellErrorColor := clRed;
end;
// pp.getPrefBool('', );
// pp.getPrefStr('', );
// pp.getPrefInt('', );
// pp.getPrefDateTime('', );
// pp.Free;
// pp := NIL;
// backward compatibility
{ if lastVersion < $00080104 then // here i introduced BE_history
for i:=1 to EK_last do
if BE_history in supportedBehactions[i] then
include(behaviour[i].trig, BE_history);
// end of backward compatibility }
boundInt(inactivehideTime, 0, 60 * 60 * 10);
boundInt(blinkSpeed, 1, 15);
boundInt(transparency.active, 0, 255);
boundInt(transparency.inactive, 0, 255);
// l := curXStatusStr;
// mainFrm.ChangeXStatus(curXStatus);
// curXStatusStr := l;
// RnQmain.sbar.Repaint;
if Assigned(RnQmain) and Assigned(RnQmain.PntBar) then
RnQmain.PntBar.Repaint;
histcrypt.pwdKey := calculate_KEY1(histcrypt.pwd);
dockSet;
// applyDocking;
applyTransparency;
end; // setcfg
procedure loadCFG(zp: TZipFile);
var
fn: String;
s: RawByteString;
i: integer;
begin
i := -1;
if Assigned(zp) then
try
i := zp.IndexOf(configFileName);
if i >= 0 then
s := zp.data[i];
except
i := -1;
s := '';
end;
if i < 0 then
begin
if FileExists(AccPath + configFileName) then
fn := AccPath + configFileName
else
fn := AccPath + oldconfigFileName;
if not FileExists(fn) then
fn := myPath + defaultsConfigFileName;
s := loadfileA(fn);
end;
if not (s = '') then
MainPrefs.Load(s);
s := loadfileA(cmdLinePar.extraini);
MainPrefs.Load(s);
s := '';
end;
procedure loadCommonCFG;
begin
setcommoncfg(loadfileA(myPath + commonFileName))
end;
procedure saveCommonCFG;
begin
savefile2(myPath + commonFileName, getCommonCFG, True, MakeBackups)
end;
function EnumWindowsCallback(Handle: HWND; Param: LPARAM): Boolean; stdcall;
var
ClassName: array[0..257] of Char;
begin
GetClassName(Handle, ClassName, Length(ClassName));
Result := True;
if not (StrIComp(ClassName, 'TRnQmain') = 0) then
Exit;
if SendMessage(Handle, WM_FINDINSTANCE, 0, 0) <> 1337 then
Exit;
Previous := Handle;
Result := False;
end;
procedure beforeWindowsCreation;
procedure ParseCmdLineParams;
var
i, m: Integer;
s: String;
UIN: TUID;
begin
MyPath := ExtractFilePath(paramStr(0));
StickerPath := MyPath + 'Cache\Stickers\';
cmdLinePar.extraini := '';
cmdLinePar.startUser := '';
cmdLinePar.mainPath := '';
cmdLinePar.userPath := '';
cmdLinePar.logpath := '';
logpath := myPath;
cmdLinePar.useproxy := '';
{$IFDEF LANGDEBUG}
lang_debug := False;
xxx := False;
{$ENDIF LANGDEBUG}
i := 0;
while i < paramCount() do
begin
inc(i);
s := paramStr(i);
if s = '--add-ini' then
begin
inc(i);
cmdLinePar.extraini := paramStr(i);
end
{$IFDEF RNQ_PLAYER}
else if s = '--rqp' then
showRQP := True
{$ENDIF RNQ_PLAYER}
else if s = '--nosound' then
masterMute := True
else
{$IFDEF LANGDEBUG}
if s = '--lang' then
lang_debug := True
else
{$ENDIF}
if s = '--icqlink' then
begin
Inc(i);
Previous := 0;
EnumWindows(@EnumWindowsCallback, 0);
if Previous = 0 then
cmdLinePar.icqlink := paramStr(i)
else
begin
PostMessage(Previous, WM_HANDLEICQLINK, GlobalAddAtom(PChar(ParamStr(i))), 0);
Application.Terminate;
end;
//else if s='--icqdebug' then
// icqdebug := True
end else if s = '--mainpath' then
begin
inc(i);
cmdLinePar.mainPath := paramStr(i);
cmdLinePar.mainPath := includeTrailingPathDelimiter(cmdLinePar.mainPath);
if not DirectoryExists(cmdLinePar.mainPath) then
begin
m := messageDlg(getTranslation('Directory "%s" does not exist. Do you want to create it?', [cmdLinePar.mainPath]), mtConfirmation, [mbYes, mbIgnore, mbAbort], 0);
if m = mrAbort then
Halt;
if m = mrYes then
CreateDir(cmdLinePar.mainPath)
else
cmdLinePar.mainPath := '';
end;
end else if s = '--userpath' then
begin
inc(i);
cmdLinePar.userPath := paramStr(i);
cmdLinePar.userPath := includeTrailingPathDelimiter(cmdLinePar.userPath);
if not DirectoryExists(cmdLinePar.userPath) then
begin
m := messageDlg(getTranslation('Directory "%s" does not exist. Do you want to create it?', [cmdLinePar.userPath]), mtConfirmation, [mbYes, mbIgnore, mbAbort], 0);
if m = mrAbort then
Halt;
if m = mrYes then
CreateDir(cmdLinePar.userPath)
else
cmdLinePar.userPath := '';
end;
end else if s = '--logpath' then
begin
inc(i);
cmdLinePar.logpath := paramStr(i);
cmdLinePar.logpath := includeTrailingPathDelimiter(cmdLinePar.logpath);
if not DirectoryExists(cmdLinePar.logpath) then
cmdLinePar.logpath := '';
end else if s = '--proxy' then
begin
inc(i);
cmdLinePar.useproxy := paramStr(i);
// cmdLinePar.useproxy := includeTrailingPathDelimiter(cmdLinePar.useproxy);
// if not DirectoryExists(cmdLinePar.logpath) then
// cmdLinePar.logpath := '';
end else
// is it an UIN ?
try
UIN := s;
if TICQSession._isProtoUid(UIN) then
cmdLinePar.startUser := UIN;
except end;
end
end; // ParseCmdLineParams
var
s: String;
// needCheckPass : Boolean;
i: integer;
h: HMODULE;
// l : RawByteString;
// A, B : Integer;
// Control : TControl;
// d : Double;
// aI : Int64;
// sA : AnsiString;
// dd : TDate;
begin
// msgDlg(UnixToDateTime(getTLVdwordBE(2, snac,ofs));
// msgDlg(DateToStr(UnixToDateTime($40E2D73A)), mtInformation);
// msgDlg(DateToStr(UnixToDateTime($40E2D73A)), mtInformation);
// msgDlg(DateToStr(UnixToDateTime($40E39EFB)), false, mtInformation);
// l := #$40#$DE#$84#$00#$00#$00#$00#$00;
// l := #$40#$E0#$0E#$C0#$00#$00#$00#$00;
// l := #$40#$E0#$0E#$C0#$00#$00#$00#$00;
// l := #$40#$E0#$86#$9C#$00#$00#$00#$00;
{ Int64((@dd)^) := Qword_BEat(@l[1]);
// dd := UnixToDateTime(Qword_BEat(@l[1]));
// dd := UnixToDateTime(dword_BEat(@l[1]));
if dd < Now then
s := DateToStr(dd)
else
// s := IntToHex(DateTimeToUnix(now), 2);
s := IntToHex(Int64((@dd)^), 2);
// Int64((@dd)^) := Qword_BEat(@l[1]);
msgDlg(s, False, mtInformation);
}
// d := DateTimeToJulianDate(StrToDate('01.01.1981'));
// msgDlg(intToStr(invert(0139847)), mtConfirmation);
// ai := $9876ABCDEF;
// msgDlg(IntToHex(Int64(SwapLong(ai)), 8), mtConfirmation);
// SwapLong(@ai, 1);
// msgDlg(IntToHex(ai, 8), mtConfirmation);
// d := DateTimeToModifiedJulianDate(StrToDate('01.01.1981'));
// msgDlg(IntToHex((Int64((@d)^)), 8), mtConfirmation);
// i := $40DD9B4000000000;
// i := $40E323782635DAD5;
// d := Double((@i)^);
// msgDlg(DateToStr(ModifiedJulianDateToDateTime(d)), mtInformation);
// msgDlg(DateToStr(JulianDateToDateTime(d)), mtInformation);
// msgDlg(int2str64(int64((@d)^)), mtConfirmation);
// msgDlg(IntToHex(DateTimeToUnix(now), 8), mtInformation);
// sA := '/LXcUfUBfTTCMnuJyI+0tWhkMQ08nEQ=';
// sA := '/l5ajWuLiXce4gEmVNmDVTNnne4j';
// sA := 'U4JhnJXr1qoN+lFNYw==';
// sA := 'U4JhnJXr1qoN+lFN';
// sA := qip_msg_decr(sA, '123', $1B5F);
// msgDlg(sA, false, mtInformation);
//
// sA := 'How are you?';
// sA := qip_msg_crypt(sA, '123', $1B5F);
// sA := Base64DecodeString('AHRlc3QwMQAxMjM0NTY=');
// msgDlg(sA, false, mtInformation);
// msgDlg(GetDomain('http://c.icq.com/xtraz/img/avatar/avatar_10529.swf'), mtInformation);
{ s := openSavedlg(NIL, True, '*');
if s > '' then
begin
i := peer_oft_checksum_file(s);
msgDlg(IntToHex(i, 2), mtInformation);
end;
}
if initOnce then
Exit;
initOnce := True;
startTime := now;
ParseCmdLineParams;
Application.Initialize;
Application.ShowMainForm := False;
Application.HintHidePause := 60000;
Application.Title := 'R&Q';
WM_TASKBARCREATED := RegisterWindowMessage('TaskbarCreated');
timeformat.chat := FormatSettings.shortdateformat + ' hh:nn:ss';
timeformat.info := FormatSettings.shortdateformat + ' hh:nn';
timeformat.clock := 'hh:nn';
timeformat.log := FormatSettings.shortdateformat + ' hh:nn:ss.zzz';
timeformat.automsg := 'hh:nn';
supportedBehactions[EK_msg] := allBehactions;
supportedBehactions[EK_incoming] := allBehactions;
supportedBehactions[EK_outgoing] := allBehactions;
supportedBehactions[EK_contacts] := allBehactions;
supportedBehactions[EK_addedyou] := allBehactions;
supportedBehactions[EK_auth] := allBehactions;
supportedBehactions[EK_authreq] := allBehactions;
supportedBehactions[EK_authDenied] := allBehactions;
supportedBehactions[EK_statuschange] := allBehactions;
supportedBehactions[EK_typingBeg] := mtnBehactions;
supportedBehactions[EK_typingFin] := mtnBehactions;
supportedBehactions[EK_XstatusMsg] := allBehactions;
supportedBehactions[EK_buzz] := [BE_OPENCHAT, BE_HISTORY, BE_TIP, BE_FLASHCHAT, BE_SOUND];
resetCommonCFG;
loadCommonCFG;
LoadSomeLanguage;
DefineISOCountries;
AllProxies := nil;
uin2Bstarted := getUserAutoStart(AccPass);
if uin2Bstarted = '' then
uin2Bstarted := showUsers(AccPass);
if uin2Bstarted = '' then
halt(0);
repeat
s := 'R&Q' + uin2Bstarted;
Mutex := OpenMutex(MUTEX_MODIFY_STATE, False, PChar(s));
if Mutex <> 0 then
begin
CloseHandle(Mutex);
// needCheckPass := false;
// mutex := 0;
msgDlg(Str_already_run, True, mtWarning);
uin2Bstarted := showUsers(AccPass);
if uin2Bstarted = '' then
halt(0);
end;
until Mutex = 0;
i := findInAvailableUsers(uin2Bstarted);
if i < 0 then
begin
msgDlg('StartUser: Bad UIN', True, mtError);
halt(1);
end;
SQLDB := TSQLDatabase.Create;
Account.acks := Toutbox.create;
Account.outbox := Toutbox.create;
// visibleList:=TRnQContactList.create;
// invisibleList:=TRnQContactList.create;
RecentList := TRnQCList.create;
NotInList := TRnQCList.create;
IgnoreList := TRnQCList.create;
QuietList := TRnQCList.create;
UpdateViewInfoQ := TRnQCList.create;
groups := Tgroups.create;
// theme.smiles.root := myPath;
theme.fBasePath := RnQMainPath;
uinlists := Tuinlists.create;
retrieveQ := TRnQCList.create;
reqAvatarsQ := TRnQCList.create;
// reqXStatusQ := TRnQCList.create;
LoadTranslit;
childWindows := Tlist.create;
locked := False;
autoaway.time := 0;
userTime := -1;
eventQ := TeventQ.Create;
hotkeysEnabled := True;
plugins := Tplugins.create;
end; // beforeWindowsCreation
procedure startUser(const UID: TUID = '');
procedure ParseAbout(zp: TZipFile; var UID: TUID);
var
i: integer;
cfg, l, h: RawByteString;
begin
cfg := '';
if Assigned(zp) then
try
i := zp.IndexOf(AboutFileName);
if i >= 0 then
cfg := zp.data[i];
except
end;
while cfg > '' do
begin
// l:=chop(CRLF,cfg);
// h:=chop('=',l);
l := LowerCase(chop(CRLF, cfg));
h := Trim(chop('=', l));
l := Trim(l);
if h = 'account-id' then
begin
UID := UnUTF(l);
Break;
end;
end;
end;
const
maxProg = 17;
var
i // , k
: integer;
thisUser: TRnQUser;
// useProxy : Integer;
// v_proxyes : TarrProxy;
s, dbpath: String;
NeedConvert: Boolean;
// pr : TICQSession;
dbZip: TZipFile;
zipPrefs: boolean;
myInf: TICQContact;
AccUID: TUID;
pr: TICQSession;
begin
if not (UID = '') then
uin2Bstarted := UID;
i := findInAvailableUsers(uin2Bstarted);
if i < 0 then
begin
msgDlg('StartUser: Bad UIN', True, mtError);
halt(1);
end;
s := 'R&Q' + uin2Bstarted;
// there is no previous Mutex so create new one
Mutex := CreateMutex(nil, False, PChar(s));
// take ownership of our mutex
WaitForSingleObject(Mutex, INFINITE);
thisUser := availableusers[i];
AccPath := thisUser.path + thisUser.SubPath + PathDelim;
logpref.evts.onWindow := True;
// loadCommonCFG;
if cmdLinePar.logpath > '' then
logpath := cmdLinePar.logpath
else
logpath := myPath;
loggaEvtS('User: (ICQ)' + thisUser.UIN + ' starting');
SetProgBar(nil, 1 / maxProg);
MainPrefs := TRnQPref.create;
fantomWork := not DirectoryExists(AccPath); // New <20><> 2007.10.09
helpExists := FileExists(myPath + docsPath + getTranslation(helpFilename));
zipPrefs := False;
dbZip := nil;
s := AccPath + dbFilename + '5';
if not FileExists(s) then
s := AccPath + dbFilename + '4';
if not FileExists(s) then
begin // Trying to find saved files
s := AccPath + dbFilename + '5.new';
if not FileExists(s) then
begin
s := AccPath + dbFilename + '5.bak';
if not FileExists(s) then
s := '';
end
end;
if not (s = '') then
begin
dbZip := TZipFile.create;
try
dbZip.LoadFromFile(s);
zipPrefs := dbZip.Count > 0;
dbZip.Password := AccPass;
except
msgDlg('Error while opening DB archive', True, mtError);
// zipPrefs := false;
end;
if not zipPrefs then
begin
FreeAndNil(dbZip);
end;
end;
loadCFG(dbZip);
loggaEvtS('CFG: loaded');
AccUID := uin2Bstarted;
ParseAbout(dbZip, AccUID);
if AccUID = '' then
AccUID := uin2Bstarted;
with thisUser do
begin
Account.ProtoPath := AccPath;
Account.AccProto := TICQSession.Create(AccUID);
RnQUser := AccUID + ' "' + name + '"';
if pwd > '' then
Account.AccProto.pwd := pwd;
end;
// mainfrm.SetProgBar(2/maxProg); // <20><> <20><> <20><>, <20>.<2E>. <20><>
StayConnected := False;
CleanDisconnect := True;
// Account.AccProto.SetListener(RnQmain.ProtoEvent);
Account.AccProto.SetListener(Protocols_All.ProtoEvent);
InitProtoMenus(Account.AccProto);
resetCFG;
SetCFG(MainPrefs);
SetICQLinksHandler(HandleICQLinks);
// reset log files
if logpref.evts.clear then
deletefile(logpath + eventslogFilename);
if logpref.pkts.clear then
deletefile(logpath + packetslogFilename);
if logpref.evts.onFile and not fileIsWritible(logpath + eventslogFilename) then
begin
logpref.evts.onFile := False;
msgDlg(getTranslation('Can''t write to file: "%s"', [eventslogFilename]), False, mtError);
end;
if logpref.pkts.onFile and not fileIsWritible(logpath + packetslogFilename) then
begin
logpref.pkts.onFile := False;
msgDlg(getTranslation('Can''t write to file: "%s"', [packetslogFilename]), False, mtError);
end;
dbpath := AccPath + accountFilename;
NeedConvert := not FileExists(dbpath) or (SizeOfFile(dbpath) = 0);
histcrypt.enabled := SQLDB.ManageSecurity(SA_CHECK);
if not SQLDB.Connect then
begin
if histcrypt.enabled then
messageDlg(getTranslation('You have to provide a valid password for encrypted history!'), mtError, [mbOK], 0)
else
messageDlg(getTranslation('Failed to open history database'), mtError, [mbOK], 0);
if Assigned(Account.AccProto) then
begin
Account.AccProto.clear;
pr := Account.AccProto;
Account.AccProto := nil;
pr.Free;
end;
if Assigned(dbZip) then
FreeAndNil(dbZip);
FreeAndNil(MainPrefs);
try
CloseHandle(Mutex);
Mutex := 0;
except end;
RnQmain.Changeoradduser1Click(nil);
Exit;
end;
if NeedConvert then
SQLDB.ConvertHistory;
loggaEvtS('R&Q: ' + IntToStr(RnQBuild) + ' starting');
ChatCSS := LoadFromZipOrFile(dbZip, Account.ProtoPath, ChatCSSFileName);
chatFrm.InitDocument;
chatFrm.InitSpellCheck;
chatFrm.UpdateChatSettings;
loggaEvtS('Theme: loading');
reloadCurrentTheme;
picDrawFirstLtr := theme.ThemePath.fn = '';
loggaEvtS('Theme: loaded');
if not skipsplash then
theme.PlaySound('start');
SetProgBar(nil, 3 / maxProg);
if not startMinimized then
showForm(RnQmain);
if (showMainBorder) then
RnQmain.BorderStyle := bsNone
else
RnQmain.BorderStyle := bsSizeToolWin;
toggleMainfrmBorder(True, showMainBorder);
SetProgBar(nil, 4 / maxProg);
LoadProxies(dbZip, AllProxies);
SetProgBar(nil, 5 / maxProg);
loggaEvtS('hotkeys: loading');
loadMacros(dbZip);
updateSWhotkeys;
loggaEvtS('hotkeys: loaded');
loggaEvtS('DB: loading');
groups.FromString(LoadFromZipOrFile(dbZip, Account.ProtoPath, groupsFilename));
loadDB(dbZip, True);
loggaEvtS('DB: loaded');
SetProgBar(nil, 6 / maxProg);
if Assigned(Account.AccProto) then
Account.AccProto.SetPrefs(MainPrefs);
RnQmain.UpdateStatusGlyphs;
// mainfrm.SetProgBar(4/maxProg);
startTimer;
SetProgBar(nil, 7 / maxProg);
if cmdLinePar.useproxy > '' then
begin
// LoadProxies(v_proxyes);
for i := 0 to length(AllProxies) - 1 do
if (AllProxies[i].name = cmdLinePar.useproxy) or ('"' + AllProxies[i].name + '"' = cmdLinePar.useproxy) then
begin
// useProxy := i;
CopyProxy(MainProxy, AllProxies[i]);
Break;
end;
// ClearProxyArr(v_proxyes);
end;
// showForm(mainfrm);
SetProgBar(nil, 8 / maxProg);
lastUser := uin2Bstarted;
if RnQStartingStatus < 0 then
lastStatus := lastStatusUserSet
else
begin
lastStatusUserSet := byte(SC_UNK);
lastStatus := RnQStartingStatus;
end;
SetProgBar(nil, 9 / maxProg);
LoadExtSts(dbZip);
loadSpamQuests(dbZip);
loggaEvtS('Lists: loading');
loadLists(Account.AccProto, dbZip, Account.ProtoPath);
loggaEvtS('Lists: loaded');
mainDlg.RnQmain.roster.Visible := True;
mainDlg.RnQmain.SetFocusedControl(mainDlg.RnQmain.roster);
// lastUser := intToStr(StrToInt('Bag'));
SetProgBar(nil, 10 / maxProg);
// icq.webaware:=webaware;
RnQUser := Account.AccProto.MyAccNum;
myInf := Account.AccProto.getMyInfo;
if Assigned(myInf) then
RnQUser := myInf.displayed;
loggaEvtS('Various lists: loading');
SetProgBar(nil, 11 / maxProg);
// load tables
SetProgBar(nil, 13 / maxProg);
// loggaEvt('outbox: loading');
loadOutInbox(dbZip);
// loggaEvt('outbox: loaded');
// loggaEvt('inbox: loading');
// loadInbox((dbZip));
// loggaEvt('inbox: loaded');
SetProgBar(nil, 14 / maxProg);
loggaEvtS('Various lists: loaded');
RnQmain.updateCaption;
loggaEvtS('Lang: Translating');
translateWindows;
loggaEvtS('Lang: Translated');
rosterRebuildDelayed := True;
{$IFDEF RNQ_AVATARS}
IOresult;
if not DirectoryExists(AccPath + avtPath) then
ForceDirectories(AccPath + avtPath);
IOresult;
loggaEvtS('Avatars: loading');
loadAvatars(Account.AccProto, AccPath + avtPath);
loggaEvtS('Avatars: loaded');
{$ENDIF RNQ_AVATARS}
setRosterAnimation(animatedRoster);
StatusIcon := TStatusIcon.Create(RnQMain.Handle);
StatusIcon.OnGetPicTip := Protocols_All.GetTrayIconTip;
StatusIcon.TrayIcon.OnEvent := RnQmain.OnTrayEvent;
eventQ.onNewTop := StatusIcon.Update;
StatusIcon.TrayIcon.Show;
StatusIcon.Update;
contactsPnlStr := intToStr(Tlist(Account.AccProto.readList(LT_ROSTER)).Count);
Account.acks.clear;
if Assigned(PrefSheetFrm) then
PrefSheetFrm.Reset;
SetProgBar(nil, 15 / maxProg);
plugins.Load;
SetProgBar(nil, 16 / maxProg);
if reopenchats then
chatFrm.loadPages(loadFromZipOrFile(dbZip, Account.ProtoPath, reopenchatsFileName));
FreeAndNil(dbZip);
// All loaded!
try // If exists old type files - delete them all
RenameFile(AccPath + dbFilename + '4', AccPath + dbFilename + '4.bak');
deletefile(AccPath + dbFilename + '4');
deletefile(AccPath + dbFilename + '3');
deletefile(AccPath + dbFilename);
deletefile(AccPath + rosterFileName1);
deletefile(AccPath + groupsFilename);
deletefile(AccPath + ignoreFileName1);
deletefile(AccPath + nilFilename1);
deletefile(AccPath + retrieveFilename1);
deletefile(AccPath + configFileName);
deletefile(AccPath + inboxFilename);
deletefile(AccPath + outboxFilename);
deletefile(AccPath + macrosFileName);
deletefile(AccPath + uinlistFilename);
deletefile(AccPath + reopenchatsFileName);
deletefile(AccPath + SpamQuestsFilename);
deletefile(AccPath + extstatusesFilename);
deletefile(AccPath + proxiesFileName);
except
// RnQFileUtil.saveFile(userPath+dbFileName, s, True);
msgDlg('Error on deleting old lists', True, mtError);
end;
if lockOnStart then
begin
startingLock := True;
if not doLock then
exit;
enD;
startingLock := False;
if docking.Dock2Chat and docking.Docked2chat then
begin
RnQmain.WindowState := wsNormal;
showForm(RnQmain);
ForceForegroundWindow(chatFrm.Handle)
end else
ForceForegroundWindow(RnQmain.Handle);
userTime := 0;
SetProgBar(nil, 0);
if autoconnect then
DoConnect;
loggaEvtS('User: started');
CheckBDays;
if not (cmdLinePar.icqlink = '') then
begin
ProcessICQLink(cmdLinePar.icqlink);
cmdLinePar.icqlink := '';
end;
// if not startMinimized then
// showForm(mainfrm);
// SetMenu(mainFrm.Handle, mainFrm.menu.Handle);
end; // startUser
procedure quitUser;
var
pr: TICQSession;
begin
if userTime < 0 then
Exit;
userTime := -1;
loggaEvtS('Quit user');
if Assigned(plugins) then
try
plugins.unload;
except end;
StopMainTimer;
TipsHideAll;
chatFrm.closeAllPages(True);
mainDlg.RnQmain.roster.Visible := False;
{ if notInList.empty or (NILdoWith = 1)
or ((NILdoWith = 0) and (messageDlg(getTranslation('You have some not-in-list contact.\nDo you want to see them next time?'),mtConfirmation,[mbyes,mbNo],0, mbYes, 30) = mrNo)) then
deleteFile(userPath+nilFileName1)
else
if not saveFile(userPath+nilFileName1, notinlist.toString) then
msgDlg(getTranslation('Error saving not-in-list'),mtError);
}
if (NILdoWith = 1) or ((NILdoWith = 0) and not notinlist.empty and
(MessageDlg(GetTranslation('You have some not-in-list contact.\nDo you want to see them next time?'), mtConfirmation,
[mbYes, mbNo], 0, 30) = mrNo)) then
notinlist.clear;
// theme.PlaySound('quit');
SQLDB.Disconnect();
FlushLogPktFile();
FlushLogEvFile();
roasterlib.clear;
if not (startingLock or fantomWork) then
begin
// groups.save;
// saveLists(MainProto);
// saveInbox;
// saveOutbox;
// saveCFG;
// saveAutoMessages;
// saveMacros;
// saveDB;
// saveRetrieveQ;
// if reopenchats then chatFrm.savePages;
// SaveExtSts;
// SaveSpamQuests;
UpdateProperties;
saveCommonCFG;
saveAllListsSync(Account.ProtoPath, Account.AccProto, AllProxies);
end
// else
// roasterLib.clear;
;
loggaEvtS('Properties saved');
AccPass := '';
chatFrm.PagesEnumStr := '';
trayIconGuid := GUID_NULL;
FreeAndNil(MainPrefs);
FreeAndNil(StatusIcon);
FreeAndNil(spellLanguages);
MonPositions.Clear;
Account.outbox.clear;
eventQ.onNewTop := nil;
eventQ.Clear;
groups.Clear;
RnQmain.roster.Clear;
FreeAndNil(PrefSheetFrm);
FreeAndNil(wpFrm); // we must free it before closeAllChildWindows to avoid AV
// freeandnil();
RnQmain.closeAllChildWindows;
Account.AccProto.Clear;
RecentList.Clear;
NotInList.Clear;
RetrieveQ.Clear;
ReqAvatarsQ.Clear;
clearDB(TICQSession.ContactsDB);
try
if Assigned(Account.AccProto) then
begin
pr := Account.AccProto;
Account.AccProto := nil;
pr.Free;
end;
except end;
try
Account.AccProto := nil;
except end;
// reqXStatusQ.Clear;
DragAcceptFiles(RnQmain.Handle, False);
RnQmain.oldHandle := 0;
theme.ClearThemelist;
if Assigned(ContactsTheme) then
ContactsTheme.Clear(tsc_all);
// rqSmiles.Clear(tsc_all);
theme.clear(tsc_all);
// destroy our mutex
try
CloseHandle(Mutex);
Mutex := 0;
except end;
loggaEvtS('User exited');
// FreeAndNil(RnQprefs);
end; // quitUser
const
splitMsg = 'automsg: ';
procedure loadMacros(zp: TZipFile);
var
s: RawByteString;
i: integer;
begin
i := -1;
if Assigned(zp) then
try
i := zp.IndexOf(macrosFileName);
if i >= 0 then
s := zp.data[i];
except
i := -1;
s := '';
end;
if i < 0 then
s := loadfileA(Account.ProtoPath + macrosFileName);
str2macros(s, macros)
end;
procedure quit;
begin
if not initOnce then
Exit;
InitOnce := False;
plugins.castEv(PE_QUIT); // Added For Test Purpose
SoundUnInit;
DisableSounds := True;
StayConnected := False;
CleanDisconnect := True;
StopMainTimer;
try
Account.AccProto.Disconnect;
except end;
Running := False;
UninstallHook;
StopSpellTask;
chatFrm.StopTimer(HintTimerOpen);
if (Assigned(hintwnd)) then
hintwnd.Hide;
FreeAndNil(hintwnd);
RnQmain.Hide;
chatFrm.UpdateChatfrmXY;
// chatFrm.Hide; // Causes AV in Sciter
if Assigned(AllHistSrchForm) then
AllHistSrchForm.UpdateSearchFrmXY;
if Assigned(PrefSheetFrm) then
PrefSheetFrm.UpdateFormXY;
quitUser;
quitconfirmation := False;
FreeAndNil(logfrm);
// applyDocking(True);
RnQmain.roster.EndUpdate;
// freeAndNIL(xStatusForm);
// ClearThemelist;
UnLoadTranslit;
FreeAndNil(plugins);
ClearLanguage;
ClearAvailableUsers;
ClearPrefPages;
try
if Assigned(Account.AccProto) then
Account.AccProto.Free;
except end;
try
Account.AccProto := nil;
except end;
FreeAndNil(SQLDB);
// freeAndNIL(visibleList);
// freeAndNIL(invisibleList);
FreeAndNil(RecentList);
FreeAndNil(NotInList);
FreeAndNil(IgnoreList);
FreeAndNil(QuietList);
FreeAndNil(UpdateViewInfoQ);
FreeAndNil(ChildWindows);
// FreeAndNil(ReqXStatusQ);
FreeAndNil(ReqAvatarsQ);
FreeAndNil(RetrieveQ);
FreeAndNil(Groups);
FreeAndNil(Account.outbox);
// acks.clear;
FreeAndNil(Account.acks);
FreeAndNil(eventQ);
FreeAndNil(uinlists);
// freeAndNIL(Account.AccProto);
FreeAndNil(PrefSheetFrm);
FlushLogPktFile();
loggaEvtS('Shutdown', '', True);
// FlushLogEvFile();
// RnQmain.Close;
Application.Terminate;
end; // quit
procedure afterWindowsCreation;
var
i: integer;
begin
Application.OnHint := RnQmain.displayHint;
RnQmain.roster.NodeDataSize := sizeOf(Pointer);
running := True;
mainfrmHandleUpdate;
// applyDocking;
applyTransparency;
for i := 0 to screen.FormCount - 1 do
applyCommonSettings(screen.forms[i]);
SoundInit;
// ShowHintsInChat2 := True;
end; // afterWindowsCreation
initialization
initOnce := False;
onContactCreation := ContactCreation;
onContactDestroying := contactDestroying;
cacheDir := ExtractFilePath(paramStr(0)) + 'Cache\';
ForceDirectories(cacheDir);
imgCacheInfo := TMemIniFile.Create(cacheDir + 'Images.ini');
GSSL_DLL_DIR := modulesPath;
SCITER_DLL_DIR := modulesPath;
finalization
if Assigned(imgCacheInfo) then
imgCacheInfo.Free;
end.