[interfacekit] Re: some questions on BApplication
- From: "burton666@xxxxxxxxx" <burton666@xxxxxxxxx>
- To: "interfacekit" <interfacekit@xxxxxxxxxxxxx>
- Date: Thu, 18 Dec 2003 08:36:42 +0100
> IIRC, in the early stages of the app_server and the prototypes, the app
> signature was the main way to determine whether or not the application
> was still running. Every three seconds or so, the app_server does a
> quick check to make sure that all applications it has in its list are
> still valid, and it would check via thread name. It wasn't quite good
> enough, so it checks for the app's port. It's been kept around for
> server debugging purposes, though. It probably should be kept around
> because it makes debugger server-side applcation stuff *much* easier.
Oki, I won't touch it :)
I have this patch for BApplication, anyway:
Index: src/kits/app/Application.cpp
===================================================================
RCS file: /cvsroot/open-beos/current/src/kits/app/Application.cpp,v
retrieving revision 1.33
diff -u -r1.33 Application.cpp
--- src/kits/app/Application.cpp 13 Oct 2003 23:34:12 -0000 1.33
+++ src/kits/app/Application.cpp 18 Dec 2003 07:34:23 -0000
@@ -33,12 +33,14 @@
#include <unistd.h>
// System Includes
-------------------------------------------------------------
+#include <Alert.h>
#include <AppFileInfo.h>
#include <Application.h>
#include <AppMisc.h>
#include <Cursor.h>
#include <Entry.h>
#include <File.h>
+#include <InterfaceDefs.h>
#include <Locker.h>
#include <Path.h>
#include <PropertyInfo.h>
@@ -365,6 +367,11 @@
//------------------------------------------------------------------------------
void BApplication::AboutRequested()
{
+ thread_info info;
+ if (get_thread_info(Thread(), &info) == B_OK) {
+ BAlert *alert = new BAlert("_about_", info.name, "OK");
+ alert->Go(NULL);
+ }
}
//------------------------------------------------------------------------------
BHandler* BApplication::ResolveSpecifier(BMessage* msg, int32 index,
@@ -742,38 +749,17 @@
}
#endif // ifdef RUN_WITHOUT_REGISTRAR
- // Notify app_server that we exist
- fServerFrom=find_port(SERVER_PORT_NAME);
- if(fServerFrom!=B_NAME_NOT_FOUND)
- {
- // Create the port so that the app_server knows where to send
messages
- fServerTo=create_port(100,"a<fServerTo");
- if(fServerTo!=B_BAD_VALUE && fServerTo!=B_NO_MORE_PORTS)
- {
- // AS_CREATE_APP:
-
- // Attach data:
- // 1) port_id - receiver port of a regular app
- // 2) int32 - handler ID token of the app
- // 3) char * - signature of the regular app
- PortLink link(fServerFrom);
- PortMessage pmsg;
-
- link.SetOpCode(AS_CREATE_APP);
- link.Attach<port_id>(fServerTo);
- link.Attach<port_id>(_get_object_token_(this));
- link.AttachString(signature);
- link.FlushWithReply(&pmsg);
-
- // Reply code: AS_CREATE_APP
- // Reply data:
- // 1) port_id server-side application port
(fServerFrom value)
- pmsg.Read<port_id>(&fServerFrom);
- }
- else
- fInitError=fServerTo;
- }
-
+ // TODO: Not sure about the order
+ if (fInitError == B_OK)
+ connect_to_app_server();
+ if (fInitError == B_OK)
+ setup_server_heaps();
+ if (fInitError == B_OK)
+ get_scs();
+ //TODO: Where is _init_interface_kit() declared ?
+ //if (fInitError == B_OK)
+ // fInitError = _init_interface_kit();
+
// init be_app and be_app_messenger
if (fInitError == B_OK) {
be_app = this;
@@ -813,6 +799,7 @@
//------------------------------------------------------------------------------
void BApplication::get_scs()
{
+ //gPrivateScreen = new BPrivateScreen();
}
//------------------------------------------------------------------------------
void BApplication::setup_server_heaps()
@@ -836,6 +823,34 @@
//------------------------------------------------------------------------------
void BApplication::connect_to_app_server()
{
+ fServerFrom = find_port(SERVER_PORT_NAME);
+ if(fServerFrom > 0) {
+ // Create the port so that the app_server knows where to send
messages
+ fServerTo = create_port(100, "a<fServerTo");
+ if(fServerTo > 0) {
+ // AS_CREATE_APP:
+
+ // Attach data:
+ // 1) port_id - receiver port of a regular app
+ // 2) int32 - handler ID token of the app
+ // 3) char * - signature of the regular app
+ PortLink link(fServerFrom);
+ PortMessage pmsg;
+
+ link.SetOpCode(AS_CREATE_APP);
+ link.Attach<port_id>(fServerTo);
+ link.Attach<port_id>(_get_object_token_(this));
+ link.AttachString(fAppName);
+ link.FlushWithReply(&pmsg);
+
+ // Reply code: AS_CREATE_APP
+ // Reply data:
+ // 1) port_id server-side application port
(fServerFrom value)
+ pmsg.Read<port_id>(&fServerFrom);
+ }
+ else
+ fInitError = fServerTo;
+ }
}
//------------------------------------------------------------------------------
void BApplication::send_drag(BMessage* msg, int32 vs_token, BPoint offset,
BRect drag_rect, BHandler* reply_to)
@@ -863,6 +878,7 @@
void BApplication::do_argv(BMessage* message)
{
if (message) {
+ // TODO: Isn't this implementation specific ?
int32 argc = __libc_argc;
const char * const *argv = __libc_argv;
// add argc
I moved the connection to the app server to "connect_to_app_server()"
(amazingly), added calls to get_scs(), init_interface_kit() (commented, since I
can't find where we declare it), added a comment to do_argv(), and implemented
AboutRequested().
I'll apply the patch to Globals.cpp in short time (i.e. tomorrow).
- Follow-Ups:
- [interfacekit] Re: some questions on BApplication
- From: Ingo Weinhold
Other related posts:
- » [interfacekit] some questions on BApplication
- » [interfacekit] Re: some questions on BApplication
- » [interfacekit] Re: some questions on BApplication
- » [interfacekit] Re: some questions on BApplication
- » [interfacekit] Re: some questions on BApplication
- » [interfacekit] Re: some questions on BApplication
- » [interfacekit] Re: some questions on BApplication
- [interfacekit] Re: some questions on BApplication
- From: Ingo Weinhold