Skip to content

Commit bf7efe1

Browse files
authored
Merge pull request #3 from daviladanielc/main
Nova função
2 parents 1550738 + 361d3af commit bf7efe1

File tree

5 files changed

+132
-6
lines changed

5 files changed

+132
-6
lines changed

Demo/u_principal.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,7 @@ procedure TfrmPrincipal.SpeedButton3Click(Sender: TObject);
19261926
if not TWPPConnect1.auth then
19271927
exit;
19281928

1929-
TWPPConnect1.Logtout;
1929+
TWPPConnect1.Logout;
19301930
TWPPConnect1.Disconnect;
19311931
end;
19321932

Source/Model/uTWPPConnect.Constant.pas

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ interface
151151
//MARCELO 02/05/2022
152152
FrmConsole_JS_VAR_SendContact = 'WPP.chat.sendVCardContactMessage("<#MSG_PHONE_DEST#>", "<#MSG_PHONE#>", {} )';
153153

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

Source/Services/uTWPPConnect.pas

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ TWPPConnect = class(TComponent)
170170
procedure SendBase64(Const vBase64: String; vNum: String; Const vFileName, vMess: string); deprecated; //Versao 1.0.2.0 disponivel ate Versao 1.0.6.0
171171
procedure SendLinkPreview(PNumberPhone, PVideoLink, PMessage: string);
172172
procedure SendLocation(PNumberPhone, PLat, PLng, PMessage: string);
173-
procedure Logtout();
173+
procedure Logout();
174174
procedure GetBatteryStatus;
175175
procedure CheckIsValidNumber(PNumberPhone: string);
176176
procedure NewCheckIsValidNumber(PNumberPhone : string);
@@ -186,6 +186,9 @@ TWPPConnect = class(TComponent)
186186
procedure GroupLeave(PIDGroup: string);
187187
procedure GroupDelete(PIDGroup: string);
188188

189+
procedure BloquearContato(PIDContato: String);
190+
procedure DesbloquearContato(PIDContato: String);
191+
189192
procedure GroupJoinViaLink(PLinkGroup: string);
190193
procedure GroupRemoveInviteLink(PIDGroup: string);
191194
procedure SetProfileName(vName : String);
@@ -309,6 +312,45 @@ function TWPPConnect.Auth(PRaise: Boolean): Boolean;
309312
Result := FrmConsole.ConfigureNetWork;
310313
end; }
311314

315+
procedure TWPPConnect.BloquearContato(PIDContato: String);
316+
var
317+
lThread : TThread;
318+
begin
319+
If Application.Terminated Then
320+
Exit;
321+
322+
if not Assigned(FrmConsole) then
323+
Exit;
324+
325+
if Trim(PIDContato) = '' then
326+
begin
327+
Int_OnErroInterno(Self, MSG_WarningNothingtoSend, PIDContato);
328+
Exit;
329+
end;
330+
331+
PIDContato := AjustNumber.FormatIn(PIDContato);
332+
if pos('@', PIDContato) = 0 then
333+
Begin
334+
Int_OnErroInterno(Self, MSG_ExceptPhoneNumberError, PIDContato);
335+
Exit;
336+
end;
337+
338+
lThread := TThread.CreateAnonymousThread(procedure
339+
begin
340+
TThread.Synchronize(nil, procedure
341+
begin
342+
if Assigned(FrmConsole) then
343+
begin
344+
FrmConsole.BloquearContato(PIDContato);
345+
end;
346+
end);
347+
348+
end);
349+
350+
lThread.FreeOnTerminate := true;
351+
lThread.Start;
352+
end;
353+
312354
function TWPPConnect.CheckDelivered: String;
313355
var
314356
lThread : TThread;
@@ -528,6 +570,47 @@ procedure TWPPConnect.deleteConversation(PNumberPhone: string);
528570

529571
end;
530572

573+
procedure TWPPConnect.DesbloquearContato(PIDContato: String);
574+
var
575+
lThread : TThread;
576+
begin
577+
If Application.Terminated Then
578+
Exit;
579+
580+
if not Assigned(FrmConsole) then
581+
Exit;
582+
583+
if Trim(PIDContato) = '' then
584+
begin
585+
Int_OnErroInterno(Self, MSG_WarningNothingtoSend, PIDContato);
586+
Exit;
587+
end;
588+
589+
PIDContato := AjustNumber.FormatIn(PIDContato);
590+
if pos('@', PIDContato) = 0 then
591+
Begin
592+
Int_OnErroInterno(Self, MSG_ExceptPhoneNumberError, PIDContato);
593+
Exit;
594+
end;
595+
596+
597+
598+
lThread := TThread.CreateAnonymousThread(procedure
599+
begin
600+
TThread.Synchronize(nil, procedure
601+
begin
602+
if Assigned(FrmConsole) then
603+
begin
604+
FrmConsole.DesbloquearContato(PIDContato);
605+
end;
606+
end);
607+
608+
end);
609+
610+
lThread.FreeOnTerminate := true;
611+
lThread.Start;
612+
end;
613+
531614
destructor TWPPConnect.Destroy;
532615
begin
533616

