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

570 lines
17 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
This file is part of R&Q.
Under same license
}
unit globalLib;
{$I RnQConfig.inc}
interface
uses
Windows, SysUtils, Graphics, Controls, ComCtrls, Types, Classes, Forms, Messages,
events,
groupsLib, roasterLib, pluginLib, RnQTrayLib, outboxLib, uinlistLib,
RQThemes, RDGlobal,
RnQMacros, RnQPrefsLib,
ICQCommon, ICQContacts, ICQSession, Nodes;
{$I NoRTTI.inc}
const
RQversion: Longword = $000A01FF; // remember: it's hex
RnQBuild = 1129;
RnQBuildCustom = 67;
DevMode = {$IFDEF DEBUG}True{$ELSE}False{$ENDIF};
PIC_CLIENT_LOGO = TPicName('rnq');
{$I RnQBuiltTime.inc}
type
TWhatForm = (WF_SHEET, WF_USERS, WF_WP, WF_WP_MRA, WF_SEARCH);
TFrmViewMode = (vmFull, vmShort);
TFormXY = record
top, left, height, width: integer;
maximized: boolean;
end;
TSortBy = (SB_NONE, SB_ALPHA, SB_EVENT);
TBehAction = (BE_TRAY, BE_SOUND, BE_OPENCHAT, BE_HISTORY, BE_SAVE, BE_TIP, BE_POPUP, BE_FLASHCHAT, BE_BALLOON);
Tbehaviour = record
trig: set of Tbehaction;
tiptime: integer;
tiptimeplus: integer;
tiptimes: boolean;
// doFlashChat : Boolean;
// flash
end;
Tbehaviours = array [1 .. EK_last] of Tbehaviour;
pTCE = ^TCE;
TCE = packed record
// history0:Tobject; // a probably wanted history, won't be saved to disk
Notes: string;
LastEventTime: Tdatetime;
LastMsgTime: Tdatetime;
LastIncoming: Tdatetime;
Node: TNode;
Keylay: integer;
AskedAuth: boolean;
DontDelete: boolean;
ToQuery: boolean;
end;
const
{$IFNDEF UNICODE}
ALPHANUMERIC = ['a' .. 'z', 'A' .. 'Z', '0' .. '9', 'à' .. 'ÿ', 'À' .. 'ß', '¨', '¸'];
{$ENDIF UNICODE}
WHITESPACES = [#9, #10, #13, #32];
EMAILCHARS = ['a' .. 'z', 'A' .. 'Z', '0' .. '9', '-', '_', '.'];
// UID_CHARS = ['a'..'z','A'..'Z','0','1'..'9','-','_','.', '@'];
UID_CHARS = ['a' .. 'z', 'A' .. 'Z', '0', '1' .. '9', '_', '.', '@'];
BreakChars = [' ', ';', ',', #10, #13];
FTPURLCHARS = [#33, #35 .. #38, #40 .. #59, #61, #63 .. #90, #92, #94 .. #255];
WEBURLCHARS = FTPURLCHARS;
DOCK_SNAP = 5;
MaxDispayedLen = 40;
// By Rapid D
MaxXStatusLen = 251;
MaxXStatusDescLen = 251;
WM_DOCK = WM_USER + 200;
WM_HANDLEICQLINK = WM_USER + 300;
progLogonTotal = 6.3;
timeBetweenMsgs = 21; // In 0.1 of seconds
saveDBdelay = 100;
DTseconds = 1 / (SecsPerDay);
allBehactions = [BE_TRAY, BE_SOUND, BE_OPENCHAT, BE_HISTORY, BE_SAVE, BE_TIP, BE_POPUP, BE_FLASHCHAT, BE_BALLOON];
allBehactionsButTip = allBehactions - [BE_TIP];
mtnBehactions = [BE_OPENCHAT, BE_TIP, BE_SOUND, BE_HISTORY, BE_BALLOON];
RnQImageTag = '';
RnQImageUnTag = '';
RnQImageExTag = '';
RnQImageExUnTag = '';
// additional flags start from the top, to not collide with ICQv9 flags
IF_sendWhenImVisible = 1 shl 31;
IF_pager = 1 shl 30; // it is a pager message
IF_auth = 1 shl 29; // it is a Autorization Request message
IF_not_show_chat = 1 shl 28;
IF_not_save_hist = 1 shl 27;
IF_Delivered = 1 shl 26;
// Msg delivered to recipient
IF_Not_Delivered = 1 shl 25;
IF_Server_Accept = 1 shl 24; // Msg on server
IF_XTended_EVENT = 1 shl 23; // XStatus desc in status change for example
IF_Bin = 1 shl 6; // msg is not Text string - dont crypt :)
IF_Encrypt = 1 shl 7; // msg was encrypted!
IF_CODEPAGE_MASK = (1 shl 8) or (1 shl 9) or (1 shl 10);
// filenames
userthemeFilename = 'user.theme.ini';
contactsthemeFilename = 'contacts.theme.ini';
packetslogFilename = 'packets.log';
commonFileName = 'common.ini';
OldconfigFileName = 'andrq.ini';
configFileName = 'rnq.ini';
defaultsConfigFileName = 'defaults.ini';
groupsFilename = 'groups.ini';
msgidFilename = 'servermsgs.ini';
// myinfoFilename='myinfo';
inboxFilename = 'inbox';
outboxFilename = 'outbox';
macrosFilename = 'macros';
dbFilename = 'db';
// langFilename='lang.txt';
uinlistFilename = 'uinlists';
extstatusesFilename = 'extstatuses';
SpamQuestsFilename = 'spamquests.txt';
reopenchatsFileName = 'reopen.list.txt';
proxiesFilename = 'proxies.list.txt';
// recent version of list files have a trailing .txt
// here i keep old filenames to be able to load old versions
// rosterFileName='contact.list';
// visibleFileName='visible.list';
// invisibleFileName='invisible.list';
// ignoreFileName='ignore.list';
// nilFilename='not.in.list';
// retrieveFilename='retrieve.list';
rosterFileName1 = 'contact.list.txt';
ignoreFileName1 = 'ignore.list.txt';
quietFileName1 = 'quiet.list.txt';
nilFilename1 = 'not.in.list.txt';
retrieveFilename1 = 'retrieve.list.txt';
AboutFileName = 'about.txt';
ChatCSSFileName = 'chat.user.css';
// cachedThemeFilename='cache.theme';
spamsFilename = '0spamers';
snapshotFilename = 'snapshot.png';
helpFilename = 'miniguide.html';
rnqSite = 'https://rnq.ru';
accountFilename = 'account.s3db';
// paths
historyPath = 'history\';
// langsPath='lang\';
avtPath = 'Devils\';
docsPath = 'docs\';
// macro opcodes
OP_NONE = 0;
OP_CHAT = 1;
OP_ROSTER = 2;
OP_TRAY = 3;
OP_CLEAREVENT = 4;
OP_CLEAREVENTS = 5;
OP_POPEVENT = 6;
OP_QUIT = 7;
OP_SHUTDOWN = 8;
OP_GROUPS = 9;
OP_MAINMENU = 10;
OP_STATUSMENU = 11;
OP_VISIBILITYMENU = 12;
OP_BROWSER = 13;
OP_OFFLINECONTACTS = 14;
OP_AUTOSIZE = 15;
OP_CONNECT = 16;
OP_CD_PLAY = 17;
OP_CD_STOP = 18;
OP_VIEWINFO = 19;
OP_ADDBYUIN = 20;
OP_WP = 21;
OP_TOGGLEBORDER = 22;
OP_PREFERENCES = 23;
OP_LOCK = 24;
OP_HINT = 25;
OP_TIP = 26;
OP_RELOADTHEME = 27;
OP_RELOADLANG = 28;
OP_VISIBLE_TO = 29;
OP_TOGGLE_SOUND = 30;
OP_BOSSKEY = 31;
OP_RESTARTRNQ = 32;
OP_SEARCHALLHISTORY = 33;
OP_LAST = 33;
macro2str: array [OP_CHAT .. OP_LAST] of AnsiString = ('Show/hide chat window', // 'chat',
'Show/hide contact list', // 'roster',
'Simulate double-click on tray', // 'tray',
'Clear event', // 'clear event',
'Clear all events', // 'clear events',
'Pop event', 'Quit', 'Shutdown the computer', // 'shutdown',
'Show/hide groups', // 'groups',
'Pop up main menu', // 'main menu',
'Pop up status menu', // 'status menu',
'Pop up visibility menu', // 'visibility menu',
'Open browser', // 'browser',
'Show/hide offline contacts', // 'offline contacts',
'Toggle autosize', // 'autosize',
'Connect', 'Play audio cd', // 'cd play',
'Stop/eject audio cd', // 'cd stop',
'Show contact info', // 'view info',
'Show ''add by uin'' dialog', // 'by uin',
'Show white-pages', // 'wp',
'Toggle contact list border', // 'toggle border',
'Show preferences', // 'preferences',
'Lock', 'Contact tip pop up', // 'show hint',
'Simulate double-click on tip message', // 'tip',
'Reload theme', 'Reload language', 'Visible to selected contact', // 'visible to',
'Sound on/off', // 'toggle sound'
'Bosskey', 'Restart R&Q', 'Search in all history files');
VK_A = 65;
VK_B = 66;
VK_C = 67;
VK_D = 68;
VK_E = 69;
VK_F = 70;
VK_G = 71;
VK_H = 72;
VK_I = 73;
VK_J = 74;
VK_K = 75;
VK_L = 76;
VK_M = 77;
VK_N = 78;
VK_O = 79;
VK_P = 80;
VK_Q = 81;
VK_R = 82;
VK_S = 83;
VK_T = 84;
VK_U = 85;
VK_V = 86;
VK_W = 87;
VK_X = 88;
VK_Y = 89;
VK_Z = 90;
{
VK_ESC=27;
VK_BS=8;
}
// behactions2str:array [Tbehaction] of string=('tray','sound','openchat',
// 'history','save','tip','popupchat');
behactions2str: array [Tbehaction] of string = ('tray notification', 'play sound', 'open a chat', 'add to history',
'save to disk', 'show pop-up message', 'pop up chat', 'flash chat', 'show balloon in tray (Win2K+)');
sortby2str: array [TsortBy] of RawByteString = ('none', 'alpha', 'event');
type
TRnQPageControl = Class(TPageControl)
procedure WMEraseBkGnd(var Message: TWMEraseBkGnd);
// procedure DrawTab(TabIndex: Integer; const Rect: TRect; Active: Boolean); virtual;
end;
type
TRnQViewInfoForm = class(TForm)
contact: TICQContact;
constructor doAll(owner_: Tcomponent; c: TICQContact); virtual; abstract;
public
readOnlyContact: boolean;
procedure UpdateInfo(Async: Boolean = True); virtual; abstract;
procedure UpdateCntAnP; virtual; Abstract;
procedure ClearAoP(pictype: Integer = 0); virtual; abstract;
procedure UpdateClock; virtual; abstract;
end;
type
TRnQAccount = record
ProtoPath: String;
// db : TZipFile;
AccProto: TICQSession;
outbox: Toutbox;
acks: Toutbox;
end;
{$I PubRTTI.inc}
TQuestAns = record
q: String;
a: array of String;
end;
TQuestAnsArr = array of TQuestAns;
{$I NoRTTI.inc}
var
outboxprocessChk: boolean = True;
ContactsTheme: TRQtheme;
// ICQ :TICQSession;
// MainProto : IRnQProtocol;
// MainProto : TICQSession;
Account: TRnQAccount;
MainPrefs: TRnQPref;
// userPath : String;
AccPath: String;
MakeBackups: Boolean;
// gmtCodes,languageCodes,countryCodes,pastCodes,ageCodes,interestCodes,genderCodes :Tcodes;
eventQ: TeventQ;
plugins: Tplugins;
progStart: double;
StatusIcon: TStatusIcon;
usertime: integer;
startTime: Tdatetime;
WM_TASKBARCREATED: Longword;
// contactsPnl,
// freePnl :TstatusPanel;
contactsPnlStr: String;
locked, startingLock: boolean;
hotkeysEnabled: boolean;
CloseFTWndAuto: boolean;
outboxSbarRect: Trect;
supportedBehactions: array [1 .. EK_last] of set of Tbehaction;
// here i bookmark last selected node, cause it could change between clicks
clickedContact: TICQContact;
// focusedCnt : TICQContact;
clickedNode: TNode;
prefHeight: integer;
hideScrollTimer: integer;
saveDBtimer2: integer;
CmdLinePar: record
StartUser: TUID;
extraini, userPath, mainPath, logpath, useproxy, icqlink: String;
// NoSound : Boolean;
end;
lastOnTimer: Tdatetime;
showRosterTimer: integer;
inactiveTime: integer;
NoIncomingCounter: integer; // if > 0, IE_incoming means people was here before (used in the login process)
childWindows: Tlist;
MustQuit: boolean = False; // Âûçûâàåòñÿ èç ïëàãèíîâ, ÷òîáû èõ íîðìàëüíî çàâåðøèòü óñïåòü.
docking: record
pos: (DP_right, DP_left);
bakOfs, bakSize: Tpoint;
enabled, active, appbar, appbarFlag, tempOff, Dock2Chat, Docked2chat: boolean;
end;
fantomWork, ShowUINDelimiter, XStatusInTray,
blinkWithStatus, menuViaMacro, SaveOutboxDelayed, SaveInboxDelayed, SaveGroupsDelayed, appBarResizeDelayed, saveListsDelayed,
saveCfgDelayed, autosizeDelayed, dbUpdateDelayed, // requires a roasterLib.repaint
StayConnected, Running, CleanDisconnect: boolean;
chatfrmXY: TformXY;
searchfrmXY: TformXY;
settingsfrmXY: TformXY;
oldForeWindow: Thandle;
groups: Tgroups;
usersPath: string;
lastUser: TUID;
userCharSet: integer;
imAwaySince: Tdatetime;
lastSearchTime: Tdatetime;
selectedColor: Tcolor;
dialogFrm: TForm;
uinlists: Tuinlists;
// myStatus,
// visibleList, invisibleList,
IgnoreList, QuietList, NotInList, RecentList, updateViewInfoQ, retrieveQ, reqAvatarsQ{, reqXStatusQ}: TRnQCList;
// timers
outboxCount: integer;
blinkCount: word;
delayCount: word;
longDelayCount, reconnectdelayCount: byte;
flapSecs: byte;
blinking: boolean;
toReconnectTime: integer;
// options
focusOnChatPopup: boolean;
quoting: record
cursorBelow: boolean;
quoteselected: boolean;
width: integer;
end;
behaviour: Tbehaviours;
SpamFilter: record
IgnoreNIL, Warn, AddToHist, IgnoreAuthNIL,
// rules
UseBot, UseBotFromFile, NotNIL, NotEmpty, NoBadWords, MultiSend: boolean;
BotTriesCount: integer;
UINgt: integer;
BadWords: String;
Quests: TQuestAnsArr;
end;
histCrypt: record
enabled: boolean;
savePwd: boolean;
pwdKey: integer;
pwd: String;
end;
AccPass, NewAccPass: String;
autoaway: record
time: cardinal;
// {$IFDEF WIN98_SUP}
// lastMousePos :Tpoint;
// lastKeybPos :integer;
// {$ENDIF WIN98_SUP}
away, na, ss, boss, autoexit, setVol: Boolean;
awayTime, naTime: Integer;
triggered: (TR_NONE, TR_AWAY, TR_NA);
setxstatus: Boolean;
xstatus: Integer;
bakstatus: Byte;
bakxstatus: Byte;
vol: Integer;
end;
BossMode: Record
isBossKeyOn, activeChat, toShowChat, toShowCL: boolean;
end;
// themeprops :array of TthemeProperty;
BrowserCmdLine: String;
FTOutPorts: String;
splitX, splitY, inactiveHideTime, blinkSpeed: integer;
TipsMaxAvtSize: integer;
TipsMaxAvtSizeUse: boolean;
RelativeTimeInChat: Boolean;
RelativeTimeInChatDays,
RelativeTimeInChatHours: Integer;
UseDefaultBrowser: boolean;
minOnOff: boolean;
minOnOffTime: integer; // in seconds
autostartUIN: TUID;
RnQStartingStatus, RnQStartingVisibility: Int8;
LastStatus, LastStatusUserSet: Int8;
rosterTitle: string;
fixingWindows: record
lastWidth, lastRightSpace: integer;
onTheRight: boolean;
end;
sendOnEnter, tempBlinkTime, wheelVelocity: integer;
disabledPlugins: string;
sortBy: TsortBy;
transparency: record
forRoster, forChat, forTray: boolean;
chgOnMouse: boolean;
active, inactive: integer;
tray: integer;
end;
macros: Tmacros;
CheckUpdate: record
AutoChecking, Checking, Enabled, Betas: Boolean;
Every: Integer;
Last: TDateTime;
end;
fontstylecodes: record
enabled: boolean;
end;
spellLanguages: TStringList = nil;
spellLanguageMain: String;
spellErrorColor: TColor;
spellErrorStyle: Integer;
ChatLoadBuffer: Integer;
ChatCSS: String;
BarPos, FilterPos: Integer;
// booleans
AutoRequestXsts, ShowHintsInCL, ShowHintsInChat, AnimateWindows,
// showClientID,
ConnectOnConnection, reopenchats, closeChatOnSend, ClosePageOnSingle, filterBarOnTop, rosterbarOnTop, animatedRoster,
ShowMainBorder, lockOnStart, closeAuthAfterReply, AutoConsumeEvents,
DsblEvnt4ClsdGrp, EnableIgnoreList, EnableQuietList, inactiveHide, optimizeDB, doFixWindows, minimizeRoster, AutoReconnect,
startMinimized, autoSwitchKL, skipSplash, incomingOnAway, enteringProtoPWD, check4readonly,
dontSavePwd, clearPwdOnDSNCT, showStatusOnTabs,
// webaware,
singleDefault, ShowGroups, ShowEmptyGroups, autoCopyHist, bViewTextWrap, indentRoster, collapseGroups, showDisconnectedDlg, autoConnect,
alwaysOnTop, chatAlwaysOnTop, useLastStatus, useSmiles, ShowAniSmlPanel, QuitConfirmation, showIncomingDlg,
showOnlyOnline, showUnkAsOffline, OnlOfflInOne, autosizeFullRoster, AutosizeRoster, autosizeUp,
snapToScreenEdges, useSingleClickTray,
// SupportTyping, // In ICQv9.pas
avatarShowInChat, avatarShowInHint, avatarShowInTray, avatarShowInTaskBar, AvatarUsePalette, showXStatusMnu, showNewXStatuses, UseContactThemes, xxx,
usePlugPanel, useMainPlugPanel, AskPassOnBossKeyOn, helpExists,
// AutoCheckGoOfflineUsers : Boolean;
// Chat & History
EnableImgLinksIn, EnableImgLinksOut, EnableSpellCheck, EnableStickers, EnableRecentlyOffline,
ChatSmoothFontRendering, TrimMsgNewLines, AnimatedScroll, HandleICQLinks: Boolean;
UseWebProtocol: Boolean = False;
StickerResolution, PreferredResolution, ChatImageQuality, ServerToUpload, RecentlyOfflineDelay: Integer;
// haveToApplyTheme : Boolean;
NILdoWith: Byte; // 0 - ask; 1 = clear all; 2 = save
TypingInterval: Integer;
prefPages: array of TPrefPage;
Mutex: cardinal;
UserStarting: Boolean = False;
// const
// supportInvisCheck = false;
procedure AddPrefPage(index: Byte; const Cpt: String);
procedure ClearPrefPages;
type
TUpdateLayeredWindow = function(Handle: Thandle; hdcDest: HDC; pptDst: PPoint; _psize: PSize; hdcSrc: HDC; pptSrc: PPoint;
crKey: COLORREF; pblend: PBLENDFUNCTION; dwFlags: DWORD): boolean; stdcall;
var
g_hLib_User32: HMODULE;
g_pUpdateLayeredWindow: TUpdateLayeredWindow;
implementation
uses
Themes;
procedure ClearPrefPages;
var
i: integer;
begin
if Length(prefPages) > 0 then
for i := 0 to Length(prefPages) - 1 do
FreeAndNil(prefPages[i]);
{ with prefPages[I] do
begin
Free;
end; }
SetLength(prefPages, 0);
end;
procedure AddPrefPage(index: Byte; const Cpt: String);
var
i: integer;
begin
i := Length(prefPages);
SetLength(prefPages, i + 1);
prefPages[i] := TPrefPage.Create;
with prefPages[i] do
begin
idx := index;
Name := Cpt;
Caption := Cpt;
end;
end;
procedure TRnQPageControl.WMEraseBkGnd(var Message: TWMEraseBkGnd);
begin
// if (not StyleServices.Enabled) or (not ParentBackground) then
if (not StyleServices.enabled) or (not ParentBackground) then
inherited
else
Message.Result := 1;
end;
end.