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.
1574 lines
44 KiB
Plaintext
1574 lines
44 KiB
Plaintext
{
|
|
This file is part of R&Q.
|
|
Under same license
|
|
}
|
|
unit CLBox;
|
|
{$I RnQConfig.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, System.Types, System.StrUtils, System.Variants, System.Rtti,
|
|
Generics.Collections, Vcl.Controls, Vcl.Graphics, Vcl.Forms,
|
|
RDGlobal, ICQCommon, ICQSession, ICQContacts, ICQConsts, Protocols_all, Nodes, roasterLib, groupsLib, aboutDlg,
|
|
SciterLib, Sciter, SciterApi, madStackTrace;
|
|
|
|
{$I PubRTTI.inc}
|
|
|
|
type
|
|
TStatus = record
|
|
code: Byte;
|
|
name, caption, img: String;
|
|
end;
|
|
|
|
TThemeItem = record
|
|
index: Integer;
|
|
title: String;
|
|
current: Boolean;
|
|
end;
|
|
|
|
TSettings = record
|
|
blinkEnabled, blinkWithStatus, onlineOnly, helpExists,
|
|
showGroups, showEmptyGroups, combinedGroups, showHints, indentRoster,
|
|
collapseGroups, avatarInHint, moreStatuses, showBorder, showStatusMsgMenu: Boolean;
|
|
barPos, filterPos, sortBy, blinkTime: Integer;
|
|
end;
|
|
|
|
// TNativeClass = class(TSciterClassInfo)
|
|
// public
|
|
// constructor Create; override;
|
|
// destructor Destroy; override;
|
|
// end;
|
|
|
|
TCLBox = class(TSciterEx)
|
|
private
|
|
NativeMethods: TNativeMethods;
|
|
protected
|
|
public
|
|
procedure Load;
|
|
procedure ApplyTheme;
|
|
procedure InitSettings;
|
|
procedure InitThemeList;
|
|
procedure InitMenus;
|
|
procedure UpdateMenus;
|
|
procedure OpenMainMenu;
|
|
procedure OpenMainMenuDelayed;
|
|
procedure OpenStatusMenu;
|
|
procedure OpenContextMenu;
|
|
// procedure OpenContactMenu(const UID: TUID);
|
|
procedure OpenAddContact;
|
|
function OpenLoginDialog: Boolean;
|
|
function EnterPassword(Title: String; MaxLength: Integer): String;
|
|
procedure ClearCL;
|
|
procedure InsertNode(Node: TNode);
|
|
procedure RemoveNode(Node: TNode);
|
|
procedure EditNode(Node: TNode; Reason: TGroupAction = GA_NONE);
|
|
procedure SetGroupState(Node: TNode; Expand: Boolean);
|
|
procedure UpdateStatusImage(const Pic: TPicName);
|
|
procedure UpdateAdditionalImage;
|
|
procedure UpdateContact(Contact: TICQContact);
|
|
procedure UpdateGroup(Divisor: TDivisor; Group: TGroup); overload;
|
|
procedure UpdateGroup(Group: TGroup); overload;
|
|
procedure UpdateContactCount;
|
|
function GetContacts(Divisor: TDivisor): TArray |
|
function GetCurrentContact: TICQContact;
|
|
function GetFullMaxY: Integer;
|
|
function GetOnlineMaxY: Integer;
|
|
function IsFilterFocused: Boolean;
|
|
function IsMenuFocused: Boolean;
|
|
procedure FocusChanged(Focused: Boolean);
|
|
procedure FocusFilter;
|
|
procedure FocusNode(Node: TNode);
|
|
procedure SetProgress(Progress: Double);
|
|
procedure FinishBuild;
|
|
procedure ApplySystemColor;
|
|
procedure ScriptingCall(ASender: TObject; const Args: TElementOnScriptingCallArgs);
|
|
constructor Create(AOwner: TComponent);
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
//var
|
|
// hisBGColor, myBGColor: TColor;
|
|
// renderInit: Boolean = False;
|
|
|
|
implementation
|
|
|
|
uses
|
|
RDUtils, RQUtil, RDFileUtil, RQThemes, RnQPics, RnQLangs, RnQSysUtils, RnQ_Avatars, RnQGraphics32, RnQStrings, RnQDialogs,
|
|
StatusForm, usersDlg, mainDlg, chatDlg, outboxDlg, RnQdbDlg, RQlog, RnQGlobal, RnQMacros,
|
|
globalLib, iniLib, utilLib, themesLib, langLib, pluginLib, events, history;
|
|
// Math, Clipbrd, RnQSysUtils, RnQLangs, RDFileUtil, RDUtils, RnQBinUtils,
|
|
|
|
//var
|
|
// vKeyPicElm: TRnQThemedElementDtls;
|
|
|
|
//function NativeMethodHandler(vm: HVM; self: tiscript_value; tag: Pointer): tiscript_value; cdecl;
|
|
//var
|
|
// pForm: TForm;
|
|
// pInfo: ISciterMethodInfo;
|
|
//begin
|
|
// pForm := NI.get_instance_data(self);
|
|
// pInfo := ISciterMethodInfo(tag);
|
|
//
|
|
// if pInfo.Name = 'this' then
|
|
// begin
|
|
// // pForm := TForm.Create(Application) is dangerous because of
|
|
// // finalizer call followed by Application destructor call.
|
|
// // The form will be freed twice.
|
|
// pForm := TForm.CreateParented(GetDesktopWindow);
|
|
//
|
|
// pForm.Caption := 'Sciter';
|
|
// pForm.ClientWidth := 400;
|
|
// pForm.ClientHeight := 200;
|
|
// pForm.Position := poScreenCenter;
|
|
// NI.set_instance_data(self, pForm);
|
|
// end
|
|
//
|
|
// else if pInfo.Name = 'Show' then
|
|
// begin
|
|
// if pForm <> nil then
|
|
// begin
|
|
// pForm.Show;
|
|
// pForm.BringToFront();
|
|
// end;
|
|
// end
|
|
//
|
|
// else if pInfo.Name = 'Close' then
|
|
// begin
|
|
// pForm.Close;
|
|
// pForm.Free;
|
|
// NI.set_instance_data(self, nil);
|
|
// end;
|
|
//
|
|
// Result := Self;
|
|
//end;
|
|
//
|
|
//procedure NativeFinalizerHandler(vm: HVM; this: tiscript_value); cdecl;
|
|
//var
|
|
// pForm: TForm;
|
|
//begin
|
|
// pForm := TObject(NI.get_instance_data(this)) as TForm;
|
|
// if pForm <> nil then
|
|
// begin
|
|
// pForm.Free;
|
|
// NI.set_instance_data(this, nil);
|
|
// end;
|
|
//end;
|
|
|
|
//constructor TNativeClass.Create;
|
|
//var
|
|
// pInfo: ISciterMethodInfo;
|
|
//begin
|
|
// inherited;
|
|
// TypeName := 'NativeClass';
|
|
//
|
|
// Self.MethodHandler := NativeMethodHandler;
|
|
// Self.FinalizerHandler := NativeFinalizerHandler;
|
|
//
|
|
// pInfo := TSciterMethodInfo.Create;
|
|
// pInfo.Name := 'this';
|
|
// Self.Methods.Add(pInfo);
|
|
//
|
|
// pInfo := TSciterMethodInfo.Create;
|
|
// pInfo.Name := 'Show';
|
|
// Self.Methods.Add(pInfo);
|
|
//
|
|
// pInfo := TSciterMethodInfo.Create;
|
|
// pInfo.Name := 'Close';
|
|
// Self.Methods.Add(pInfo);
|
|
//end;
|
|
//
|
|
//destructor TNativeClass.Destroy;
|
|
//begin
|
|
// inherited;
|
|
//end;
|
|
|
|
constructor TCLBox.Create(AOwner: TComponent);
|
|
begin
|
|
inherited Create(AOwner);
|
|
SetParentComponent(AOwner);
|
|
|
|
TabStop := True;
|
|
Color := clBtnFace;
|
|
|
|
// NativeClass := TNativeClass.Create;
|
|
// RegisterNativeClass(NativeClass, True);
|
|
NativeMethods := TNativeMethods.Create(Self);
|
|
|
|
OnScriptingCall := ScriptingCall;
|
|
end;
|
|
|
|
destructor TCLBox.Destroy;
|
|
begin
|
|
NativeMethods.Free;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TCLBox.Load;
|
|
begin
|
|
LoadTemplate('template', 'main.htm');
|
|
end;
|
|
|
|
procedure TCLBox.ApplyTheme;
|
|
var
|
|
OfficialSprite, DeletedSprite, LocalSprite, AuthSprite: TSprite;
|
|
begin
|
|
OfficialSprite := MakeSprite(PIC_OFFICIAL);
|
|
DeletedSprite := MakeSprite(PIC_DELETED);
|
|
AuthSprite := MakeSprite(PIC_AUTH_NEED);
|
|
LocalSprite := MakeSprite(PIC_LOCAL);
|
|
Call('applyTheme', [RecordToVar(OfficialSprite), RecordToVar(DeletedSprite), RecordToVar(AuthSprite), RecordToVar(LocalSprite)]);
|
|
end;
|
|
|
|
procedure TCLBox.InitSettings;
|
|
var
|
|
Icons: TParams;
|
|
Settings: TSettings;
|
|
i: Integer;
|
|
begin
|
|
SetLength(Icons, Length(SHOW_ICONS_ORDER));
|
|
for i := 0 to Length(Icons) - 1 do
|
|
begin
|
|
Icons[i] := VarArrayCreate([0, 1], varVariant);
|
|
Icons[i][0] := RecordToVar(RnQCLIcons[SHOW_ICONS_ORDER[i]]);
|
|
Icons[i][1] := TO_SHOW_ICON[SHOW_ICONS_ORDER[i]];
|
|
end;
|
|
|
|
Settings.blinkEnabled := not Account.AccProto.GetStatusDisable.blinking;
|
|
Settings.blinkWithStatus := blinkWithStatus;
|
|
Settings.onlineOnly := showOnlyOnline;
|
|
Settings.showGroups := ShowGroups;
|
|
Settings.showEmptyGroups := ShowEmptyGroups;
|
|
Settings.combinedGroups := OnlOfflInOne;
|
|
Settings.showHints := ShowHintsInCL;
|
|
Settings.indentRoster := indentRoster;
|
|
// Settings.animatedGroups := animatedRoster;
|
|
Settings.collapseGroups := collapseGroups;
|
|
Settings.sortBy := Integer(sortBy);
|
|
Settings.blinkTime := blinkSpeed * 100 + 100;
|
|
Settings.barPos := BarPos;
|
|
Settings.filterPos := FilterPos;
|
|
Settings.helpExists := helpExists;
|
|
Settings.avatarInHint := avatarShowInHint;
|
|
Settings.moreStatuses := showNewXStatuses;
|
|
Settings.showStatusMsgMenu := showXStatusMnu;
|
|
|
|
try
|
|
Call('initSettings', [Icons, RecordToVar(Settings)]);
|
|
except
|
|
on e: ESciterCallException do
|
|
MsgDlg('Error in InitSettings: ' + e.Message, false, mtError);
|
|
end;
|
|
end;
|
|
|
|
procedure TCLBox.InitMenus;
|
|
var
|
|
I: Integer;
|
|
Code: Byte;
|
|
StArr: TStatusArray;
|
|
StatusMenu: TStatusMenu;
|
|
Statuses: array of TStatus;
|
|
StatusesVar: TParams;
|
|
begin
|
|
StArr := Account.AccProto.Statuses;
|
|
StatusMenu := Account.AccProto.GetStatusMenu;
|
|
SetLength(Statuses, Length(StatusMenu));
|
|
SetLength(StatusesVar, Length(StatusMenu));
|
|
|
|
I := 0;
|
|
for Code in StatusMenu do
|
|
begin
|
|
Statuses[I].code := Code;
|
|
Statuses[I].name := StArr[Code].ShortName;
|
|
Statuses[I].img := StArr[Code].ImageName;
|
|
Statuses[I].caption := GetTranslation(StArr[Code].Cptn);
|
|
StatusesVar[I] := RecordToVar(Statuses[I]);
|
|
Inc(I);
|
|
end;
|
|
|
|
Call('initMenus', [StatusesVar]);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateMenus;
|
|
begin
|
|
Call('updateMenus', [RnQmain.Visible]);
|
|
end;
|
|
|
|
procedure TCLBox.OpenMainMenu;
|
|
begin
|
|
Call('openMainMenu', []);
|
|
end;
|
|
|
|
procedure TCLBox.OpenMainMenuDelayed;
|
|
begin
|
|
FireRoot($100);
|
|
end;
|
|
|
|
procedure TCLBox.OpenStatusMenu;
|
|
begin
|
|
Call('openStatusMenu', []);
|
|
end;
|
|
|
|
procedure TCLBox.OpenContextMenu;
|
|
begin
|
|
Call('openContextMenu', []);
|
|
end;
|
|
|
|
//procedure TCLBox.OpenContactMenu(const UID: TUID);
|
|
//begin
|
|
// Call('openContactMenu', [UID]);
|
|
//end;
|
|
|
|
procedure TCLBox.OpenAddContact;
|
|
begin
|
|
Call('openAddContactDialog', []);
|
|
end;
|
|
|
|
function TCLBox.OpenLoginDialog: Boolean;
|
|
begin
|
|
Result := Call('openLoginDialog', []);
|
|
end;
|
|
|
|
function TCLBox.EnterPassword(Title: String; MaxLength: Integer): String;
|
|
begin
|
|
Result := Call('enterPassword', [Title, MaxLength]);
|
|
end;
|
|
|
|
procedure TCLBox.InitThemeList;
|
|
var
|
|
I: Integer;
|
|
Themes: array of TThemeItem;
|
|
ThemesVar: TParams;
|
|
Smiles: array of TThemeItem;
|
|
SmilesVar: TParams;
|
|
Sounds: array of TThemeItem;
|
|
SoundsVar: TParams;
|
|
begin
|
|
theme.RefreshThemelist;
|
|
|
|
SetLength(Themes, Length(theme.themelist2));
|
|
SetLength(ThemesVar, Length(theme.themelist2));
|
|
for I := 0 to Length(theme.themelist2) - 1 do
|
|
begin
|
|
Themes[I].index := I;
|
|
Themes[I].title := GetTranslation(theme.themelist2[I].title);
|
|
Themes[I].current := (LowerCase(theme.themelist2[i].fn) = LowerCase(theme.ThemePath.fn)) and (theme.ThemePath.subfn = theme.themelist2[i].subFile);
|
|
ThemesVar[I] := RecordToVar(Themes[I]);
|
|
end;
|
|
|
|
SetLength(Smiles, Length(theme.smileList));
|
|
SetLength(SmilesVar, Length(theme.smileList));
|
|
if Length(theme.smileList) > 0 then
|
|
for I := 0 to Length(theme.smileList) - 1 do
|
|
begin
|
|
Smiles[I].index := I;
|
|
Smiles[I].title := GetTranslation(theme.smileList[I].title);
|
|
Smiles[I].current := (LowerCase(theme.smileList[i].fn) = LowerCase(RQSmilesPath.fn)) and (RQSmilesPath.subfn = theme.smileList[i].subFile);
|
|
SmilesVar[I] := RecordToVar(Smiles[I]);
|
|
end;
|
|
|
|
SetLength(Sounds, Length(theme.soundList));
|
|
SetLength(SoundsVar, Length(theme.soundList));
|
|
if Length(theme.soundList) > 0 then
|
|
for I := 0 to Length(theme.soundList) - 1 do
|
|
begin
|
|
Sounds[I].index := I;
|
|
Sounds[I].title := GetTranslation(theme.soundList[I].title);
|
|
Sounds[I].current := (LowerCase(theme.soundList[i].fn) = LowerCase(RQSoundsPath.fn)) and (RQSoundsPath.subfn = theme.soundList[i].subFile);
|
|
SoundsVar[I] := RecordToVar(Sounds[I]);
|
|
end;
|
|
|
|
Call('initThemeList', [ThemesVar, SmilesVar, SoundsVar]);
|
|
end;
|
|
|
|
procedure TCLBox.ClearCL;
|
|
begin
|
|
Call('clear', []);
|
|
end;
|
|
|
|
procedure TCLBox.InsertNode(Node: TNode);
|
|
var
|
|
Data: TNodeData;
|
|
begin
|
|
if not Assigned(Node) then
|
|
Exit;
|
|
Data := GetNodeData(Node);
|
|
Call('insertNode', [RecordToVar(Data), Building]);
|
|
end;
|
|
|
|
procedure TCLBox.RemoveNode(Node: TNode);
|
|
var
|
|
Data: TNodeData;
|
|
begin
|
|
if not Assigned(Node) then
|
|
Exit;
|
|
Data := GetNodeData(Node);
|
|
Call('removeNode', [RecordToVar(Data)]);
|
|
end;
|
|
|
|
procedure TCLBox.EditNode(Node: TNode; Reason: TGroupAction = GA_NONE);
|
|
var
|
|
Data: TNodeData;
|
|
begin
|
|
Data := GetNodeData(Node, True);
|
|
Call('editNode', [RecordToVar(Data), Reason]);
|
|
end;
|
|
|
|
procedure TCLBox.SetGroupState(Node: TNode; Expand: Boolean);
|
|
var
|
|
Data: TNodeData;
|
|
begin
|
|
Data := GetNodeData(Node, True);
|
|
Call('setGroupState', [RecordToVar(Data), Expand]);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateStatusImage(const Pic: TPicName);
|
|
begin
|
|
Call('updateStatusImage', [Pic]);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateAdditionalImage;
|
|
var
|
|
XSt, Pic: TPicName;
|
|
begin
|
|
XSt := GetXStsPic(nil, True);
|
|
if Assigned(Account.outbox) and not Account.outbox.empty then
|
|
Pic := PIC_OUTBOX
|
|
else
|
|
Pic := XSt;
|
|
|
|
if Pic = '' then
|
|
begin
|
|
Call('updateAdditionalImage', [XSt, False]);
|
|
Exit;
|
|
end;
|
|
|
|
Call('updateAdditionalImage', [XSt, Pic]);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateContact(Contact: TICQContact);
|
|
begin
|
|
InsertNode(TCE(Contact.data^).Node);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateGroup(Divisor: TDivisor; Group: TGroup);
|
|
begin
|
|
if Divisor in divsWithGroups then
|
|
if Assigned(Group.Node[Divisor]) then
|
|
InsertNode(Group.Node[Divisor]);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateGroup(Group: TGroup);
|
|
var
|
|
Divisor: TDivisor;
|
|
begin
|
|
for Divisor := Low(TDivisor) to High(TDivisor) do
|
|
UpdateGroup(Divisor, Group);
|
|
end;
|
|
|
|
procedure TCLBox.UpdateContactCount;
|
|
begin
|
|
Call('updateContactCount', [contactsPnlStr]);
|
|
end;
|
|
|
|
function TCLBox.GetContacts(Divisor: TDivisor): TArray |
|
var
|
|
List: TParams;
|
|
I: Integer;
|
|
begin
|
|
SetLength(Result, 0);
|
|
List := Call('getContacts', [Integer(Divisor)]);
|
|
for I := VarArrayLowBound(List, 1) to VarArrayHighBound(List, 1) do
|
|
begin
|
|
SetLength(Result, Length(Result) + 1);
|
|
Result[Length(Result) - 1] := Account.AccProto.GetContact(TUID(List[I]))
|
|
end;
|
|
end;
|
|
|
|
function TCLBox.GetCurrentContact: TICQContact;
|
|
var
|
|
Res: Variant;
|
|
begin
|
|
Result := nil;
|
|
Res := Call('getCurrentContact', []);
|
|
if not (Res = '') then
|
|
Result := Account.AccProto.GetContact(String(Res));
|
|
end;
|
|
|
|
function TCLBox.GetFullMaxY: Integer;
|
|
begin
|
|
Result := Call('getMaxY', [false]);
|
|
end;
|
|
|
|
function TCLBox.GetOnlineMaxY: Integer;
|
|
begin
|
|
Result := Call('getMaxY', [true]);
|
|
end;
|
|
|
|
function TCLBox.IsFilterFocused: Boolean;
|
|
begin
|
|
Result := not (Focused = nil) and Focused.Visible and (Focused.GetID = 'clfilter');
|
|
end;
|
|
|
|
function TCLBox.IsMenuFocused: Boolean;
|
|
begin
|
|
Result := not (Focused = nil) and Focused.Visible and (Focused.GetTag = 'menu');
|
|
end;
|
|
|
|
procedure TCLBox.FocusChanged(Focused: Boolean);
|
|
begin
|
|
Call('focusChanged', [Focused]);
|
|
end;
|
|
|
|
procedure TCLBox.FocusFilter;
|
|
begin
|
|
Call('focusFilter', []);
|
|
end;
|
|
|
|
procedure TCLBox.FocusNode(Node: TNode);
|
|
var
|
|
Data: TNodeData;
|
|
begin
|
|
Data := GetNodeData(Node, True);
|
|
Call('focusNode', [RecordToVar(Data)]);
|
|
end;
|
|
|
|
procedure TCLBox.SetProgress(Progress: Double);
|
|
begin
|
|
Call('setProgress', [Progress]);
|
|
end;
|
|
|
|
procedure TCLBox.FinishBuild;
|
|
begin
|
|
Call('finishBuild', []);
|
|
end;
|
|
|
|
procedure TCLBox.ApplySystemColor;
|
|
begin
|
|
if not (AccentColor = clWhite) then
|
|
Call('setSystemColor', [GetRValue(AccentColor), GetGValue(AccentColor), GetBValue(AccentColor)]);
|
|
end;
|
|
|
|
procedure DivisorToTitle(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Divisor: Integer;
|
|
DivStr: String;
|
|
begin
|
|
Divisor := 2;
|
|
API.ValueIntData(argv, Divisor);
|
|
DivStr := GetTranslation(divisor2ShowStr[TDivisor(Divisor)]);
|
|
API.ValueStringDataSet(retval, PWideChar(DivStr), Length(DivStr), 0);
|
|
end;
|
|
|
|
procedure ToggleOnlineOnly(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
ToggleOnlyOnline;
|
|
end;
|
|
|
|
procedure ToggleFilter(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
RnQmain.ToggleFilter;
|
|
end;
|
|
|
|
procedure GroupStateChanged(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Group: TGroup;
|
|
Tmp, GroupID, Divisor: Integer;
|
|
Ex, Expanded: Boolean;
|
|
begin
|
|
if tag = nil then
|
|
Exit;
|
|
|
|
API.ValueIntData(argv, Tmp);
|
|
Expanded := Tmp = 1;
|
|
Inc(argv);
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
Inc(argv);
|
|
Divisor := 2;
|
|
API.ValueIntData(argv, Divisor);
|
|
|
|
Group := groups.Get(GroupID);
|
|
Ex := Group.Expanded[TDivisor(Divisor)];
|
|
if not (Ex = Expanded) then
|
|
begin
|
|
groups.SetExpanded(GroupID, TDivisor(Divisor), Expanded);
|
|
TCLBox(tag).UpdateGroup(TDivisor(Divisor), Group);
|
|
SaveGroupsDelayed := True;
|
|
end;
|
|
end;
|
|
|
|
procedure OpenContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
strLen: Cardinal;
|
|
ev: Thevent;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, strLen);
|
|
clickedContact := Account.AccProto.GetContact(UID);
|
|
|
|
if UID = '' then
|
|
Exit;
|
|
|
|
ev := eventQ.firstEventFor(clickedContact);
|
|
if ev = nil then
|
|
begin
|
|
chatFrm.OpenOn(clickedContact);
|
|
if chatFrm.Visible then
|
|
chatFrm.SetFocus;
|
|
ForceForegroundWindow(chatFrm.Handle);
|
|
end
|
|
else
|
|
begin
|
|
eventQ.remove(ev);
|
|
realizeEvent(ev);
|
|
end;
|
|
end;
|
|
|
|
procedure BarButtonClick(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
id: PWideChar;
|
|
strLen: Cardinal;
|
|
right: Boolean;
|
|
r, x, y: Integer;
|
|
// SL: TStringList;
|
|
// TmpJSON: TJSONValue;
|
|
// ev: Thevent;
|
|
begin
|
|
if (tag = nil) or (argc = 0) then
|
|
Exit;
|
|
|
|
API.ValueStringData(argv, id, strLen);
|
|
r := 0;
|
|
if argc > 1 then
|
|
begin
|
|
Inc(argv);
|
|
API.ValueIntData(argv, r);
|
|
end;
|
|
right := r = 1;
|
|
x := 0;
|
|
if argc > 2 then
|
|
begin
|
|
Inc(argv);
|
|
API.ValueIntData(argv, x);
|
|
end;
|
|
y := 0;
|
|
if argc > 3 then
|
|
begin
|
|
Inc(argv);
|
|
API.ValueIntData(argv, y);
|
|
end;
|
|
|
|
with TCLBox(tag) do
|
|
if id = 'addBtn' then
|
|
begin
|
|
//SL := TStringList.Create;
|
|
//SL.LoadFromFile('C:\SpeedProgs\Inet\Chat\RnQ\Build\Distro\CL.json');
|
|
//TmpJSON := TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(SL.Text), 0);
|
|
//Account.AccProto.ProcessContactList(TJSONArray(TmpJSON));
|
|
//Account.AccProto.Test;
|
|
//ev := Thevent.new(EK_Msg, Account.AccProto.GetContact('230490'), Account.AccProto.GetContact('230490'), Now, 'test+', [], 0, 0, '');
|
|
//chatFrm.ChatBox.AddEvent('230490', ev);
|
|
//ev := Thevent.new(EK_Msg, Account.AccProto.GetContact('230490'), Account.AccProto.GetContact('230490'), Now, 'test-', [], 0, 0, '');
|
|
//chatFrm.ChatBox.AddEvent('230490', ev);
|
|
//UpdateContact(Account.AccProto.GetContact('230490'));
|
|
//roasterLib.Focus(Account.AccProto.GetContact('230490'));
|
|
//roasterLib.Rebuild;
|
|
//Exit;
|
|
if Assigned(Account.outbox) and not Account.outbox.Empty then
|
|
begin
|
|
if not Assigned(outboxFrm) then
|
|
begin
|
|
outboxFrm := ToutboxFrm.Create(Application);
|
|
TranslateWindow(outboxFrm);
|
|
end;
|
|
outboxFrm.open;
|
|
end else
|
|
Call('openStatusDialog', []);
|
|
end;
|
|
end;
|
|
|
|
procedure DragFormStart(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
const
|
|
SC_DragMove = $F012;
|
|
begin
|
|
with RnQmain do
|
|
if Floating then
|
|
begin
|
|
ReleaseCapture;
|
|
Perform(WM_SYSCOMMAND, SC_DragMove, 0);
|
|
end;
|
|
end;
|
|
|
|
procedure GoOnline(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
DoConnect
|
|
end;
|
|
|
|
procedure RenameGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Group: TGroup;
|
|
GroupID: Integer;
|
|
Reason: Integer;
|
|
GroupName: PWideChar;
|
|
StrLen: Cardinal;
|
|
Res: TPair |
|
begin
|
|
if tag = nil then
|
|
begin
|
|
V2S(False, retval);
|
|
Exit;
|
|
end;
|
|
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
Inc(argv);
|
|
GroupName := '';
|
|
API.ValueStringData(argv, GroupName, StrLen);
|
|
Inc(argv);
|
|
Reason := 0;
|
|
API.ValueIntData(argv, Reason);
|
|
|
|
if groups.Name2ID(GroupName) > 0 then
|
|
begin
|
|
V2S(GetTranslation('The name %s already exists.', [GroupName]), retval);
|
|
Exit;
|
|
end;
|
|
|
|
Group := groups.Get(GroupID);
|
|
if not Group.IsLocal and (Group.ID >= 0) and Account.AccProto.IsOnline then
|
|
begin
|
|
Res := groups.RenameLocal(Group.ID, GroupName);
|
|
if not (Res.Key = '') then
|
|
Group.ServerUpdate(TGroupAction(Reason), Res.Key)
|
|
end else if Group.IsLocal then
|
|
groups.RenameLocal(Group.ID, GroupName)
|
|
else
|
|
begin
|
|
V2S(GetTranslation('Group is not local and must be modified while online'), retval);
|
|
Exit;
|
|
end;
|
|
|
|
if Reason = Integer(GA_Add) then
|
|
TCLBox(tag).UpdateGroup(Group);
|
|
|
|
SaveGroupsDelayed := True;
|
|
V2S(True, retval);
|
|
end;
|
|
|
|
procedure RenameContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Contact: TICQContact;
|
|
UID: PWideChar;
|
|
Reason: Integer;
|
|
ContactName: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
if tag = nil then
|
|
begin
|
|
V2S(False, retval);
|
|
Exit;
|
|
end;
|
|
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
Inc(argv);
|
|
ContactName := '';
|
|
API.ValueStringData(argv, ContactName, StrLen);
|
|
Inc(argv);
|
|
Reason := 0;
|
|
API.ValueIntData(argv, Reason);
|
|
|
|
if UID = '' then
|
|
begin
|
|
V2S(False, retval);
|
|
Exit;
|
|
end;
|
|
|
|
Contact := Account.AccProto.GetContact(UID);
|
|
|
|
if not (ContactName = Contact.displayed) then
|
|
Contact.SetDisplay(ContactName);
|
|
|
|
UpdateInPlace(contact);
|
|
dbUpdateDelayed := True;
|
|
UpdateViewInfo(contact);
|
|
TCLBox(tag).UpdateContact(contact);
|
|
|
|
V2S(True, retval);
|
|
end;
|
|
|
|
procedure RemoveGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
GroupID: Integer;
|
|
begin
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
roasterLib.RemoveGroup(GroupID);
|
|
end;
|
|
|
|
procedure DeleteCurrentGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
id: Integer;
|
|
begin
|
|
if (clickedNode = nil) or not (clickedNode.kind = NODE_GROUP) then
|
|
Exit;
|
|
id := clickedNode.groupId;
|
|
|
|
if not groups.Get(id).IsLocal and not Account.AccProto.IsOnline then
|
|
begin
|
|
MsgDlg('Group is not local and must be modified while online', True, mtInformation);
|
|
Exit;
|
|
end;
|
|
|
|
with groups.Get(id) do
|
|
if MessageDlg(GetTranslation('Are you sure you want to delete the group "%s" ?', [name]), mtConfirmation, [mbYes, mbNo]) = mrYes then
|
|
begin
|
|
if Account.AccProto.readList(LT_ROSTER).GetCount(id) > 0 then
|
|
if MessageDlg(GetTranslation('This group (%s) is not empty! All contacts in it will be lost!\nAre you sure you want to continue?', [name]), mtWarning, [mbYes, mbNo]) = mrNo then
|
|
Exit;
|
|
roasterLib.RemoveGroup(id);
|
|
end;
|
|
end;
|
|
|
|
procedure SetClicked(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Kind, Divisor, GroupID: Integer;
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
Kind := 0;
|
|
API.ValueIntData(argv, Kind);
|
|
Inc(argv);
|
|
Divisor := 2;
|
|
API.ValueIntData(argv, Divisor);
|
|
Inc(argv);
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
Inc(argv);
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
|
|
if Kind = NODE_DIV then
|
|
begin
|
|
clickedContact := nil;
|
|
clickedNode := nil;
|
|
end else if Kind = NODE_GROUP then
|
|
begin
|
|
clickedContact := nil;
|
|
clickedNode := GetGroupNode(TDivisor(Divisor), GroupID);
|
|
end else if Kind = NODE_CONTACT then
|
|
begin
|
|
if not (UID = '') then
|
|
begin
|
|
clickedContact := Account.AccProto.GetContact(UID);
|
|
clickedNode := TCE(clickedContact.Data^).Node;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure SetStatus(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Code: Integer;
|
|
begin
|
|
Code := 1;
|
|
API.ValueIntData(argv, Code);
|
|
Account.AccProto.UserSetStatus(Code, Account.AccProto.GetVisibility);
|
|
end;
|
|
|
|
procedure OpenWhitePages(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
Account.AccProto.ShowWP
|
|
end;
|
|
|
|
procedure Lock(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
DoLock
|
|
end;
|
|
|
|
procedure Unlock(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
DoUnlock
|
|
end;
|
|
|
|
procedure ViewInfoAbout(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
Contact: TICQContact;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
Contact := Account.AccProto.GetContact(UID);
|
|
if Assigned(Contact) then
|
|
Contact.ViewInfo;
|
|
end;
|
|
|
|
procedure OpenChatWith(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
chatFrm.OpenOn(Account.AccProto.GetContact(UID));
|
|
end;
|
|
|
|
procedure OpenSearch(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
ShowForm(WF_SEARCH, '', vmShort, nil);
|
|
end;
|
|
|
|
procedure OpenOutbox(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if not Assigned(OutboxFrm) then
|
|
begin
|
|
OutboxFrm := TOutboxFrm.Create(Application);
|
|
TranslateWindow(OutboxFrm);
|
|
end;
|
|
OutboxFrm.Open
|
|
end;
|
|
|
|
procedure OpenContactsDB(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if not Assigned(RnQdbFrm) then
|
|
begin
|
|
RnQdbFrm := TRnQdbFrm.Create(Application);
|
|
ApplyCommonSettings(RnQdbFrm);
|
|
TranslateWindow(RnQdbFrm);
|
|
end;
|
|
ShowForm(RnQdbFrm);
|
|
end;
|
|
|
|
procedure OpenLogWindow(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if not Assigned(LogFrm) then
|
|
begin
|
|
LogFrm := TLogFrm.Create(Application);
|
|
TranslateWindow(LogFrm);
|
|
end;
|
|
ShowForm(logFrm)
|
|
end;
|
|
|
|
procedure ReloadLang(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
ReloadCurrentLang
|
|
end;
|
|
|
|
procedure GetCL(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if OnlFeature(Account.AccProto) then
|
|
TICQSession(Account.AccProto).GetCL;
|
|
end;
|
|
|
|
procedure ReloadTheme(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
ReloadCurrentTheme
|
|
end;
|
|
|
|
procedure ReloadThemeList(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(tag) then
|
|
TCLBox(tag).InitThemeList;
|
|
end;
|
|
|
|
procedure OpenContactThemes(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
S: String;
|
|
begin
|
|
if FantomWork then
|
|
Exit;
|
|
S := AccPath + contactsthemeFilename;
|
|
if not FileExists(S) then
|
|
AppendFile(S, '');
|
|
Exec(S);
|
|
end;
|
|
|
|
procedure SelectTheme(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Index: Integer;
|
|
begin
|
|
Index := 0;
|
|
API.ValueIntData(argv, Index);
|
|
|
|
if (Index >= Low(theme.themelist2)) and (Index <= High(theme.themelist2)) then
|
|
begin
|
|
with theme.themelist2[Index] do
|
|
theme.load(fn, subFile);
|
|
with RQSmilesPath do
|
|
theme.load(fn, subfn, False, tsc_smiles);
|
|
with RQSoundsPath do
|
|
theme.load(fn, subfn, False, tsc_sounds);
|
|
theme.loadThemeScript(userthemeFilename, AccPath);
|
|
applyTheme;
|
|
saveCfgDelayed := TRUE;
|
|
end else
|
|
MsgDlg('Not found this theme''s description. Make Refresh-List.', True, mtError);
|
|
end;
|
|
|
|
procedure SelectSmiles(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Index: Integer;
|
|
begin
|
|
if tag = nil then
|
|
Exit;
|
|
|
|
Index := 0;
|
|
API.ValueIntData(argv, Index);
|
|
|
|
if (Index >= Low(theme.smileList)) and (Index <= High(theme.smileList)) then
|
|
begin
|
|
with theme.smileList[Index] do
|
|
begin
|
|
RQSmilesPath.pathType := pt_path;
|
|
RQSmilesPath.fn := fn;
|
|
RQSmilesPath.subfn := subFile;
|
|
if fn > '' then
|
|
begin
|
|
theme.load(fn, subFile, False, tsc_smiles);
|
|
theme.loadThemeScript(userthemeFilename, AccPath);
|
|
if Assigned(chatFrm) then
|
|
chatFrm.ResetHistory;
|
|
TCLBox(tag).InitThemeList;
|
|
end else
|
|
ReloadCurrentTheme();
|
|
end;
|
|
SaveCfgDelayed := True;
|
|
if Assigned(chatFrm) then
|
|
chatFrm.UpdateChatSettings;
|
|
end else
|
|
MsgDlg('Not found this theme''s description. Make Refresh-List.', True, mtError);
|
|
end;
|
|
|
|
procedure SelectSounds(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Index: Integer;
|
|
begin
|
|
if tag = nil then
|
|
Exit;
|
|
|
|
Index := 0;
|
|
API.ValueIntData(argv, Index);
|
|
|
|
if (Index >= Low(theme.soundList)) and (Index <= High(theme.soundList)) then
|
|
begin
|
|
with theme.soundList[Index] do
|
|
begin
|
|
RQSoundsPath.pathType := pt_path;
|
|
RQSoundsPath.fn := fn;
|
|
RQSoundsPath.subfn := subFile;
|
|
if fn > '' then
|
|
begin
|
|
theme.load(fn, subFile, False, tsc_sounds);
|
|
theme.loadThemeScript(userthemeFilename, AccPath);
|
|
TCLBox(tag).InitThemeList;
|
|
end else
|
|
ReloadCurrentTheme();
|
|
end;
|
|
SaveCfgDelayed := True;
|
|
end else
|
|
MsgDlg('Not found this theme''s description. Make Refresh-List.', True, mtError);
|
|
end;
|
|
|
|
procedure OpenPrefs(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
ShowForm(WF_SHEET)
|
|
end;
|
|
|
|
procedure OpenMyInfo(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
Account.AccProto.GetMyInfo.ViewInfo
|
|
end;
|
|
|
|
procedure OpenMyWebProfile(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
OpenICQURL('https://icq.com/people/' + Account.AccProto.MyAccNum + '/edit/');
|
|
end;
|
|
|
|
procedure CheckForUpdates(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
CheckUpdate.AutoChecking := False;
|
|
Check4Update;
|
|
end;
|
|
|
|
procedure OpenHelpSite(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
utilLib.OpenURL('https://help.rnq.ru')
|
|
end;
|
|
|
|
procedure OpenHelpLocal(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
utilLib.OpenURL(MyPath + docsPath + GetTranslation(helpFilename));
|
|
end;
|
|
|
|
procedure ShowAndActivate(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
with RnQmain do
|
|
begin
|
|
WindowState := wsNormal;
|
|
Show;
|
|
Application.BringToFront;
|
|
ForceForegroundWindow(RnQmain.Handle);
|
|
end;
|
|
end;
|
|
|
|
procedure Toggle(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
RnQmain.ToggleVisible
|
|
end;
|
|
|
|
procedure Quit(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
RnQmain.Close
|
|
end;
|
|
|
|
procedure AddGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
roasterLib.AddGroup(GetTranslation('New group'));
|
|
end;
|
|
|
|
procedure DeleteEmptyGroups(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
id: Integer;
|
|
g: TPair |
|
begin
|
|
for g in groups.GList do
|
|
begin
|
|
id := g.Value.ID;
|
|
if Account.AccProto.readList(LT_ROSTER).GetCount(id) = 0 then
|
|
roasterLib.RemoveGroup(id);
|
|
end;
|
|
end;
|
|
|
|
procedure ToggleShowGroups(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
RnQMacros.ToggleShowGroups
|
|
end;
|
|
|
|
procedure ToggleShowEmptyGroups(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
RnQMacros.ToggleShowEmptyGroups
|
|
end;
|
|
|
|
procedure ToggleStatusSeparation(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
RnQMacros.ToggleStatusSeparation
|
|
end;
|
|
|
|
procedure AddGroupToServer(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
p: TGroup;
|
|
begin
|
|
if (tag = nil) or (clickedNode = nil) or (clickedNode.groupId <= 0) then
|
|
Exit;
|
|
p := groups.Get(clickedNode.groupId);
|
|
if p.IsLocal and Account.AccProto.IsReady then
|
|
if p.ServerUpdate(GA_Add) then
|
|
begin
|
|
groups.SetLocal(p.ID, False);
|
|
TCLBox(tag).UpdateGroup(p);
|
|
end;
|
|
end;
|
|
|
|
procedure RemoveCurrentGroupFromServer(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
p: TGroup;
|
|
begin
|
|
if (tag = nil) or (clickedNode = nil) or (clickedNode.groupId <= 0) then
|
|
Exit;
|
|
p := groups.Get(clickedNode.groupId);
|
|
if not p.IsLocal and Account.AccProto.IsReady then
|
|
if p.ServerUpdate(GA_Remove) then
|
|
begin
|
|
groups.SetLocal(p.ID, True);
|
|
TCLBox(tag).UpdateGroup(p);
|
|
end;
|
|
end;
|
|
|
|
procedure MoveAllFromCurrentToGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
OldID, NewID: Integer;
|
|
c: TICQContact;
|
|
begin
|
|
if clickedNode = nil then
|
|
Exit;
|
|
|
|
with clickedNode do
|
|
if kind = NODE_GROUP then
|
|
OldID := groupId
|
|
else
|
|
Exit;
|
|
|
|
NewID := 0;
|
|
API.ValueIntData(argv, NewID);
|
|
|
|
if NewID = 2000 then
|
|
NewID := 0; // 2000 means no group
|
|
|
|
try
|
|
for c in Account.AccProto.readList(LT_ROSTER) do
|
|
if c.group = OldID then
|
|
SetNewGroupFor(c, newID);
|
|
except end;
|
|
end;
|
|
|
|
procedure OpenChatWithCurrent(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
chatFrm.OpenOn(clickedContact)
|
|
end;
|
|
|
|
procedure SendContactsToCurrent(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
OpenSendContacts(clickedContact)
|
|
end;
|
|
|
|
procedure SendMailToCurrent(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
clickedContact.sendEmailTo
|
|
end;
|
|
|
|
procedure HasEmail(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
i: Integer;
|
|
begin
|
|
V2S(Assigned(clickedContact) and not (clickedContact.Email = '') and not TryStrToInt(TICQContact(clickedContact).Email, i), retval)
|
|
end;
|
|
|
|
procedure GetSpamContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
V2S(spamsFilename, retval)
|
|
end;
|
|
|
|
procedure AddCurrentContactToServer(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) then
|
|
Account.AccProto.AddContact(TICQContact(clickedContact));
|
|
end;
|
|
|
|
procedure IsCurrentInRoster(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
V2S(clickedContact.IsInRoster, retval)
|
|
end;
|
|
|
|
procedure CurrentRequestAuth(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
uid: TUID;
|
|
begin
|
|
if not Assigned(clickedContact) or (Account.AccProto = nil) then
|
|
Exit;
|
|
try
|
|
uid := clickedContact.uid;
|
|
except
|
|
uid := '';
|
|
end;
|
|
if uid = '' then
|
|
Exit;
|
|
if OnlFeature(Account.AccProto) then
|
|
begin
|
|
Account.AccProto.AuthRequest(TICQContact(clickedContact), '');
|
|
plugins.castEv(PE_AUTHREQ_SENT, uid, '');
|
|
end;
|
|
end;
|
|
|
|
procedure CurrentGrantAuth(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) and OnlFeature(Account.AccProto) then
|
|
Account.AccProto.Authorize(TICQContact(clickedContact))
|
|
end;
|
|
|
|
procedure CurrentRequestAvatar(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
reqAvatarsQ.Add(clickedContact)
|
|
end;
|
|
|
|
procedure CurrentViewInfo(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) then
|
|
clickedContact.ViewInfo;
|
|
end;
|
|
|
|
procedure AddCurrentToGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
NewID: Integer;
|
|
begin
|
|
NewID := 0;
|
|
API.ValueIntData(argv, NewID);
|
|
|
|
if Assigned(clickedContact) then
|
|
AddToRoster(clickedContact, NewID, clickedContact.CntIsLocal)
|
|
end;
|
|
|
|
procedure MoveCurrentToGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
NewID: Integer;
|
|
begin
|
|
if not Assigned(clickedContact) then
|
|
Exit;
|
|
|
|
NewID := 0;
|
|
API.ValueIntData(argv, NewID);
|
|
if NewID = 2000 then
|
|
NewID := 0; // 2000 means no group?
|
|
|
|
try
|
|
SetNewGroupFor(clickedContact, NewID);
|
|
except end;
|
|
end;
|
|
|
|
procedure RemoveCurrentContactFromServer(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) and Account.AccProto.IsOnline then
|
|
clickedContact.DelCntFromSrv;
|
|
end;
|
|
|
|
procedure DeleteCurrentContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) then
|
|
if (clickedContact.CntIsLocal or Account.AccProto.IsOnline) then
|
|
begin
|
|
if MessageDlg(GetTranslation('Are you sure you want to delete %s from your list?', [clickedContact.displayed]), mtConfirmation, [mbYes, mbNo]) = mrYes then
|
|
RemoveFromRoster(clickedContact);
|
|
end else
|
|
MsgDlg('Contact is not local and must be modified while online', True, mtInformation);
|
|
end;
|
|
|
|
procedure DeleteCurrentContactHistory(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) then
|
|
DelHistWith(clickedContact.UID2cmp);
|
|
end;
|
|
|
|
procedure DeleteCurrentContactAndHistory(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) then
|
|
if MessageDlg(GetTranslation('Are you sure you want to delete %s from your list with his history?', [clickedContact.displayed]), mtConfirmation, [mbYes, mbNo]) = mrYes then
|
|
RemoveFromRoster(clickedContact, True);
|
|
end;
|
|
|
|
procedure CurrentIsInIgnoreList(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
V2S(ignorelist.exists(clickedContact), retval)
|
|
end;
|
|
|
|
procedure AddCurrentToIgnoreList(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
c: TICQContact;
|
|
begin
|
|
c := clickedContact;
|
|
if c = nil then
|
|
Exit;
|
|
if ignorelist.exists(c) then
|
|
removeFromIgnorelist(c)
|
|
else
|
|
begin
|
|
addToIgnorelist(c);
|
|
if MessageDlg(GetTranslation('Do you want to remove %s from your contact list?', [c.displayed]), mtConfirmation, [mbYes, mbNo]) = mrYes then
|
|
RemoveFromRoster(c);
|
|
end;
|
|
end;
|
|
|
|
procedure GetCurrentUIN2Show(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
begin
|
|
if Assigned(clickedContact) then
|
|
V2S(GetTranslation('%s (copy UIN)', [clickedContact.uin2Show]), retval);
|
|
end;
|
|
|
|
procedure IsGroupLocal(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
GroupID: Integer;
|
|
IsLocal: Boolean;
|
|
begin
|
|
IsLocal := True;
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
if GroupID > 0 then
|
|
IsLocal := groups.Get(GroupID).IsLocal;
|
|
V2S(IsLocal, retval);
|
|
end;
|
|
|
|
procedure GetGroupName(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
GroupID: Integer;
|
|
begin
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
V2S(groups.ID2Name(groupId), retval)
|
|
end;
|
|
|
|
procedure GetContactGroup(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
if not (UID = '') then
|
|
V2S(Account.AccProto.GetContact(UID).Group, retval)
|
|
end;
|
|
|
|
procedure ContactNeedsAuth(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
if not (UID = '') then
|
|
V2S(not Account.AccProto.GetContact(UID).Authorized, retval)
|
|
end;
|
|
|
|
procedure IsContactLocal(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
if not (UID = '') then
|
|
V2S(Account.AccProto.GetContact(UID).CntIsLocal, retval);
|
|
end;
|
|
|
|
procedure AddContact(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
UID: PWideChar;
|
|
StrLen: Cardinal;
|
|
GroupID: Integer;
|
|
begin
|
|
UID := '';
|
|
API.ValueStringData(argv, UID, StrLen);
|
|
Inc(argv);
|
|
GroupID := 0;
|
|
API.ValueIntData(argv, GroupID);
|
|
if not (UID = '') then
|
|
begin
|
|
AddToRoster(Account.AccProto.GetContact(UID), GroupID, (GroupID = 0) or not Account.AccProto.IsOnline);
|
|
SaveListsDelayed := True;
|
|
end;
|
|
end;
|
|
|
|
procedure SavePassword(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
|
|
var
|
|
Password: PWideChar;
|
|
StrLen: Cardinal;
|
|
begin
|
|
Password := '';
|
|
API.ValueStringData(argv, Password, StrLen);
|
|
if Password = '' then
|
|
Exit;
|
|
Account.AccProto.Pwd := Password;
|
|
if not dontSavePwd then
|
|
SaveCfgDelayed := True;
|
|
end;
|
|
|
|
procedure TCLBox.ScriptingCall(ASender: TObject; const Args: TElementOnScriptingCallArgs);
|
|
begin
|
|
if Args.Method = 'getNativeApi' then
|
|
with NativeMethods do
|
|
begin
|
|
// Main
|
|
AddMethod('SetFormIcon', SetFormIcon);
|
|
AddMethod('CheckOnline', CheckOnline);
|
|
AddMethod('GetGroups', GetGroups, True);
|
|
AddMethod('CheckUIN', CheckUIN, True);
|
|
AddMethod('GetMaxPasswordLength', GetMaxPasswordLength);
|
|
AddMethod('GetPwd', GetPwd);
|
|
AddMethod('GetCurrentUserAcc', GetCurrentUserAcc);
|
|
|
|
// CL
|
|
AddMethod('DivisorToTitle', DivisorToTitle);
|
|
AddMethod('ToggleOnlineOnly', ToggleOnlineOnly);
|
|
AddMethod('ToggleFilter', ToggleFilter);
|
|
AddMethod('GroupStateChanged', GroupStateChanged, True);
|
|
AddMethod('OpenContact', OpenContact);
|
|
AddMethod('BarButtonClick', BarButtonClick, True);
|
|
AddMethod('DragFormStart', DragFormStart);
|
|
AddMethod('GoOnline', GoOnline);
|
|
AddMethod('RenameContact', RenameContact, True);
|
|
AddMethod('RenameGroup', RenameGroup, True);
|
|
AddMethod('RemoveGroup', RemoveGroup);
|
|
AddMethod('DeleteCurrentGroup', DeleteCurrentGroup);
|
|
AddMethod('SetClicked', SetClicked);
|
|
AddMethod('SetStatus', SetStatus);
|
|
AddMethod('OpenWhitePages', OpenWhitePages);
|
|
AddMethod('Lock', Lock);
|
|
AddMethod('Unlock', Unlock);
|
|
AddMethod('ViewInfoAbout', ViewInfoAbout);
|
|
AddMethod('OpenChatWith', OpenChatWith);
|
|
AddMethod('OpenSearch', OpenSearch);
|
|
AddMethod('OpenOutbox', OpenOutbox);
|
|
AddMethod('OpenContactsDB', OpenContactsDB);
|
|
AddMethod('OpenLogWindow', OpenLogWindow);
|
|
AddMethod('ReloadLang', ReloadLang);
|
|
AddMethod('GetCL', GetCL);
|
|
AddMethod('ReloadTheme', ReloadTheme);
|
|
AddMethod('ReloadThemeList', ReloadThemeList, True);
|
|
AddMethod('OpenContactThemes', OpenContactThemes);
|
|
AddMethod('SelectTheme', SelectTheme);
|
|
AddMethod('SelectSmiles', SelectSmiles, True);
|
|
AddMethod('SelectSounds', SelectSounds, True);
|
|
AddMethod('OpenPrefs', OpenPrefs);
|
|
AddMethod('OpenMyInfo', OpenMyInfo);
|
|
AddMethod('OpenMyWebProfile', OpenMyWebProfile);
|
|
AddMethod('CheckForUpdates', CheckForUpdates);
|
|
AddMethod('OpenHelpSite', OpenHelpSite);
|
|
AddMethod('OpenHelpLocal', OpenHelpLocal);
|
|
AddMethod('ShowAndActivate', ShowAndActivate);
|
|
AddMethod('Toggle', Toggle);
|
|
AddMethod('Quit', Quit);
|
|
AddMethod('AddGroup', AddGroup);
|
|
AddMethod('DeleteEmptyGroups', DeleteEmptyGroups);
|
|
AddMethod('ToggleShowGroups', ToggleShowGroups);
|
|
AddMethod('ToggleShowEmptyGroups', ToggleShowEmptyGroups);
|
|
AddMethod('ToggleStatusSeparation', ToggleStatusSeparation);
|
|
AddMethod('AddGroupToServer', AddGroupToServer, True);
|
|
AddMethod('RemoveCurrentGroupFromServer', RemoveCurrentGroupFromServer, True);
|
|
AddMethod('MoveAllFromCurrentToGroup', MoveAllFromCurrentToGroup);
|
|
AddMethod('OpenChatWithCurrent', OpenChatWithCurrent);
|
|
AddMethod('SendContactsToCurrent', SendContactsToCurrent);
|
|
AddMethod('SendMailToCurrent', SendMailToCurrent);
|
|
AddMethod('HasEmail', HasEmail);
|
|
AddMethod('GetSpamContact', GetSpamContact);
|
|
AddMethod('AddCurrentContactToServer', AddCurrentContactToServer);
|
|
AddMethod('IsCurrentInRoster', IsCurrentInRoster);
|
|
AddMethod('CurrentRequestAuth', CurrentRequestAuth);
|
|
AddMethod('CurrentGrantAuth', CurrentGrantAuth);
|
|
AddMethod('CurrentRequestAvatar', CurrentRequestAvatar);
|
|
AddMethod('CurrentViewInfo', CurrentViewInfo);
|
|
AddMethod('AddCurrentToGroup', AddCurrentToGroup);
|
|
AddMethod('MoveCurrentToGroup', MoveCurrentToGroup);
|
|
AddMethod('RemoveCurrentContactFromServer', RemoveCurrentContactFromServer);
|
|
AddMethod('DeleteCurrentContact', DeleteCurrentContact);
|
|
AddMethod('DeleteCurrentContactHistory', DeleteCurrentContactHistory);
|
|
AddMethod('DeleteCurrentContactAndHistory', DeleteCurrentContactAndHistory);
|
|
AddMethod('CurrentIsInIgnoreList', CurrentIsInIgnoreList);
|
|
AddMethod('AddCurrentToIgnoreList', AddCurrentToIgnoreList);
|
|
AddMethod('GetCurrentUIN2Show', GetCurrentUIN2Show);
|
|
AddMethod('IsGroupLocal', IsGroupLocal);
|
|
AddMethod('GetGroupName', GetGroupName);
|
|
AddMethod('GetContactGroup', GetContactGroup);
|
|
AddMethod('ContactNeedsAuth', ContactNeedsAuth);
|
|
AddMethod('IsContactLocal', IsContactLocal);
|
|
AddMethod('AddContact', AddContact);
|
|
AddMethod('SavePassword', SavePassword);
|
|
|
|
// Status Message
|
|
AddMethod('GetStatusMessage', GetStatusMessage);
|
|
AddMethod('GetStatusMessages', GetStatusMessages);
|
|
AddMethod('SaveStatusMessage', SaveStatusMessage);
|
|
AddMethod('SetStatusMessage', SetStatusMessage);
|
|
|
|
// About
|
|
AddMethod('GetAboutInfo', GetAboutInfo, True);
|
|
|
|
RegisterMethods(Args.ReturnSciterValue);
|
|
Args.Handled := True;
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
|
|
finalization
|
|
|
|
end.
|