@@ -1076,7 +1159,7 @@ procedure TWPPConnect.Loaded;
10761159
FormQrCodeStart(False);
10771160
end;
10781161

1079-
procedure TWPPConnect.Logtout;
1162+
procedure TWPPConnect.Logout;
10801163
var
10811164
lThread : TThread;
10821165
begin

Source/View/uTWPPConnect.Console.dfm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ object FrmConsole: TFrmConsole
3737
object Lbl_Caption: TLabel
3838
Left = 1
3939
Top = 1
40-
Width = 106
41-
Height = 13
40+
Width = 785
41+
Height = 18
4242
Align = alClient
4343
Alignment = taCenter
4444
Caption = 'Mega Online Software'
@@ -49,6 +49,8 @@ object FrmConsole: TFrmConsole
4949
Font.Style = []
5050
ParentFont = False
5151
Layout = tlCenter
52+
ExplicitWidth = 106
53+
ExplicitHeight = 13
5254
end
5355
object lbl_Versao: TLabel
5456
AlignWithMargins = True
@@ -434,7 +436,7 @@ object FrmConsole: TFrmConsole
434436
7E7DB6FFA0CEF8FFE57798F46A8E6D6850A60000000049454E44AE426082}
435437
Proportional = True
436438
Transparent = True
437-
Visible = False
439+
OnClick = Img_BrasilClick
438440
OnMouseEnter = lbl_VersaoMouseEnter
439441
end
440442
end

Source/View/uTWPPConnect.Console.pas

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ TFrmConsole = class(TForm)
8787
const params: ICefContextMenuParams; const model: ICefMenuModel);
8888
procedure Button2Click(Sender: TObject);
8989
procedure Image2Click(Sender: TObject);
90+
procedure Img_BrasilClick(Sender: TObject);
9091
protected
9192
// You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned.
9293
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
@@ -190,6 +191,10 @@ TFrmConsole = class(TForm)
190191

191192
//Adicionado Por Marcelo 01/03/2022
192193
procedure isBeta();
194+
195+
//Adicionado por Daniel 25/05/2022
196+
procedure BloquearContato(vContato: string);
197+
procedure DesbloquearContato(vContato: string);
193198
procedure CheckDelivered;
194199
procedure SendContact(vNumDest, vNum:string; vNameContact: string = '');
195200
procedure SendBase64(vBase64, vNum, vFileName, vText:string);
@@ -252,6 +257,18 @@ procedure TFrmConsole.App_EventMinimize(Sender: TObject);
252257
Hide;
253258
end;
254259

260+
procedure TFrmConsole.BloquearContato(vContato: string);
261+
var
262+
Ljs: string;
263+
begin
264+
if not FConectado then
265+
raise Exception.Create(MSG_ConfigCEF_ExceptConnetServ);
266+
267+
LJS := FrmConsole_JS_VAR_BlockContact;
268+
FrmConsole_JS_AlterVar(LJS, '#CTT_NAME#', Trim(vContato));
269+
ExecuteJS(LJS, true);
270+
end;
271+
255272
procedure TFrmConsole.BrowserDestroyMsg(var aMessage : TMessage);
256273
begin
257274
CEFWindowParent1.Free;
@@ -701,6 +718,18 @@ procedure TFrmConsole.DeleteMessages(vID: string);
701718
ExecuteJS(FrmConsole_JS_AlterVar(LJS, '#MSG_PHONE#', Trim(vID)), False);
702719
end;
703720

721+
procedure TFrmConsole.DesbloquearContato(vContato: string);
722+
var
723+
Ljs: string;
724+
begin
725+
if not FConectado then
726+
raise Exception.Create(MSG_ConfigCEF_ExceptConnetServ);
727+
728+
LJS := FrmConsole_JS_VAR_unBlockContact ;
729+
FrmConsole_JS_AlterVar(LJS, '#CTT_NAME#', Trim(vContato));
730+
ExecuteJS(LJS, true);
731+
end;
732+
704733
Procedure TFrmConsole.DisConnect;
705734
begin
706735
try
@@ -1791,6 +1820,15 @@ procedure TFrmConsole.Image2Click(Sender: TObject);
17911820
Chromium1.ShowDevTools(TempPoint, nil);
17921821
end;
17931822

1823+
procedure TFrmConsole.Img_BrasilClick(Sender: TObject);
1824+
var TempPoint : Tpoint;
1825+
begin
1826+
TempPoint.X := 200;
1827+
TempPoint.Y := 200;
1828+
1829+
Chromium1.ShowDevTools(TempPoint, nil);
1830+
end;
1831+
17941832
procedure TFrmConsole.Int_FrmQRCodeClose(Sender: TObject);
17951833
begin
17961834
if FFormType = Ft_Desktop then

0 commit comments

Comments
 (0)