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.
368 lines
11 KiB
Plaintext
368 lines
11 KiB
Plaintext
{
|
|
This file is part of R&Q.
|
|
Under same license
|
|
}
|
|
unit Protocols_all;
|
|
{$I RnQConfig.inc}
|
|
{$I NoRTTI.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, Forms,
|
|
langLib, Protocol_icq, ICQSession, ICQContacts,
|
|
globalLib, roasterlib,
|
|
RnQPrefsLib, RnQPics,
|
|
RDGlobal, outboxLib;
|
|
|
|
type
|
|
TRnQProtoHelper = class helper for TICQSession
|
|
public
|
|
procedure Event(event: Integer);
|
|
procedure UserSetStatus(st: Byte; vi: Byte);
|
|
function enterPWD: Boolean;
|
|
end;
|
|
|
|
TRnQContactHelper = class helper for TICQContact
|
|
public
|
|
function CanMail: Boolean;
|
|
function CanBuzz: Boolean;
|
|
procedure Auth;
|
|
procedure AuthDenied(const msg: string = '');
|
|
procedure DelCntFromSrv;
|
|
|
|
function SendEmailTo: Boolean;
|
|
function GetContactIP: Integer;
|
|
function GetContactIntIP: Integer;
|
|
end;
|
|
|
|
function GetXStsPic(cnt: TICQContact; IsSelf: Boolean = False): TPicName;
|
|
procedure ProtoEvent(Sender: TICQSession; event: Integer);
|
|
|
|
function Status2ImgName(s: byte; inv: Boolean = False): TPicName; inline;
|
|
function Status2ImgNameExt(s: Byte; inv: Boolean = False; extSts: Byte = 0): TPicName; inline;
|
|
|
|
function OutboxAdd(kind: Integer; dest: TICQContact; flags: Integer = 0; const info: string = ''): Toevent; overload;
|
|
function OutboxAdd(kind: Integer; dest: TICQContact; flags: Integer; cl: TRnQCList): Toevent; overload;
|
|
|
|
procedure GetTrayIconTip(var vPic: TPicName; var vTip: String);
|
|
|
|
var
|
|
AntiSpamMsgs: array [0 .. 6] of String = (
|
|
// (
|
|
('Your message has been blocked for antispam reason.'),
|
|
('You entered invalid code. Try again.'),
|
|
('Confirmation accepted. Your message recieved. Thank you.'),
|
|
('You failed antispam verification. You have no attemts. Your UIN (%uin%) is ignored.'),
|
|
('Please, type digital CODE which you can see below (3 digits).'),
|
|
('You have attempts: %attempt%.'), // %code%
|
|
('Please, type answer on question which you can see below.')
|
|
{ )
|
|
(
|
|
('Âàøå ñîîáùåíèå çàáëîêèðîâàíî àíòèñïàì ïëàãèíîì.'),
|
|
('Âû ââåëè íå ïðàâèëüíûé êîä. Ïîïðîáóéòå åùå ðàç.'),
|
|
('Êîä ïðèíÿò. Âàøå ñîîáùåíèå ïîëó÷åíî. Ñïàñèáî.'),
|
|
('Âû íå ïðîøëè àíòèñïàì ïðîâåðêó. Ó âàñ íå îñòàëîñü ïîïûòîê. Âàø UIN (%uin%) èãíîðèðóåòñÿ.'),
|
|
('Ïîæàëóéñòà, ââåäèòå öèôðîâîé ÊÎÄ êîòîðûé âû âèäèòå íèæå (3 öèôðû). '),
|
|
('Îñòàëîñü ïîïûòîê: %attempt%.'#13#10'%code%')
|
|
) }
|
|
);
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, StrUtils, SciterLib,
|
|
RQUtil, RnQDialogs, RnQLangs, RnQStrings,
|
|
RDUtils, RnQSysUtils, RnQGlobal,
|
|
ICQCommon, ICQConsts,
|
|
pluginutil, pluginLib, history,
|
|
utilLib, themesLib, RQThemes,
|
|
MainDlg, events, outboxDlg;
|
|
|
|
procedure TRnQProtoHelper.Event(event: Integer);
|
|
var
|
|
ICQSess: TICQSession;
|
|
begin
|
|
ICQSess := TICQSession(Self);
|
|
ProcessICQEvents(ICQSess, TICQEvent(event));
|
|
end;
|
|
|
|
procedure ProtoEvent(Sender: TICQSession; event: Integer);
|
|
begin
|
|
Sender.Event(event);
|
|
end;
|
|
|
|
function GetXStsPic(cnt: TICQContact; IsSelf: Boolean = False): TPicName;
|
|
begin
|
|
Result := '';
|
|
if IsSelf then
|
|
begin
|
|
if Assigned(Account.AccProto) then
|
|
begin
|
|
if Account.AccProto.CurXStatus > 0 then
|
|
Result := XStatusArray[Account.AccProto.CurXStatus].PicName;
|
|
end;
|
|
end else
|
|
begin
|
|
if Assigned(cnt) then
|
|
if cnt is TICQcontact then
|
|
Result := XStatusArray[TICQContact(cnt).xStatus].PicName
|
|
end;
|
|
end;
|
|
|
|
procedure TRnQProtoHelper.UserSetStatus(st: Byte; vi: Byte);
|
|
begin
|
|
Account.AccProto.SetStatusAndVis(st, vi);
|
|
LastStatusUserSet := st;
|
|
end; // UserSetStatus
|
|
|
|
function TRnQProtoHelper.enterPWD: Boolean;
|
|
begin
|
|
Result := False;
|
|
if enteringProtoPWD then
|
|
Exit;
|
|
|
|
enteringProtoPWD := True;
|
|
Result := UI.CL.OpenLoginDialog;
|
|
enteringProtoPWD := False;
|
|
Exit;
|
|
|
|
// try
|
|
// s := Self.pwd;
|
|
// sUIN := Self._GetProtoName + '#'+ Self.MyAccNum;
|
|
// res := enterPwdDlg(s, getTranslation('Login password') + ' (' + sUIN + ')', Self._MaxPWDLen);
|
|
//
|
|
// if (Self is TICQSession) and (Length(s) > maxPwdLength)
|
|
// or (Length(s) > Self._MaxPWDLen) then
|
|
// begin
|
|
// msgDlg('Password too long', True, mtError);
|
|
// exit;
|
|
// end;
|
|
// if Self is TICQSession then
|
|
// begin
|
|
// myInf := Self.getMyInfo;
|
|
// if Assigned(myInf) then
|
|
// if not tICQcontact(myInf).isAIM then
|
|
// if Length(s) > 8 then
|
|
// begin
|
|
// msgDlg('Please enter only first 8 symbols of your password', True, mtInformation);
|
|
// // exit;
|
|
// end;
|
|
// end;
|
|
// finally
|
|
// enteringProtoPWD := False;
|
|
// end;
|
|
//
|
|
// if not res or (s='') then exit;
|
|
//{ if thisICQ.ProtoElem is TICQSession then
|
|
// if LoginMD5 and saveMD5Pwd then
|
|
// s := MD5Pass(s);}
|
|
// Self.pwd := s;
|
|
//// saveCFG;
|
|
// if not dontSavePwd then
|
|
// saveCfgDelayed := True;
|
|
// result := TRUE;
|
|
end;
|
|
|
|
/////////////////////////////////////////////
|
|
// TRnQContactHelper
|
|
/////////////////////////////////////////////
|
|
|
|
function TRnQContactHelper.CanMail: Boolean;
|
|
begin
|
|
Result := Assigned(Self) and ((Self is TICQcontact) and (TICQcontact(Self).Email > ''));
|
|
end;
|
|
|
|
function TRnQContactHelper.CanBuzz: Boolean;
|
|
begin
|
|
if Assigned(Self) and (Self is TICQContact) then
|
|
Result := CAPS_big_Buzz in TICQContact(Self).capabilitiesBig
|
|
else
|
|
Result := False;
|
|
end;
|
|
|
|
procedure TRnQContactHelper.Auth;
|
|
var
|
|
ev: THevent;
|
|
begin
|
|
plugins.castEv(PE_AUTH_SENT, Self.uid);
|
|
Account.AccProto.Authorize(TICQContact(Self));
|
|
ev := THevent.new(EK_auth, Self, Account.AccProto.GetMyInfo, now, '', [], 0);
|
|
ev.outgoing := True;
|
|
if logpref.writehistory and (BE_save in behaviour[ev.kind].trig) then
|
|
WriteToHistory(ev);
|
|
UI.Chat.AddEvent_OpenChat(Self, ev);
|
|
end;
|
|
|
|
procedure TRnQContactHelper.AuthDenied(const msg: string = '');
|
|
var
|
|
ev: THevent;
|
|
begin
|
|
plugins.castEv(PE_AUTHDENIED_SENT, Self.uid, msg);
|
|
Account.AccProto.Authorize(TICQContact(Self), False);
|
|
ev := THevent.new(EK_authDenied, Self, Account.AccProto.GetMyInfo, now, msg, [], 0);
|
|
ev.outgoing := True;
|
|
if logpref.writehistory and (BE_save in behaviour[ev.kind].trig) then
|
|
WriteToHistory(ev);
|
|
UI.Chat.AddEvent_OpenChat(Self, ev);
|
|
end;
|
|
|
|
procedure TRnQContactHelper.DelCntFromSrv;
|
|
begin
|
|
Account.AccProto.RemoveContactFromServer(TICQCOntact(Self));
|
|
end;
|
|
|
|
function TRnQContactHelper.SendEmailTo: Boolean;
|
|
var
|
|
ml: String;
|
|
begin
|
|
if Self = nil then
|
|
Exit(False)
|
|
else if Self is TICQContact then
|
|
ml := TICQContact(Self).email
|
|
else
|
|
ml := '';
|
|
Result := not (ml = '');
|
|
if Result then
|
|
exec('mailto: ' + ml);
|
|
end; // SendEmailTo
|
|
|
|
function TRnQContactHelper.GetContactIP: Integer;
|
|
begin
|
|
if Self is TICQContact then
|
|
Result := 0
|
|
else
|
|
Result := 0;
|
|
end;
|
|
|
|
function TRnQContactHelper.GetContactIntIP: Integer;
|
|
begin
|
|
if Self is TICQContact then
|
|
Result := 0
|
|
else
|
|
Result := 0;
|
|
end;
|
|
|
|
function Status2ImgName(s: Byte; inv: Boolean = False): TPicName;
|
|
begin
|
|
Result := Protocol_ICQ.Status2ImgName(s, inv);
|
|
end;
|
|
|
|
function status2imgNameExt(s: Byte; inv: Boolean = False; extSts: Byte = 0): TPicName;
|
|
begin
|
|
Result := Protocol_ICQ.Status2ImgNameExt(s, inv, extSts);
|
|
end;
|
|
|
|
function OutboxAdd(kind: Integer; dest: TICQContact; flags: Integer = 0; const info: string = ''): Toevent;
|
|
begin
|
|
if Assigned(dest) then
|
|
begin
|
|
Result := Account.outbox.add(kind, dest, flags, info);
|
|
UI.UpdateOutbox;
|
|
ActionManager.Execute(AK_PROCESSOUTBOX);
|
|
end else
|
|
Result := nil;
|
|
end;
|
|
|
|
function OutboxAdd(kind: Integer; dest: TICQContact; flags: Integer; cl: TRnQCList): Toevent;
|
|
begin
|
|
if Assigned(dest) then
|
|
begin
|
|
Result := Account.outbox.add(kind, dest, flags, cl);
|
|
UI.UpdateOutbox;
|
|
ActionManager.Execute(AK_PROCESSOUTBOX);
|
|
end else
|
|
Result := nil;
|
|
end;
|
|
|
|
procedure GetTrayIconTip(var vPic: TPicName; var vTip: String);
|
|
var
|
|
e: THevent;
|
|
// nIco : String;
|
|
// IcoDtl : TRnQThemedElementDtls;
|
|
// IcoPicName : TPicName;
|
|
// s:string;
|
|
MyInf: TICQContact;
|
|
begin
|
|
vPic := PIC_CLIENT_LOGO;
|
|
vTip := Application.Title;
|
|
if BossMode.isBossKeyOn then
|
|
Exit
|
|
else if (eventQ = nil) or eventQ.Empty or (blinkWithStatus and not (Blinking or Account.AccProto.getStatusDisable.blinking)) then
|
|
begin
|
|
if not Assigned(Account.AccProto) then
|
|
// IcoDtl.picName := status2imgName(byte(SC_UNK), false)
|
|
vPic := Status2ImgName(byte(SC_UNK), False)
|
|
else if Account.AccProto.IsOnline then
|
|
begin
|
|
// nIco := status2imgNameExt(status, invisibleModeBool, ICQ.curXStatus);
|
|
// s := statusNameExt2(myStatus, TICQSession(MainProto.ProtoElem).curXStatus);
|
|
// IcoDtl.picName := status2imgNameExt(myStatus, invisibleModeBool, TICQSession(MainProto.ProtoElem).curXStatus);
|
|
vTip := Account.AccProto.GetStatusName(True);
|
|
// IcoDtl.picName := MainProto.getStatusImg;
|
|
vPic := Account.AccProto.GetStatusImg(True);
|
|
end else if Account.AccProto.IsConnecting then
|
|
begin
|
|
vTip := GetTranslation('Connecting');
|
|
// nIco := PIC_CONNECTING;
|
|
// IcoDtl.ThemeToken := -1;
|
|
if Account.AccProto.progLogon > 0 then
|
|
begin
|
|
// nIco := PIC_CONNECTING + IntToStr(Trunc(progLogon * 8));
|
|
// IcoDtl.picName := PIC_CONNECTING + IntToStrA(Trunc(progLogon * 8));
|
|
vPic := PIC_CONNECTING + IntToStr(Trunc(Account.AccProto.progLogon * 8));
|
|
// with theme.GetPicSize(IcoDtl) do
|
|
with theme.GetPicSize(RQteTrayNotify, vPic) do
|
|
if not ((cx > 0) and (cy > 0)) then
|
|
begin
|
|
// nIco := PIC_CONNECTING;
|
|
// IcoDtl.picName := PIC_CONNECTING;
|
|
vPic := PIC_CONNECTING;
|
|
end;
|
|
end else
|
|
// IcoDtl.picName := PIC_CONNECTING;
|
|
vPic := PIC_CONNECTING;
|
|
if Account.AccProto.IsInvisible then
|
|
// nIco := INVIS_PREFIX + nIco;
|
|
// IcoDtl.picName := INVIS_PREFIX + IcoDtl.picName;
|
|
vPic := INVIS_PREFIX + vPic;
|
|
// IcoDtl.ThemeToken := -1;
|
|
end
|
|
else
|
|
begin
|
|
// s:=statusNameExt2(byte(SC_OFFLINE));
|
|
vTip := GetTranslation(Account.AccProto.Statuses[Byte(SC_OFFLINE)].Cptn);
|
|
// nIco := status2imgNameExt(SC_OFFLINE, invisibleModeBool);
|
|
// IcoDtl.picName := status2imgNameExt(byte(SC_OFFLINE), invisibleModeBool);
|
|
// IcoDtl.picName := status2imgName(byte(SC_OFFLINE), MainProto.IsInvisible);
|
|
vPic := Status2imgName(Byte(SC_OFFLINE), Account.AccProto.IsInvisible);
|
|
end;
|
|
MyInf := Account.AccProto.getMyInfo;
|
|
if Assigned(MyInf) then
|
|
// if assigned(Account.AccProto.myinfo) then
|
|
vTip := GetTranslation('%s [%s]', [vTip, MyInf.Displayed + ' / ' + MyInf.UIN2Show])
|
|
else
|
|
vTip := 'R&&&Q';
|
|
end
|
|
else
|
|
begin
|
|
e := eventQ.Top;
|
|
if Assigned(e) then
|
|
begin
|
|
if Blinking or Account.AccProto.getStatusDisable.blinking then
|
|
// nIco:=e.pic
|
|
// IcoDtl.picName := e.pic
|
|
vPic := e.pic
|
|
else
|
|
vPic := PIC_EMPTY;
|
|
if e.who = nil then
|
|
vTip := GetTranslation(Str_Error)
|
|
else
|
|
// s:=gettr('tray '+event2str[e.kind],[e.who.displayed]);
|
|
vTip := GetTranslation(TrayEvent2Str[e.kind], [e.who.Displayed]);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end.
|