Skip to content

Commit

Permalink
Merge pull request #3 from daviladanielc/main
Browse files Browse the repository at this point in the history
Nova função
  • Loading branch information
marcelo386 authored May 26, 2022
2 parents 1550738 + 361d3af commit bf7efe1
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Demo/u_principal.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,7 @@ procedure TfrmPrincipal.SpeedButton3Click(Sender: TObject);
if not TWPPConnect1.auth then
exit;

TWPPConnect1.Logtout;
TWPPConnect1.Logout;
TWPPConnect1.Disconnect;
end;

Expand Down
3 changes: 3 additions & 0 deletions Source/Model/uTWPPConnect.Constant.pas
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ interface
//MARCELO 02/05/2022
FrmConsole_JS_VAR_SendContact = 'WPP.chat.sendVCardContactMessage("<#MSG_PHONE_DEST#>", "<#MSG_PHONE#>", {} )';

//DANIEL 25/05/2022
FrmConsole_JS_VAR_BlockContact = 'WPP.blocklist.blockContact("<#CTT_NAME#>");';
FrmConsole_JS_VAR_unBlockContact = 'WPP.blocklist.unblockContact("<#CTT_NAME#>");';
//Marcelo 18/05/2022
FrmConsole_JS_VAR_sendRawMessage = 'WPP.chat.sendRawMessage("<#MSG_PHONE#>","<#MSG_RAW#>",{<#MSG_OPTIONS#>} );';

Expand Down
87 changes: 85 additions & 2 deletions Source/Services/uTWPPConnect.pas
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ TWPPConnect = class(TComponent)
procedure SendBase64(Const vBase64: String; vNum: String; Const vFileName, vMess: string); deprecated; //Versao 1.0.2.0 disponivel ate Versao 1.0.6.0
procedure SendLinkPreview(PNumberPhone, PVideoLink, PMessage: string);
procedure SendLocation(PNumberPhone, PLat, PLng, PMessage: string);
procedure Logtout();
procedure Logout();
procedure GetBatteryStatus;
procedure CheckIsValidNumber(PNumberPhone: string);
procedure NewCheckIsValidNumber(PNumberPhone : string);
Expand All @@ -186,6 +186,9 @@ TWPPConnect = class(TComponent)
procedure GroupLeave(PIDGroup: string);
procedure GroupDelete(PIDGroup: string);

procedure BloquearContato(PIDContato: String);
procedure DesbloquearContato(PIDContato: String);

procedure GroupJoinViaLink(PLinkGroup: string);
procedure GroupRemoveInviteLink(PIDGroup: string);
procedure SetProfileName(vName : String);
Expand Down Expand Up @@ -309,6 +312,45 @@ function TWPPConnect.Auth(PRaise: Boolean): Boolean;
Result := FrmConsole.ConfigureNetWork;
end; }

procedure TWPPConnect.BloquearContato(PIDContato: String);
var
lThread : TThread;
begin
If Application.Terminated Then
Exit;

if not Assigned(FrmConsole) then
Exit;

if Trim(PIDContato) = '' then
begin
Int_OnErroInterno(Self, MSG_WarningNothingtoSend, PIDContato);
Exit;
end;

PIDContato := AjustNumber.FormatIn(PIDContato);
if pos('@', PIDContato) = 0 then
Begin
Int_OnErroInterno(Self, MSG_ExceptPhoneNumberError, PIDContato);
Exit;
end;

lThread := TThread.CreateAnonymousThread(procedure
begin
TThread.Synchronize(nil, procedure
begin
if Assigned(FrmConsole) then
begin
FrmConsole.BloquearContato(PIDContato);
end;
end);

end);

lThread.FreeOnTerminate := true;
lThread.Start;
end;

function TWPPConnect.CheckDelivered: String;
var
lThread : TThread;
Expand Down Expand Up @@ -528,6 +570,47 @@ procedure TWPPConnect.deleteConversation(PNumberPhone: string);

end;

procedure TWPPConnect.DesbloquearContato(PIDContato: String);
var
lThread : TThread;
begin
If Application.Terminated Then
Exit;

if not Assigned(FrmConsole) then
Exit;

if Trim(PIDContato) = '' then
begin
Int_OnErroInterno(Self, MSG_WarningNothingtoSend, PIDContato);
Exit;
end;

PIDContato := AjustNumber.FormatIn(PIDContato);
if pos('@', PIDContato) = 0 then
Begin
Int_OnErroInterno(Self, MSG_ExceptPhoneNumberError, PIDContato);
Exit;
end;



