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.
168 lines
4.7 KiB
Plaintext
168 lines
4.7 KiB
Plaintext
{
|
|
This file is part of R&Q.
|
|
Under same license
|
|
}
|
|
unit outboxDlg;
|
|
{$I RnQConfig.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, System.SysUtils, System.StrUtils, System.Classes,
|
|
SciterJS, SciterJSAPI, SciterLib, ICQCommon, ICQContacts, outboxLib;
|
|
|
|
{$I PubRTTI.inc}
|
|
|
|
type
|
|
TOutboxEvent = record
|
|
UID: TUID;
|
|
index, kind: Integer;
|
|
name, pic, text, info: String;
|
|
end;
|
|
|
|
{$I NoRTTI.inc}
|
|
|
|
TOutboxMethods = class(TNativeMethods)
|
|
class procedure RegisterMethods(var ReturnValue: TSciterValue); override;
|
|
class procedure GetOutboxMessages(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
class procedure GetOutboxProcess(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
class procedure SetOutboxProcess(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
class procedure UpdateOutboxText(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
class procedure DeleteOutboxEvent(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
class procedure SendOutboxEvent(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
RnQLangs, RnQStrings, RnQPics,
|
|
globalLib, utilLib;
|
|
|
|
class procedure TOutboxMethods.RegisterMethods(var ReturnValue: TSciterValue);
|
|
begin
|
|
AddMethod('GetOutboxMessages', GetOutboxMessages);
|
|
AddMethod('GetOutboxProcess', GetOutboxProcess);
|
|
AddMethod('SetOutboxProcess', SetOutboxProcess);
|
|
AddMethod('UpdateOutboxText', UpdateOutboxText);
|
|
AddMethod('DeleteOutboxEvent', DeleteOutboxEvent);
|
|
AddMethod('SendOutboxEvent', SendOutboxEvent);
|
|
inherited;
|
|
end;
|
|
|
|
class procedure TOutboxMethods.GetOutboxMessages(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
I: Integer;
|
|
Info: String;
|
|
Outbox: array of TOutboxEvent;
|
|
OutboxVar: TParams;
|
|
OE: TOEvent;
|
|
begin
|
|
SetLength(Outbox, Account.outbox.Count);
|
|
SetLength(OutboxVar, Account.outbox.Count);
|
|
for I := 0 to Account.outbox.Count - 1 do
|
|
begin
|
|
OE := TOEvent(Account.outbox.List[I]);
|
|
Outbox[I].index := I;
|
|
Outbox[I].kind := OE.kind;
|
|
Outbox[I].uid := OE.whom.UID;
|
|
Outbox[I].text := OE.info;
|
|
if Assigned(OE.whom) then
|
|
Outbox[I].name := OE.whom.displayed
|
|
else
|
|
Outbox[I].name := Str_unk;
|
|
|
|
case oe.kind of
|
|
OE_msg:
|
|
Outbox[I].pic := PIC_MSG;
|
|
OE_contacts:
|
|
Outbox[I].pic := PIC_CONTACTS;
|
|
OE_addedYou:
|
|
Outbox[I].pic := PIC_ADD_CONTACT;
|
|
OE_auth:
|
|
Outbox[I].pic := PIC_AUTH_REQ;
|
|
OE_authDenied:
|
|
Outbox[I].pic := PIC_MSG_BAD;
|
|
end;
|
|
|
|
case OE.kind of
|
|
OE_msg, OE_contacts, OE_addedYou, OE_auth, OE_authDenied:
|
|
Info := GetTranslation(OEvent2ShowStr[OE.kind]);
|
|
else
|
|
Info := '';
|
|
end;
|
|
|
|
Outbox[I].info := getTranslation('%0:s%1:s for %2:s\nCreated: %3:s\nLast modified: %4:s',
|
|
[IfThen(OE.flags and IF_multiple > 0, GetTranslation('(multi-send)') + ' '), Info, Outbox[I].name, DateTimeToStr(OE.wrote),
|
|
IfThen((OE.lastmodify > 0) and not (OE.lastmodify = OE.wrote), DateTimeToStr(OE.lastmodify), '-')]);
|
|
|
|
OutboxVar[I] := UI.RecordToVar(Outbox[I]);
|
|
end;
|
|
V2S(OutboxVar, retval);
|
|
end;
|
|
|
|
class procedure TOutboxMethods.GetOutboxProcess(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
V2S(outboxprocessChk, retval);
|
|
end;
|
|
|
|
class procedure TOutboxMethods.SetOutboxProcess(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Process: Integer;
|
|
begin
|
|
API.ValueIntData(argv, Process);
|
|
outboxprocessChk := Process = 1;
|
|
ActionManager.Execute(AK_PROCESSOUTBOX);
|
|
end;
|
|
|
|
class procedure TOutboxMethods.UpdateOutboxText(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Index: Integer;
|
|
Text: String;
|
|
begin
|
|
Index := -1;
|
|
API.ValueIntData(argv, Index);
|
|
if Index < 0 then
|
|
Exit;
|
|
|
|
Inc(argv);
|
|
Text := SciterVarToString(argv);
|
|
|
|
with Account.outbox.GetAt(Index) do
|
|
begin
|
|
info := Text;
|
|
lastmodify := Now;
|
|
end;
|
|
end;
|
|
|
|
class procedure TOutboxMethods.DeleteOutboxEvent(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Index: Integer;
|
|
begin
|
|
Index := -1;
|
|
API.ValueIntData(argv, Index);
|
|
if Index >= 0 then
|
|
begin
|
|
Account.outbox.Delete(Index);
|
|
UI.CL.UpdateAdditionalImage;
|
|
if Assigned(UI.Chat) then
|
|
UI.Chat.UpdateStatusBar;
|
|
ActionManager.Execute(AK_SAVEOUTBOX, SaveDelay);
|
|
end;
|
|
end;
|
|
|
|
class procedure TOutboxMethods.SendOutboxEvent(argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Index: Integer;
|
|
begin
|
|
Index := -1;
|
|
API.ValueIntData(argv, Index);
|
|
if Index = 0 then
|
|
Exit;
|
|
|
|
processOevent(Account.outbox.GetAt(Index));
|
|
Account.outbox.Delete(Index);
|
|
UI.UpdateOutbox;
|
|
end;
|
|
|
|
end.
|