1 /* 2 * Copyright 2006, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Axel Dörfler, axeld@pinc-software.de 7 */ 8 9 10 #include <unistd.h> 11 12 #include <DesktopLink.h> 13 #include <ServerProtocol.h> 14 15 16 namespace BPrivate { 17 18 DesktopLink::DesktopLink() 19 : 20 fReplyPort(B_ERROR) 21 { 22 // get the app server port 23 port_id port = find_port(SERVER_PORT_NAME); 24 if (port < B_OK) 25 return; 26 27 // create a reply port 28 fReplyPort = create_port(1, "desktop reply"); 29 if (fReplyPort < B_OK) 30 return; 31 32 SetTo(port, fReplyPort); 33 34 // We can't use AppServerLink because be_app may be NULL 35 StartMessage(AS_GET_DESKTOP); 36 Attach<port_id>(fReplyPort); 37 Attach<int32>(getuid()); 38 39 int32 code; 40 if (FlushWithReply(code) != B_OK || code != B_OK) 41 return; 42 43 // we now talk to the desktop 44 Read<port_id>(&port); 45 SetSenderPort(port); 46 } 47 48 49 DesktopLink::~DesktopLink() 50 { 51 delete_port(fReplyPort); 52 } 53 54 55 status_t 56 DesktopLink::InitCheck() const 57 { 58 return fReplyPort < B_OK ? fReplyPort : B_OK; 59 } 60 61 } // namespace BPrivate 62