lThread := TThread.CreateAnonymousThread(procedure
begin
TThread.Synchronize(nil, procedure
begin
if Assigned(FrmConsole) then
begin
FrmConsole.DesbloquearContato(PIDContato);
end;
end);

end);

lThread.FreeOnTerminate := true;
lThread.Start;
end;

destructor TWPPConnect.Destroy;
begin

Expand Down Expand Up @@ -1076,7 +1159,7 @@ procedure TWPPConnect.Loaded;
FormQrCodeStart(False);
end;

procedure TWPPConnect.Logtout;
procedure TWPPConnect.Logout;
var
lThread : TThread;
begin
Expand Down
8 changes: 5 additions & 3 deletions Source/View/uTWPPConnect.Console.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object FrmConsole: TFrmConsole
object Lbl_Caption: TLabel
Left = 1
Top = 1
Width = 106
Height = 13
Width = 785
Height = 18
Align = alClient
Alignment = taCenter
Caption = 'Mega Online Software'
Expand All @@ -49,6 +49,8 @@ object FrmConsole: TFrmConsole
Font.Style = []
ParentFont = False
Layout = tlCenter
ExplicitWidth = 106
ExplicitHeight = 13
end
object lbl_Versao: TLabel
AlignWithMargins = True
Expand Down Expand Up @@ -434,7 +436,7 @@ object FrmConsole: TFrmConsole
7E7DB6FFA0CEF8FFE57798F46A8E6D6850A60000000049454E44AE426082}
Proportional = True
Transparent = True
Visible = False
OnClick = Img_BrasilClick
OnMouseEnter = lbl_VersaoMouseEnter
end
end
Expand Down
38 changes: 38 additions & 0 deletions Source/View/uTWPPConnect.Console.pas
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ TFrmConsole = class(TForm)
const params: ICefContextMenuParams; const model: ICefMenuModel);
procedure Button2Click(Sender: TObject);
procedure Image2Click(Sender: TObject);
procedure Img_BrasilClick(Sender: TObject);
protected
// You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned.
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
Expand Down Expand Up @@ -190,6 +191,10 @@ TFrmConsole = class(TForm)

//Adicionado Por Marcelo 01/03/2022
procedure isBeta();

//Adicionado por Daniel 25/05/2022
procedure BloquearContato(vContato: string);
procedure DesbloquearContato(vContato: string);
procedure CheckDelivered;
procedure SendContact(vNumDest, vNum:string; vNameContact: string = '');
procedure SendBase64(vBase64, vNum, vFileName, vText:string);
Expand Down Expand Up @@ -252,6 +257,18 @@ procedure TFrmConsole.App_EventMinimize(Sender: TObject);
Hide;
end;

procedure TFrmConsole.BloquearContato(vContato: string);
var
Ljs: string;
begin
if not FConectado then
raise Exception.Create(MSG_ConfigCEF_ExceptConnetServ);

LJS := FrmConsole_JS_VAR_BlockContact;
FrmConsole_JS_AlterVar(LJS, '#CTT_NAME#', Trim(vContato));
ExecuteJS(LJS, true);
end;

procedure TFrmConsole.BrowserDestroyMsg(var aMessage : TMessage);
begin
CEFWindowParent1.Free;
Expand Down Expand Up @@ -701,6 +718,18 @@ procedure TFrmConsole.DeleteMessages(vID: string);
ExecuteJS(FrmConsole_JS_AlterVar(LJS, '#MSG_PHONE#', Trim(vID)), False);
end;

procedure TFrmConsole.DesbloquearContato(vContato: string);
var
Ljs: string;
begin
if not FConectado then
raise Exception.Create(MSG_ConfigCEF_ExceptConnetServ);

LJS := FrmConsole_JS_VAR_unBlockContact ;
FrmConsole_JS_AlterVar(LJS, '#CTT_NAME#', Trim(vContato));
ExecuteJS(LJS, true);
end;

Procedure TFrmConsole.DisConnect;
begin
try
Expand Down Expand Up @@ -1791,6 +1820,15 @@ procedure TFrmConsole.Image2Click(Sender: TObject);
Chromium1.ShowDevTools(TempPoint, nil);
end;

procedure TFrmConsole.Img_BrasilClick(Sender: TObject);
var TempPoint : Tpoint;
begin
TempPoint.X := 200;
TempPoint.Y := 200;

Chromium1.ShowDevTools(TempPoint, nil);
end;

procedure TFrmConsole.Int_FrmQRCodeClose(Sender: TObject);
begin
if FFormType = Ft_Desktop then
Expand Down

0 comments on commit bf7efe1

Please sign in to comment.