source: trunk/dsa_messenger/client-sessions.adb

Last change on this file was 11, checked in by vadim.godunko, 12 years ago

Renamings.

File size: 2.3 KB
Line 
1with Qt_Ada.Object_Unchecked_Deallocation;
2with Qt4.Strings;
3
4with Client.Emitters;
5
6package body Client.Sessions is
7
8 procedure Free is
9 new Qt_Ada.Object_Unchecked_Deallocation
10 (Client.Emitters.Emitter'Class, Client.Emitters.Emitter_Access);
11
12 ----------------------
13 -- Message_Received --
14 ----------------------
15
16 procedure Message_Received
17 (Self : in out Session;
18 From : String;
19 Text : String)
20 is
21 Emitter : Client.Emitters.Emitter_Access
22 := Client.Emitters.Constructors.Create;
23
24 begin
25 Qt4.Objects.Connect
26 (Emitter,
27 Qt4.Signal ("received(QString,QString)"),
28 Self.Dispatcher,
29 Qt4.Slot ("receive(QString,QString)"));
30
31 Emitter.Receive
32 (Qt4.Strings.From_Utf_8 (From), Qt4.Strings.From_Utf_8 (Text));
33
34 Free (Emitter);
35 end Message_Received;
36
37 ----------------------------
38 -- Set_Message_Dispatcher --
39 ----------------------------
40
41 procedure Set_Message_Dispatcher
42 (Self : in out Session;
43 Dispatcher : not null access Qt4.Objects.Q_Object'Class) is
44 begin
45 Self.Dispatcher := Qt4.Objects.Q_Object_Access (Dispatcher);
46 end Set_Message_Dispatcher;
47
48 --------------------
49 -- User_Connected --
50 --------------------
51
52 procedure User_Connected
53 (Self : in out Session;
54 Name : String)
55 is
56 Emitter : Client.Emitters.Emitter_Access
57 := Client.Emitters.Constructors.Create;
58
59 begin
60 Qt4.Objects.Connect
61 (Emitter,
62 Qt4.Signal ("userConnected(QString)"),
63 Self.Dispatcher,
64 Qt4.Slot ("userConnected(QString)"));
65
66 Emitter.User_Connected (Qt4.Strings.From_Utf_8 (Name));
67
68 Free (Emitter);
69 end User_Connected;
70
71 -----------------------
72 -- User_Disconnected --
73 -----------------------
74
75 procedure User_Disconnected
76 (Self : in out Session;
77 Name : String)
78 is
79 Emitter : Client.Emitters.Emitter_Access
80 := Client.Emitters.Constructors.Create;
81
82 begin
83 Qt4.Objects.Connect
84 (Emitter,
85 Qt4.Signal ("userDisconnected(QString)"),
86 Self.Dispatcher,
87 Qt4.Slot ("userDisconnected(QString)"));
88
89 Emitter.User_Disconnected (Qt4.Strings.From_Utf_8 (Name));
90
91 Free (Emitter);
92 end User_Disconnected;
93
94end Client.Sessions;
Note: See TracBrowser for help on using the repository browser.