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.
209 lines
5.1 KiB
Plaintext
209 lines
5.1 KiB
Plaintext
{
|
|
This file is part of R&Q.
|
|
Under same license
|
|
}
|
|
unit ICQCommon;
|
|
{$I RnQConfig.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, System.SysUtils, System.JSON, Generics.Collections, RDGlobal, RnQPics;
|
|
|
|
{$I PubRTTI.inc}
|
|
|
|
type
|
|
TOpenedSession = record
|
|
hash: String;
|
|
client: String;
|
|
current: Boolean;
|
|
ip: String;
|
|
location: String;
|
|
os: String;
|
|
startedTime: String;
|
|
end;
|
|
|
|
{$I NoRTTI.inc}
|
|
|
|
type
|
|
{$IFDEF UID_IS_UNICODE}
|
|
TUID = String;
|
|
TUID_Char = Char;
|
|
{$ELSE ansi}
|
|
TUID = AnsiString;
|
|
TUID_Char = AnsiChar;
|
|
{$ENDIF UID_IS_UNICODE}
|
|
TUIDS = array of TUID;
|
|
|
|
TMsgID = UInt64;
|
|
TSrvHist = record
|
|
LastMsgId, LastRead: TMsgID;
|
|
PatchVersion: String;
|
|
end;
|
|
|
|
TPatch = record
|
|
PatchType, PatchedText: String;
|
|
end;
|
|
|
|
PReactions = ^TReactions;
|
|
TReactions = class
|
|
private
|
|
pMsgID: TMsgID;
|
|
pChatID: String;
|
|
pNotifyMsgID: TMsgID;
|
|
pData: TJSONArray;
|
|
pMy: String;
|
|
public
|
|
constructor Create(MsgID: TMsgID; const ChatID: String; NotifyMsgID: TMsgID; Data: TJSONArray; const MyReaction: String);
|
|
destructor Destroy; override;
|
|
|
|
property MsgID: TMsgID read pMsgID;
|
|
property NotifyMsgID: TMsgID read pNotifyMsgID;
|
|
property ChatID: String read pChatID;
|
|
property Data: TJSONArray read pData;
|
|
property My: String read pMy write pMy;
|
|
end;
|
|
|
|
PStatusProp = ^TStatusProp;
|
|
TStatusProp = record
|
|
Cptn: String;
|
|
ShortName: TPicName;
|
|
ImageName: TPicName;
|
|
idx: Byte;
|
|
end;
|
|
|
|
TStatusArray = array of TStatusProp;
|
|
TStatusMenu = array of Byte;
|
|
|
|
TOnStatusDisable = packed record
|
|
Tips,
|
|
Blinking,
|
|
Sounds,
|
|
OpenChat: Boolean;
|
|
end;
|
|
|
|
PXStatStr = ^TXStatStr;
|
|
TXStatStr = record
|
|
Cap, Desc: String;
|
|
end;
|
|
|
|
TWhatLog = (WL_connected, WL_disconnected,
|
|
WL_serverGot, WL_serverSent,
|
|
WL_heSent, WL_meSent, WL_connecting,
|
|
WL_sent_text, WL_rcvd_text{$IFDEF DEBUG_PACKETS}, WL_unknown{$ENDIF DEBUG_PACKETS});
|
|
const
|
|
// Flags for messages
|
|
IF_multiple = 1 shl 0; // multiple recipients
|
|
IF_offline = 1 shl 1; // sent while you were offline
|
|
IF_urgent = 1 shl 2; // send msg urgent
|
|
IF_noblink = 1 shl 3; // send to contact list
|
|
IF_sticker = 1 shl 4; // message is a sticker
|
|
|
|
IF_no_matter = 1 shl 10; // If set, don't play sound
|
|
|
|
// Avatar type
|
|
IS_AVATAR = 0;
|
|
IS_PHOTO = 1;
|
|
IS_NONE = 2;
|
|
|
|
const
|
|
LogPics: array[TwhatLog] of TPicName = (PIC_CONNECTING, PIC_OUTGOING,
|
|
PIC_LEFT, PIC_RIGHT,
|
|
PIC_RIGHT, PIC_LEFT, PIC_CONNECTING,
|
|
PIC_LEFT, PIC_RIGHT{$IFDEF DEBUG_PACKETS}, PIC_HELP{$ENDIF DEBUG_PACKETS});
|
|
|
|
var
|
|
GMToffset:TdateTime; // add it to a GMT time, subtract it from your local time
|
|
GMToffset0:TdateTime; // For OfflineMsg-s & ViewInfo
|
|
|
|
MsgsReactions: TObjectDictionary |
|
function GetMyReactionIndex(MsgID: TMsgID): Integer;
|
|
|
|
procedure LogProtoPacket(What: TWhatLog; const Method, Head: String; const Data: String = '');
|
|
procedure FlushLogPktFile;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.StrUtils,
|
|
{$IFDEF UNICODE}
|
|
System.AnsiStrings,
|
|
{$ENDIF UNICODE}
|
|
RQLog, RDFileUtil, RQUtil, RnQGlobal, ICQConsts,
|
|
globalLib, utilLib;
|
|
|
|
var
|
|
LogPktFileData: String;
|
|
TZinfo: TTimeZoneInformation;
|
|
|
|
procedure LogProtoPacket(What: TWhatLog; const Method, Head: String; const Data: String = '');
|
|
//var
|
|
// NeedHash: Boolean;
|
|
begin
|
|
// NeedHash := not (What in [WL_sent_text, WL_rcvd_text, WL_serverGot, WL_serverSent]);
|
|
|
|
if LogPref.pkts.onWindow then
|
|
LogPacket(Method, Head, Data, LogPics[What]);
|
|
|
|
if LogPref.pkts.onFile then
|
|
begin
|
|
LogPktFileData := LogPktFileData + LogTimestamp + '> ' + Head + CRLF + Data + CRLF;
|
|
ActionManager.Execute(AK_FLUSHPACKETS, 1000);
|
|
end;
|
|
end;
|
|
|
|
procedure FlushLogPktFile;
|
|
begin
|
|
if Length(LogPktFileData) > 0 then
|
|
if AppendFile(LogPath + RequestsLogFilename, LogPktFileData) or (Length(LogPktFileData) > MByte) then
|
|
LogPktFileData := '';
|
|
end;
|
|
|
|
constructor TReactions.Create(MsgID: TMsgID; const ChatID: String; NotifyMsgID: TMsgID; Data: TJSONArray; const MyReaction: String);
|
|
begin
|
|
inherited Create;
|
|
pMsgID := MsgID;
|
|
pChatID := ChatID;
|
|
pNotifyMsgID := NotifyMsgID;
|
|
pData := Data;
|
|
pMy := MyReaction;
|
|
end;
|
|
|
|
destructor TReactions.Destroy;
|
|
begin
|
|
FreeAndNil(pData);
|
|
inherited;
|
|
end;
|
|
|
|
function GetMyReactionIndex(MsgID: TMsgID): Integer;
|
|
var
|
|
Reaction: TReactions;
|
|
begin
|
|
Result := -1;
|
|
for Reaction in MsgsReactions.Values do
|
|
if Reaction.MsgID = MsgID then
|
|
begin
|
|
Result := IndexText(Reaction.My, ReactionOptions);
|
|
Break;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
|
|
GetTimeZoneInformation(TZinfo);
|
|
case GetTimeZoneInformation(TZInfo) of
|
|
TIME_ZONE_ID_STANDARD: GMToffset := TZInfo.StandardBias;
|
|
TIME_ZONE_ID_DAYLIGHT: GMToffset := TZInfo.DaylightBias;
|
|
else GMToffset := 0;
|
|
end;
|
|
GMToffset:=-(TZinfo.bias+GMToffset)/(24*60);
|
|
GMToffset0 :=-(TZinfo.bias)/(24*60);
|
|
|
|
MsgsReactions := TObjectDictionary |
|
|
|
finalization
|
|
|
|
MsgsReactions.Free;
|
|
|
|
end.
|