From 15fe75b9a0e16762374a6224bb42a121c35c8207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 24 Nov 2009 17:22:44 +0000 Subject: [PATCH] * Added a protocol version field to AS_GET_DESKTOP. This should be bumped after incompatible releases, and makes sure clients using the old libbe.so will be rejected. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34210 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/ServerProtocol.h | 2 ++ src/kits/app/Application.cpp | 3 ++- src/servers/app/AppServer.cpp | 36 ++++++++++++++++++---------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 44c10d71b6..663d2b1576 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -28,6 +28,8 @@ # define SERVER_INPUT_PORT "haiku-test:input port" #endif +#define AS_PROTOCOL_VERSION 1 + #define AS_REQUEST_COLOR_KEY 0x00010000 // additional option for AS_VIEW_SET_VIEW_BITMAP diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index 341645cfc6..b8be3428c1 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2008, Haiku. + * Copyright 2001-2009, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -1273,6 +1273,7 @@ BApplication::_ConnectToServer() fServerLink->Attach(clientPort); fServerLink->Attach(getuid()); fServerLink->AttachString(getenv("TARGET_SCREEN")); + fServerLink->Attach(AS_PROTOCOL_VERSION); int32 code; if (fServerLink->FlushWithReply(code) != B_OK || code != B_OK) { diff --git a/src/servers/app/AppServer.cpp b/src/servers/app/AppServer.cpp index 612d6450a5..ec2c879506 100644 --- a/src/servers/app/AppServer.cpp +++ b/src/servers/app/AppServer.cpp @@ -35,7 +35,7 @@ // Globals port_id gAppServerPort; -static AppServer *sAppServer; +static AppServer* sAppServer; BTokenSpace gTokenSpace; uint32 gAppServerSIMDFlags = 0; @@ -128,6 +128,9 @@ AppServer::AppServer() sAppServer = this; + // Initialize SIMD flags + detect_simd(); + gInputManager = new InputManager(); // Create the font server and scan the proper directories. @@ -142,9 +145,6 @@ AppServer::AppServer() // Create the bitmap allocator. Object declared in BitmapManager.cpp gBitmapManager = new BitmapManager(); - - // Initialize SIMD flags - detect_simd(); } @@ -239,9 +239,10 @@ AppServer::_DispatchMessage(int32 code, BPrivate::LinkReceiver& msg) switch (code) { case AS_GET_DESKTOP: { + Desktop* desktop = NULL; + port_id replyPort; - if (msg.Read(&replyPort) < B_OK) - break; + msg.Read(&replyPort); int32 userID; msg.Read(&userID); @@ -253,16 +254,25 @@ AppServer::_DispatchMessage(int32 code, BPrivate::LinkReceiver& msg) targetScreen = NULL; } - Desktop* desktop = _FindDesktop(userID, targetScreen); - if (desktop == NULL) { - // we need to create a new desktop object for this user - // TODO: test if the user exists on the system - // TODO: maybe have a separate AS_START_DESKTOP_SESSION for - // authorizing the user - desktop = _CreateDesktop(userID, targetScreen); + int32 version; + if (msg.Read(&version) < B_OK + || version != AS_PROTOCOL_VERSION) { + syslog(LOG_ERR, "Application for user %ld with port %ld does " + "not support the current server protocol.\n", userID, + replyPort); + } else { + desktop = _FindDesktop(userID, targetScreen); + if (desktop == NULL) { + // we need to create a new desktop object for this user + // TODO: test if the user exists on the system + // TODO: maybe have a separate AS_START_DESKTOP_SESSION for + // authorizing the user + desktop = _CreateDesktop(userID, targetScreen); + } } free(targetScreen); + BPrivate::LinkSender reply(replyPort); if (desktop != NULL) { reply.StartMessage(B_OK);