unit invmsg;

interface

uses
  Unicode, Dockable, ExEvents, MsgController, XMLTag, Contnrs,
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  buttonFrame, StdCtrls, ComCtrls, Grids, ExtCtrls, ExRichEdit, RichEdit2,
  Buttons, TntStdCtrls, Menus, TntComCtrls;

type
  TfrmInviteMsg = class(TfrmDockable)
    Image1: TImage;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Panel1: TPanel;
    Button1: TButton;
    Button2: TButton;
    Bevel1: TBevel;
    Label1: TLabel;
    txtMsg: TExRichEdit;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    JID: widestring;
    procedure DisplayEvent(e: TJabberEvent);
  end;

var
  frmInviteMsg: TfrmInviteMsg;

implementation

uses JabberID, Room, Session;

{$R *.dfm}

{ TfrmInviteMsg }

procedure TfrmInviteMsg.DisplayEvent(e: TJabberEvent);
var
  j: TJabberID;
begin
  JID := e.data_type;
  txtMsg.InputFormat := ifUnicode;
  txtmsg.Clear;
  txtmsg.SelStart := 0;
  txtmsg.SelAttributes.Style := txtmsg.SelAttributes.Style + [fsBold];
  txtmsg.SelText := ('»áÒéÊÒ:' + #13 + #10);
  txtmsg.SelAttributes.Style := txtmsg.SelAttributes.Style - [fsBold];
  j := TJabberID.Create(JID);
  txtmsg.WideSelText := j.user + #13 + #10;
  j.Free;
  txtmsg.SelAttributes.Style := txtmsg.SelAttributes.Style + [fsBold];
  txtmsg.SelText := ('ÑûÇëÐÅÏ¢:' + #13 + #10);
  txtmsg.SelAttributes.Style := txtmsg.SelAttributes.Style - [fsBold];
  txtmsg.WideSelText := e.Data.Text;
end;

procedure TfrmInviteMsg.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
end;

procedure TfrmInviteMsg.Button1Click(Sender: TObject);
begin
  inherited;
  if RadioButton1.Checked then
    StartRoom(jid, MainSession.Username);
  Close;
end;

procedure TfrmInviteMsg.Button2Click(Sender: TObject);
begin
  inherited;
  Close;
end;

end.
