| 
									
										
										
										
											2020-02-16 19:28:08 +01:00
										 |  |  | #include <LibGUI/Notification.h>
 | 
					
						
							|  |  |  | #include <LibIPC/ServerConnection.h>
 | 
					
						
							|  |  |  | #include <NotificationServer/NotificationClientEndpoint.h>
 | 
					
						
							|  |  |  | #include <NotificationServer/NotificationServerEndpoint.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace GUI { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class NotificationServerConnection : public IPC::ServerConnection<NotificationClientEndpoint, NotificationServerEndpoint> | 
					
						
							|  |  |  |     , public NotificationClientEndpoint { | 
					
						
							|  |  |  |     C_OBJECT(NotificationServerConnection) | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     virtual void handshake() override | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         auto response = send_sync<Messages::NotificationServer::Greet>(); | 
					
						
							|  |  |  |         set_my_client_id(response->client_id()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     NotificationServerConnection() | 
					
						
							|  |  |  |         : IPC::ServerConnection<NotificationClientEndpoint, NotificationServerEndpoint>(*this, "/tmp/portal/notify") | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     virtual void handle(const Messages::NotificationClient::Dummy&) override {} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Notification::Notification() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Notification::~Notification() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Notification::show() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-26 20:10:03 +01:00
										 |  |  |     auto connection = NotificationServerConnection::construct(); | 
					
						
							| 
									
										
										
										
											2020-03-26 20:38:28 +01:00
										 |  |  |     connection->post_message(Messages::NotificationServer::ShowNotification(m_text, m_title, m_icon_path)); | 
					
						
							| 
									
										
										
										
											2020-02-16 19:28:08 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |