-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuAddInRoster.pas
More file actions
101 lines (88 loc) · 2.29 KB
/
Copy pathuAddInRoster.pas
File metadata and controls
101 lines (88 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
unit uAddInRoster;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons,uMessageQueue, global_const,uNewGroup;
type
TfAddUser = class(TForm)
edJID: TEdit;
Label1: TLabel;
edNick: TEdit;
Label2: TLabel;
Label3: TLabel;
bbtAdd: TBitBtn;
chbAuth: TCheckBox;
cbGroup: TComboBox;
Button1: TButton;
bbtCancel: TBitBtn;
edServer: TEdit;
Label4: TLabel;
procedure bbtAddClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure bbtCancelClick(Sender: TObject);
private
{ Private declarations }
res_ok: boolean;
public
{ Public declarations }
function AddUserInRoster(GroupList: TStringList; var userjid,usernick, group: string; auth_need : boolean):boolean;
end;
var
fAddUser: TfAddUser;
implementation
{$R *.dfm}
function TfAddUser.AddUserInRoster(GroupList: TStringList; var userjid,usernick, group: string; auth_need : boolean ):boolean;
var i : integer;
begin
res_ok := false;
cbGroup.Items.Clear;
cbGroup.Items.Append('<None>');
for i := 0 to GroupList.Count-1 do
begin
if (GroupList[i] <> GROUP_NONE)and (GroupList[i] <> GROUP_NOT_IN_LIST)then
cbGroup.Items.Append(GroupList[i]);
end;
cbGroup.ItemIndex := 0;
edServer.Text := userjid;
userjid :='';
ShowModal;
if res_ok then
begin
userjid := edJID.Text+'@'+edServer.Text;
usernick := edNick.Text;
if (cbGroup.Text = '<None>') then group := ''
else group := cbGroup.Text;
auth_need := chbAuth.Checked;
end;
result := res_ok;
end;
procedure TfAddUser.bbtAddClick(Sender: TObject);
begin
if (edJID.Text = '') then
begin
ShowMessage('Äîëæåí áûòü óêàçàí JID ïîëüçîâàòåëÿ');
exit;
end;
res_ok := true;
Close;
end;
procedure TfAddUser.Button1Click(Sender: TObject);
var fNewGroup: TfNewGroup;
new_group: string;
ind : integer;
begin
Application.CreateForm(TfNewGroup, fNewGroup);
new_group := fNewGroup.GetNewGroup;
if new_group <> '' then
begin
ind := cbGroup.Items.IndexOf(new_group);
if (ind < 0) then
ind := cbGroup.Items.Add(new_group);
cbGroup.ItemIndex := ind;
end;
end;
procedure TfAddUser.bbtCancelClick(Sender: TObject);
begin
Close;
end;
end.