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

497 lines
14 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
Winapi.Windows, Winapi.Messages, System.Classes, System.SysUtils, Vcl.Graphics,
groupsLib, pluginLib, RnQTrayLib, RQThemes, RDGlobal, RnQMacros, RnQPrefsLib,
ICQCommon, ICQContacts, ICQSession, Nodes, outboxLib, uinlistLib, events;
{$I NoRTTI.inc}
const
RQversion: Longword = $000A01FF; // remember: it's hex
RnQBuild = 1140;
RnQBuildCustom = 106;
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);
TFrmViewMode = (vmFull, vmShort);
TFormDimen = record
Top, Left, Height, Width: Integer;
Maximized: Boolean;
end;
TFormPos = class
Left: Integer;
Top: Integer;
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;
DontDelete: boolean;
end;
const
{$IFNDEF UNICODE}
ALPHANUMERIC = ['a' .. 'z', 'A' .. 'Z', '0' .. '9', 'à' .. 'ÿ', 'À' .. 'ß', '¨', '¸'];
{$ENDIF UNICODE}
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', '_', '.', '@'];
MaxDispayedLen = 40;
// By Rapid D
MaxXStatusLen = 251;
MaxXStatusDescLen = 251;
WM_HANDLEICQLINK = WM_USER + 300;
ProgLogonTotal = 6.3;
TimeBetweenMsgs = 1000;
SaveDelay = 5000;
DTseconds = 1 / (SecsPerDay);
allBehactions = [BE_TRAY, BE_SOUND, BE_OPENCHAT, BE_HISTORY, BE_SAVE, BE_TIP, BE_POPUP, BE_FLASHCHAT, BE_BALLOON];
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_Patched = 1 shl 22; // Msg was updated/deleted on server
IF_Bin = 1 shl 6; // msg is not Text string - dont crypt :)
IF_Encrypt = 1 shl 7; // msg was encrypted!
IF_Encrypt_ECC = 1 shl 21; // ECDH keys were used
IF_CODEPAGE_MASK = (1 shl 8) or (1 shl 9) or (1 shl 10);
// filenames
userthemeFilename = 'user.theme.ini';
contactsthemeFilename = 'contacts.theme.ini';
requestslogFilename = 'requests.log';
commonFileName = 'common.ini';
OldconfigFileName = 'andrq.ini';
ConfigFileName = 'rnq.ini';
defaultsConfigFileName = 'defaults.ini';
groupsFilename = 'groups.ini';
inboxFilename = 'inbox';
outboxFilename = 'outbox';
macrosFilename = 'macros';
dbFilename = 'db';
uinlistFilename = 'uinlists';
extstatusesFilename = 'extstatuses';
SpamQuestsFilename = 'spamquests.txt';
reopenchatsFileName = 'reopen.list.txt';
proxiesFilename = 'proxies.list.txt';
rosterFileName1 = 'contact.list.txt';
ignoreFileName1 = 'ignore.list.txt';
quietFileName1 = 'quiet.list.txt';
nilFilename1 = 'not.in.list.txt';
retrieveFilename1 = 'retrieve.list.txt';
MainCSSFileName = 'main.user.css';
ChatCSSFileName = 'chat.user.css';
// cachedThemeFilename='cache.theme';
spamsFilename = '0spamers';
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 histories with all contacts');
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 String = ('none', 'alpha', 'event');
type
TRnQAccount = record
ProtoPath: String;
// db : TZipFile;
AccProto: TICQSession;
outbox: Toutbox;
acks: Toutbox;
end;
{$I PubRTTI.inc}
PQuestAns = ^TQuestAns;
TQuestAns = record
q: String;
a: TArray;
end;
TQuestAnsArr = TArray;
{$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;
StartTime, UserStartTime: TDateTime;
// 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;
CmdLinePar: record
StartUser: TUID;
extraini, userPath, mainPath, logpath, useproxy, icqlink: String;
// NoSound : Boolean;
end;
LastMinuteCheck, LastAccountSave, LastEventSubscribe: TDateTime;
InactiveTime: Integer;
NoIncomingCounter: Integer; // if > 0, IE_incoming means people was here before (used in the login process)
FantomWork, ShowUINDelimiter, XStatusInTray,
blinkWithStatus,
StayConnected, Running, CleanDisconnect: Boolean;
ChatXY: TFormDimen;
SearchXY: TFormDimen;
PrefsXY: TFormDimen;
oldForeWindow: Thandle;
groups: Tgroups;
usersPath: string;
lastUser: TUID;
userCharSet: integer;
imAwaySince: Tdatetime;
lastSearchTime: Tdatetime;
uinlists: Tuinlists;
// myStatus,
// visibleList, invisibleList,
IgnoreList, QuietList, NotInList, RecentList, updateViewInfoQ, retrieveQ, reqAvatarsQ{, reqXStatusQ}: TRnQCList;
// timers
SecondsCount, SecondsCount15: Integer;
ReconnectDelayCount: Byte;
Blinking: Boolean;
// 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;
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
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;
MainCSS, ChatCSS: String;
BarPos, FilterPos: Integer;
UIAccentColor: Integer;
UIAccentColorVal: TColor;
// booleans
ShowHintsInCL, ShowHintsInChat, ShowSmartReplies, ShowReactions, AnimateWindows, NewSettingsDesign,
// showClientID,
ConnectOnConnection, ReopenChats, CloseChatOnSend, ClosePageOnSingle, filterBarOnTop, rosterbarOnTop,
ShowMainBorder, NoBorderWithShadow, lockOnStart, closeAuthAfterReply, AutoConsumeEvents,
DsblEvnt4ClsdGrp, EnableIgnoreList, EnableQuietList, InactiveHide, InactiveTrim, optimizeDB, AutoReconnect,
startMinimized, autoSwitchKL, skipSplash, incomingOnAway, enteringProtoPWD, check4readonly,
dontSavePwd, clearPwdOnDSNCT, showStatusOnTabs,
// webaware,
singleDefault, ShowGroups, ShowEmptyGroups, autoCopyHist, bViewTextWrap, indentRoster, collapseGroups, showDisconnectedDlg, ShowTempConnectErrors, 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;
PreviewResolution, PreferredResolution, ChatImageQuality, ScreenshotFormat, 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;
implementation
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;
end.