It is accomplished ...

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
ejakowatz
2002-07-09 12:24:59 +00:00
commit 52a3801208
2025 changed files with 472889 additions and 0 deletions
+167
View File
@@ -0,0 +1,167 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: AppDefs.h
// Author: Erik Jaesler ([email protected])
// Description: Message codes and the global cursors.
//------------------------------------------------------------------------------
#ifndef _APP_DEFS_H
#define _APP_DEFS_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// Global Cursors --------------------------------------------------------------
// Old-style cursors
extern const unsigned char B_HAND_CURSOR[];
extern const unsigned char B_I_BEAM_CURSOR[];
// New-style cursors
#ifdef __cplusplus
class BCursor;
extern const BCursor *B_CURSOR_SYSTEM_DEFAULT;
extern const BCursor *B_CURSOR_I_BEAM;
#endif
// System Message Codes --------------------------------------------------------
enum {
B_ABOUT_REQUESTED = '_ABR',
B_WINDOW_ACTIVATED = '_ACT',
B_APP_ACTIVATED = '_ACT', // Same as B_WINDOW_ACTIVATED
B_ARGV_RECEIVED = '_ARG',
B_QUIT_REQUESTED = '_QRQ',
B_CLOSE_REQUESTED = '_QRQ', // Obsolete; use B_QUIT_REQUESTED
B_CANCEL = '_CNC',
B_KEY_DOWN = '_KYD',
B_KEY_UP = '_KYU',
B_UNMAPPED_KEY_DOWN = '_UKD',
B_UNMAPPED_KEY_UP = '_UKU',
B_MODIFIERS_CHANGED = '_MCH',
B_MINIMIZE = '_WMN',
B_MOUSE_DOWN = '_MDN',
B_MOUSE_MOVED = '_MMV',
B_MOUSE_ENTER_EXIT = '_MEX',
B_MOUSE_UP = '_MUP',
B_MOUSE_WHEEL_CHANGED = '_MWC',
B_OPEN_IN_WORKSPACE = '_OWS',
B_PRINTER_CHANGED = '_PCH',
B_PULSE = '_PUL',
B_READY_TO_RUN = '_RTR',
B_REFS_RECEIVED = '_RRC',
B_RELEASE_OVERLAY_LOCK = '_ROV',
B_ACQUIRE_OVERLAY_LOCK = '_AOV',
B_SCREEN_CHANGED = '_SCH',
B_VALUE_CHANGED = '_VCH',
B_VIEW_MOVED = '_VMV',
B_VIEW_RESIZED = '_VRS',
B_WINDOW_MOVED = '_WMV',
B_WINDOW_RESIZED = '_WRS',
B_WORKSPACES_CHANGED = '_WCG',
B_WORKSPACE_ACTIVATED = '_WAC',
B_ZOOM = '_WZM',
_APP_MENU_ = '_AMN',
_BROWSER_MENUS_ = '_BRM',
_MENU_EVENT_ = '_MEV',
_PING_ = '_PBL',
_QUIT_ = '_QIT',
_VOLUME_MOUNTED_ = '_NVL',
_VOLUME_UNMOUNTED_ = '_VRM',
_MESSAGE_DROPPED_ = '_MDP',
_DISPOSE_DRAG_ = '_DPD',
_MENUS_DONE_ = '_MND',
_SHOW_DRAG_HANDLES_ = '_SDH',
_EVENTS_PENDING_ = '_EVP',
_UPDATE_ = '_UPD',
_UPDATE_IF_NEEDED_ = '_UPN',
_PRINTER_INFO_ = '_PIN',
_SETUP_PRINTER_ = '_SUP',
_SELECT_PRINTER_ = '_PSL'
// Media Kit reserves all reserved codes starting in '_TR'
};
// Other Commands --------------------------------------------------------------
enum {
B_SET_PROPERTY = 'PSET',
B_GET_PROPERTY = 'PGET',
B_CREATE_PROPERTY = 'PCRT',
B_DELETE_PROPERTY = 'PDEL',
B_COUNT_PROPERTIES = 'PCNT',
B_EXECUTE_PROPERTY = 'PEXE',
B_GET_SUPPORTED_SUITES = 'SUIT',
B_UNDO = 'UNDO',
B_CUT = 'CCUT',
B_COPY = 'COPY',
B_PASTE = 'PSTE',
B_SELECT_ALL = 'SALL',
B_SAVE_REQUESTED = 'SAVE',
B_MESSAGE_NOT_UNDERSTOOD = 'MNOT',
B_NO_REPLY = 'NONE',
B_REPLY = 'RPLY',
B_SIMPLE_DATA = 'DATA',
B_MIME_DATA = 'MIME',
B_ARCHIVED_OBJECT = 'ARCV',
B_UPDATE_STATUS_BAR = 'SBUP',
B_RESET_STATUS_BAR = 'SBRS',
B_NODE_MONITOR = 'NDMN',
B_QUERY_UPDATE = 'QUPD',
B_ENDORSABLE = 'ENDO',
B_COPY_TARGET = 'DDCP',
B_MOVE_TARGET = 'DDMV',
B_TRASH_TARGET = 'DDRM',
B_LINK_TARGET = 'DDLN',
B_INPUT_DEVICES_CHANGED = 'IDCH',
B_INPUT_METHOD_EVENT = 'IMEV',
B_WINDOW_MOVE_TO = 'WDMT',
B_WINDOW_MOVE_BY = 'WDMB',
B_SILENT_RELAUNCH = 'AREL',
B_OBSERVER_NOTICE_CHANGE = 'NTCH',
B_CONTROL_INVOKED = 'CIVK',
B_CONTROL_MODIFIED = 'CMOD'
// Media Kit reserves all reserved codes starting in 'TRI'
};
//------------------------------------------------------------------------------
#endif // _APP_DEFS_H
/*
* $Log $
*
* $Id $
*
*/
+223
View File
@@ -0,0 +1,223 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Application.h
// Author: Erik Jaesler ([email protected])
// Description: BApplication class is the center of the application
// universe. The global be_app and be_app_messenger
// variables are defined here as well.
//------------------------------------------------------------------------------
#ifndef _APPLICATION_H
#define _APPLICATION_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <AppDefs.h> // For convenience
#include <InterfaceDefs.h>
#include <Looper.h>
#include <Messenger.h>
#include <Point.h>
#include <Rect.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BCursor;
class BList;
class BWindow;
class _BSession_;
class BResources;
class BMessageRunner;
struct _server_heap_;
struct _drag_data_;
// BApplication class ----------------------------------------------------------
class BApplication : public BLooper {
public:
BApplication(const char* signature);
BApplication(const char* signature,
status_t* error);
virtual ~BApplication();
// Archiving
BApplication(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
status_t InitCheck() const;
// App control and System Message handling
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
virtual void Pulse();
virtual void ReadyToRun();
virtual void MessageReceived(BMessage* msg);
virtual void ArgvReceived(int32 argc, char** argv);
virtual void AppActivated(bool active);
virtual void RefsReceived(BMessage* a_message);
virtual void AboutRequested();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
// Cursor control, window/looper list, and app info
void ShowCursor();
void HideCursor();
void ObscureCursor();
bool IsCursorHidden() const;
void SetCursor(const void* cursor);
void SetCursor(const BCursor* cursor, bool sync = true);
int32 CountWindows() const;
BWindow* WindowAt(int32 index) const;
int32 CountLoopers() const;
BLooper* LooperAt(int32 index) const;
bool IsLaunching() const;
status_t GetAppInfo(app_info* info) const;
static BResources* AppResources();
virtual void DispatchMessage(BMessage* an_event,
BHandler* handler);
void SetPulseRate(bigtime_t rate);
// More scripting
virtual status_t GetSupportedSuites(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
typedef BLooper _inherited;
friend class BWindow;
friend class BView;
friend class BBitmap;
friend class BScrollBar;
friend class BPrivateScreen;
friend class _BAppServerLink_;
friend void _toggle_handles_(bool);
BApplication(uint32 signature);
BApplication(const BApplication&);
BApplication& operator=(const BApplication&);
virtual void _ReservedApplication1();
virtual void _ReservedApplication2();
virtual void _ReservedApplication3();
virtual void _ReservedApplication4();
virtual void _ReservedApplication5();
virtual void _ReservedApplication6();
virtual void _ReservedApplication7();
virtual void _ReservedApplication8();
virtual bool ScriptReceived(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
void run_task();
void InitData(const char* signature, status_t* error);
void BeginRectTracking(BRect r, bool trackWhole);
void EndRectTracking();
void get_scs();
void setup_server_heaps();
void* rw_offs_to_ptr(uint32 offset);
void* ro_offs_to_ptr(uint32 offset);
void* global_ro_offs_to_ptr(uint32 offset);
void connect_to_app_server();
void send_drag( BMessage* msg,
int32 vs_token,
BPoint offset,
BRect drag_rect,
BHandler* reply_to);
void send_drag( BMessage* msg,
int32 vs_token,
BPoint offset,
int32 bitmap_token,
drawing_mode dragMode,
BHandler* reply_to);
void write_drag(_BSession_* session, BMessage* a_message);
bool quit_all_windows(bool force);
bool window_quit_loop(bool, bool);
void do_argv(BMessage* msg);
#ifndef FIX_FOR_4_6
void SetAppCursor();
#endif
uint32 InitialWorkspace();
int32 count_windows(bool incl_menus) const;
BWindow* window_at(uint32 index, bool incl_menus) const;
status_t get_window_list(BList* list, bool incl_menus) const;
static int32 async_quit_entry(void*);
static BResources* _app_resources;
static BLocker _app_resources_lock;
const char* fAppName;
int32 fServerFrom;
int32 fServerTo;
#ifndef FIX_FOR_4_6
void* fCursorData;
#else
void* _unused1;
#endif
_server_heap_* fServerHeap;
bigtime_t fPulseRate;
uint32 fInitialWorkspace;
_drag_data_* fDraggedMessage;
BMessageRunner* fPulseRunner;
status_t fInitError;
uint32 _reserved[11];
bool fReadyToRunCalled;
};
//------------------------------------------------------------------------------
// Global Objects --------------------------------------------------------------
extern _IMPEXP_BE BApplication* be_app;
extern _IMPEXP_BE BMessenger be_app_messenger;
//------------------------------------------------------------------------------
#endif // _APPLICATION_H
/*
* $Log $
*
* $Id $
*
*/
+82
View File
@@ -0,0 +1,82 @@
/******************************************************************************
/
/ File: Clipboard.h
/
/ Description: BClipboard class defines clipboard functionality.
/ The global be_clipboard represents the default clipboard.
/
/ Copyright 1995-98, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _CLIPBOARD_H
#define _CLIPBOARD_H
#include <BeBuild.h>
#include <Messenger.h>
#include <Locker.h>
class BMessage;
enum {
B_CLIPBOARD_CHANGED = 'CLCH'
};
/*------------------------------------------------------------------*/
/*----- BClipboard class --------------------------------------------*/
class BClipboard {
public:
BClipboard(const char *name, bool transient = false);
virtual ~BClipboard();
const char *Name() const;
uint32 LocalCount() const;
uint32 SystemCount() const;
status_t StartWatching(BMessenger target);
status_t StopWatching(BMessenger target);
bool Lock();
void Unlock();
bool IsLocked() const;
status_t Clear();
status_t Commit();
status_t Revert();
BMessenger DataSource() const;
BMessage *Data() const;
/*----- Private or reserved -----------------------------------------*/
private:
BClipboard(const BClipboard &);
BClipboard &operator=(const BClipboard &);
virtual void _ReservedClipboard1();
virtual void _ReservedClipboard2();
virtual void _ReservedClipboard3();
bool AssertLocked() const;
status_t DownloadFromSystem(bool force = false);
status_t UploadToSystem();
uint32 fCount;
BMessage *fData;
BLocker fLock;
BMessenger fClipHandler;
BMessenger fDataSource;
uint32 fSystemCount;
char *fName;
uint32 _reserved[4];
};
/*----------------------------------------------------------------*/
/*----- Global Clipboard -----------------------------------------*/
extern _IMPEXP_BE BClipboard *be_clipboard;
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _CLIPBOARD_H */
+83
View File
@@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Cursor.h
// Author: Frans van Nispen ([email protected])
// Description: BCursor describes a view-wide or application-wide cursor.
//------------------------------------------------------------------------------
#ifndef _CURSOR_H
#define _CURSOR_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <Archivable.h>
#include <BeBuild.h>
#include <InterfaceDefs.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
// BCursor class ---------------------------------------------------------------
class BCursor : BArchivable {
public:
BCursor(const void* cursorData);
BCursor(BMessage* data);
virtual ~BCursor();
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* data);
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
private:
virtual void _ReservedCursor1();
virtual void _ReservedCursor2();
virtual void _ReservedCursor3();
virtual void _ReservedCursor4();
friend class BApplication;
friend class BView;
int32 m_serverToken;
int32 m_needToFree;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _CURSOR_H
/*
* $Log $
*
* $Id $
*
*/
+148
View File
@@ -0,0 +1,148 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Handler.cpp
// Author: Erik Jaesler ([email protected])
// Description: BHandler defines the message-handling protocol.
// MessageReceived() is its lynchpin.
//------------------------------------------------------------------------------
#ifndef _HANDLER_H
#define _HANDLER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Archivable.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BLooper;
class BMessageFilter;
class BMessage;
class BList;
class _ObserverList;
#define B_OBSERVE_WHAT_CHANGE "be:observe_change_what"
#define B_OBSERVE_ORIGINAL_WHAT "be:observe_orig_what"
const uint32 B_OBSERVER_OBSERVE_ALL = 0xffffffff;
// BHandler class --------------------------------------------------------------
class BHandler : public BArchivable {
public:
BHandler(const char* name = NULL);
virtual ~BHandler();
// Archiving
BHandler(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// BHandler guts.
virtual void MessageReceived(BMessage* message);
BLooper* Looper() const;
void SetName(const char* name);
const char* Name() const;
virtual void SetNextHandler(BHandler* handler);
BHandler* NextHandler() const;
// Message filtering
virtual void AddFilter(BMessageFilter* filter);
virtual bool RemoveFilter(BMessageFilter* filter);
virtual void SetFilterList(BList* filters);
BList* FilterList();
bool LockLooper();
status_t LockLooperWithTimeout(bigtime_t timeout);
void UnlockLooper();
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Observer calls, inter-looper and inter-team
status_t StartWatching(BMessenger, uint32 what);
status_t StartWatchingAll(BMessenger);
status_t StopWatching(BMessenger, uint32 what);
status_t StopWatchingAll(BMessenger);
// Observer calls for observing targets in the same BLooper
status_t StartWatching(BHandler* , uint32 what);
status_t StartWatchingAll(BHandler* );
status_t StopWatching(BHandler* , uint32 what);
status_t StopWatchingAll(BHandler* );
// Reserved
virtual status_t Perform(perform_code d, void* arg);
// Notifier calls
virtual void SendNotices(uint32 what, const BMessage* = 0);
bool IsWatched() const;
//----- Private or reserved -----------------------------------------
private:
typedef BArchivable _inherited;
friend inline int32 _get_object_token_(const BHandler* );
friend class BLooper;
friend class BMessageFilter;
virtual void _ReservedHandler2();
virtual void _ReservedHandler3();
virtual void _ReservedHandler4();
void InitData(const char* name);
BHandler(const BHandler&);
BHandler& operator=(const BHandler&);
void SetLooper(BLooper* loop);
int32 fToken;
char* fName;
BLooper* fLooper;
BHandler* fNextHandler;
BList* fFilters;
_ObserverList* fObserverList;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _HANDLER_H
/*
* $Log $
*
* $Id $
*
*/
+128
View File
@@ -0,0 +1,128 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Invoker.h
// Author: Frans van Nispen ([email protected])
// Description: BInvoker class defines a protocol for objects that
// post messages to a "target".
//------------------------------------------------------------------------------
#ifndef _INVOKER_H
#define _INVOKER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Messenger.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
class BMessage;
// BInvoker class --------------------------------------------------------------
class BInvoker {
public:
BInvoker();
BInvoker(BMessage *message,
const BHandler *handler,
const BLooper *looper = NULL);
BInvoker(BMessage *message, BMessenger target);
virtual ~BInvoker();
virtual status_t SetMessage(BMessage *message);
BMessage *Message() const;
uint32 Command() const;
virtual status_t SetTarget(const BHandler *h, const BLooper *loop = NULL);
virtual status_t SetTarget(BMessenger messenger);
bool IsTargetLocal() const;
BHandler *Target(BLooper **looper = NULL) const;
BMessenger Messenger() const;
virtual status_t SetHandlerForReply(BHandler *handler);
BHandler *HandlerForReply() const;
virtual status_t Invoke(BMessage *msg = NULL);
// Invoke with BHandler notification. Use this to perform an
// Invoke() with some other kind of notification change code.
// (A raw invoke should always notify as B_CONTROL_INVOKED.)
// Unlike a raw Invoke(), there is no standard message that is
// sent. If 'msg' is NULL, then nothing will be sent to this
// invoker's target... however, a notification message will
// still be sent to any watchers of the invoker's handler.
// Note that the BInvoker class does not actually implement
// any of this behavior -- it is up to subclasses to override
// Invoke() and call Notify() with the appropriate change code.
status_t InvokeNotify(BMessage *msg, uint32 kind = B_CONTROL_INVOKED);
status_t SetTimeout(bigtime_t timeout);
bigtime_t Timeout() const;
protected:
// Return the change code for a notification. This is either
// B_CONTROL_INVOKED for raw Invoke() calls, or the kind
// supplied to InvokeNotify(). In addition, 'notify' will be
// set to true if this was an InvokeNotify() call, else false.
uint32 InvokeKind(bool* notify = NULL);
// Start and end an InvokeNotify context around an Invoke() call.
// These are only needed for writing custom methods that
// emulate the standard InvokeNotify() call.
void BeginInvokeNotify(uint32 kind = B_CONTROL_INVOKED);
void EndInvokeNotify();
// Private or reserved ---------------------------------------------------------
private:
// to be able to keep binary compatibility
virtual void _ReservedInvoker1();
virtual void _ReservedInvoker2();
virtual void _ReservedInvoker3();
BInvoker(const BInvoker&);
BInvoker &operator=(const BInvoker&);
BMessage *fMessage;
BMessenger fMessenger;
BHandler *fReplyTo;
bigtime_t fTimeout;
uint32 fNotifyKind;
uint32 _reserved[2]; // to be able to keep binary compatibility
};
//------------------------------------------------------------------------------
#endif // _INVOKER_H
/*
* $Log $
*
* $Id $
*
*/
+237
View File
@@ -0,0 +1,237 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Looper.h
// Author(s): Erik Jaesler ([email protected])
// DarkWyrm ([email protected])
// Description: BLooper class spawns a thread that runs a message loop.
//------------------------------------------------------------------------------
#ifndef _LOOPER_H
#define _LOOPER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
#include <List.h>
#include <OS.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
class BMessageQueue;
struct _loop_data_;
// Port (Message Queue) Capacity -----------------------------------------------
#define B_LOOPER_PORT_DEFAULT_CAPACITY 100
// BLooper class ---------------------------------------------------------------
class BLooper : public BHandler {
public:
BLooper(const char* name = NULL,
int32 priority = B_NORMAL_PRIORITY,
int32 port_capacity = B_LOOPER_PORT_DEFAULT_CAPACITY);
virtual ~BLooper();
// Archiving
BLooper(BMessage* data);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
// Message transmission
status_t PostMessage(uint32 command);
status_t PostMessage(BMessage* message);
status_t PostMessage(uint32 command,
BHandler* handler,
BHandler* reply_to = NULL);
status_t PostMessage(BMessage* message,
BHandler* handler,
BHandler* reply_to = NULL);
virtual void DispatchMessage(BMessage* message, BHandler* handler);
virtual void MessageReceived(BMessage* msg);
BMessage* CurrentMessage() const;
BMessage* DetachCurrentMessage();
BMessageQueue* MessageQueue() const;
bool IsMessageWaiting() const;
// Message handlers
void AddHandler(BHandler* handler);
bool RemoveHandler(BHandler* handler);
int32 CountHandlers() const;
BHandler* HandlerAt(int32 index) const;
int32 IndexOf(BHandler* handler) const;
BHandler* PreferredHandler() const;
void SetPreferredHandler(BHandler* handler);
// Loop control
virtual thread_id Run();
virtual void Quit();
virtual bool QuitRequested();
bool Lock();
void Unlock();
bool IsLocked() const;
status_t LockWithTimeout(bigtime_t timeout);
thread_id Thread() const;
team_id Team() const;
static BLooper* LooperForThread(thread_id tid);
// Loop debugging
thread_id LockingThread() const;
int32 CountLocks() const;
int32 CountLockRequests() const;
sem_id Sem() const;
// Scripting
virtual BHandler* ResolveSpecifier(BMessage* msg,
int32 index,
BMessage* specifier,
int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
// Message filters (also see BHandler).
virtual void AddCommonFilter(BMessageFilter* filter);
virtual bool RemoveCommonFilter(BMessageFilter* filter);
virtual void SetCommonFilterList(BList* filters);
BList* CommonFilterList() const;
// Private or reserved ---------------------------------------------------------
virtual status_t Perform(perform_code d, void* arg);
protected:
// called from overridden task_looper
BMessage* MessageFromPort(bigtime_t = B_INFINITE_TIMEOUT);
private:
typedef BHandler _inherited;
friend class BWindow;
friend class BApplication;
friend class BMessenger;
friend class BView;
friend class BHandler;
friend port_id _get_looper_port_(const BLooper* );
friend status_t _safe_get_server_token_(const BLooper* , int32* );
friend team_id _find_cur_team_id_();
virtual void _ReservedLooper1();
virtual void _ReservedLooper2();
virtual void _ReservedLooper3();
virtual void _ReservedLooper4();
virtual void _ReservedLooper5();
virtual void _ReservedLooper6();
BLooper(const BLooper&);
BLooper& operator=(const BLooper&);
BLooper(int32 priority, port_id port, const char* name);
status_t _PostMessage(BMessage* msg,
BHandler* handler,
BHandler* reply_to);
static status_t _Lock(BLooper* loop,
port_id port,
bigtime_t timeout);
static status_t _LockComplete(BLooper* loop,
int32 old,
thread_id this_tid,
sem_id sem,
bigtime_t timeout);
void InitData();
void InitData(const char* name, int32 prio, int32 capacity);
void AddMessage(BMessage* msg);
void _AddMessagePriv(BMessage* msg);
static status_t _task0_(void* arg);
void* ReadRawFromPort(int32* code,
bigtime_t tout = B_INFINITE_TIMEOUT);
BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT);
virtual BMessage* ConvertToMessage(void* raw, int32 code);
virtual void task_looper();
void do_quit_requested(BMessage* msg);
bool AssertLocked() const;
BHandler* top_level_filter(BMessage* msg, BHandler* t);
BHandler* handler_only_filter(BMessage* msg, BHandler* t);
BHandler* apply_filters( BList* list,
BMessage* msg,
BHandler* target);
void check_lock();
BHandler* resolve_specifier(BHandler* target, BMessage* msg);
void UnlockFully();
static uint32 sLooperID;
static uint32 sLooperListSize;
static uint32 sLooperCount;
static _loop_data_* sLooperList;
static BLocker sLooperListLock;
static team_id sTeamID;
static void AddLooper(BLooper* l);
static bool IsLooperValid(const BLooper* l);
static void RemoveLooper(BLooper* l);
static void GetLooperList(BList* list);
static BLooper* LooperForName(const char* name);
static BLooper* LooperForPort(port_id port);
uint32 fLooperID;
BMessageQueue* fQueue;
BMessage* fLastMessage;
port_id fMsgPort;
long fAtomicCount;
sem_id fLockSem;
long fOwnerCount;
thread_id fOwner;
thread_id fTaskID;
uint32 _unused1;
int32 fInitPriority;
BHandler* fPreferred;
BList fHandlers;
BList* fCommonFilters;
bool fTerminating;
bool fRunCalled;
thread_id fCachedPid;
size_t fCachedStack;
void* fMsgBuffer;
size_t fMsgBufferSize;
uint32 _reserved[6];
};
//------------------------------------------------------------------------------
#endif // _LOOPER_H
/*
* $Log $
*
* $Id $
*
*/
+126
View File
@@ -0,0 +1,126 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: MessageFilter.h
// Author: Erik Jaesler ([email protected])
// Description: BMessageFilter class creates objects that filter
// in-coming BMessages.
//------------------------------------------------------------------------------
#ifndef _MESSAGE_FILTER_H
#define _MESSAGE_FILTER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <Handler.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BMessage;
// filter_hook Return Codes and Protocol ---------------------------------------
enum filter_result {
B_SKIP_MESSAGE,
B_DISPATCH_MESSAGE
};
typedef filter_result (*filter_hook)
(BMessage* message, BHandler** target, BMessageFilter* filter);
// BMessageFilter invocation criteria ------------------------------------------
enum message_delivery {
B_ANY_DELIVERY,
B_DROPPED_DELIVERY,
B_PROGRAMMED_DELIVERY
};
enum message_source {
B_ANY_SOURCE,
B_REMOTE_SOURCE,
B_LOCAL_SOURCE
};
// BMessageFilter Class --------------------------------------------------------
class BMessageFilter {
public:
BMessageFilter( uint32 what,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
filter_hook func = NULL);
BMessageFilter( message_delivery delivery,
message_source source,
uint32 what,
filter_hook func = NULL);
BMessageFilter(const BMessageFilter& filter);
BMessageFilter(const BMessageFilter* filter);
virtual ~BMessageFilter();
BMessageFilter &operator=(const BMessageFilter& from);
// Hook function; ignored if filter_hook is non-NULL
virtual filter_result Filter(BMessage* message, BHandler** target);
message_delivery MessageDelivery() const;
message_source MessageSource() const;
uint32 Command() const;
bool FiltersAnyCommand() const;
BLooper *Looper() const;
// Private or reserved ---------------------------------------------------------
private:
friend class BLooper;
friend class BHandler;
virtual void _ReservedMessageFilter1();
virtual void _ReservedMessageFilter2();
void SetLooper(BLooper* owner);
filter_hook FilterFunction() const;
bool fFiltersAny;
uint32 what;
message_delivery fDelivery;
message_source fSource;
BLooper *fLooper;
filter_hook fFilterFunction;
uint32 _reserved[3];
};
//------------------------------------------------------------------------------
#endif // _MESSAGE_FILTER_H
/*
* $Log $
*
* $Id $
*
*/
+67
View File
@@ -0,0 +1,67 @@
//
// $Id: MessageQueue.h,v 1.1 2002/07/09 12:24:32 ejakowatz Exp $
//
// This is the BMessageQueue interface for OpenBeOS. It has been created
// to be source and binary compatible with the BeOS version of
// BMessageQueue.
//
#ifndef _OPENBEOS_MESSAGEQUEUE_H
#define _OPENBEOS_MESSAGEQUEUE_H
#include "Locker.h"
class BMessage;
#ifdef USE_OPENBEOS_NAMESPACE
namespace OpenBeOS {
#endif
class BMessageQueue {
public:
BMessageQueue();
virtual ~BMessageQueue();
void AddMessage(BMessage *message);
void RemoveMessage(BMessage *message);
int32 CountMessages(void) const;
bool IsEmpty(void) const;
BMessage *FindMessage(int32 index) const;
BMessage *FindMessage(uint32 what, int32 index=0) const;
bool Lock(void);
void Unlock(void);
bool IsLocked(void);
BMessage *NextMessage(void);
private:
// Reserved space in the vtable for future changes to BMessageQueue
virtual void _ReservedMessageQueue1(void);
virtual void _ReservedMessageQueue2(void);
virtual void _ReservedMessageQueue3(void);
BMessageQueue(const BMessageQueue &);
BMessageQueue &operator=(const BMessageQueue &);
BMessage *fTheQueue;
BMessage *fQueueTail;
int32 fMessageCount;
BLocker fLocker;
// Reserved space for future changes to BMessageQueue
uint32 fReservedSpace[3];
};
#ifdef USE_OPENBEOS_NAMESPACE
}
#endif
#endif // _OPENBEOS_MESSAGEQUEUE_H
+62
View File
@@ -0,0 +1,62 @@
/******************************************************************************
/
/ File: MessageRunner.h
/
/ Description:
/
/ Copyright 1998, Be Incorporated, All Rights Reserved.
/
*******************************************************************************/
#ifndef _MESSAGE_RUNNER_H
#define _MESSAGE_RUNNER_H
#include <BeBuild.h>
#include <Messenger.h>
/*----------------------------------------------------------------------*/
/*----- BMessageRunner class --------------------------------------------*/
class BMessageRunner {
public:
BMessageRunner(BMessenger target, const BMessage *msg,
bigtime_t interval, int32 count = -1);
BMessageRunner(BMessenger target, const BMessage *msg,
bigtime_t interval, int32 count, BMessenger reply_to);
virtual ~BMessageRunner();
status_t InitCheck() const;
status_t SetInterval(bigtime_t interval);
status_t SetCount(int32 count);
status_t GetInfo(bigtime_t *interval, int32 *count) const;
/*----- Private or reserved -----------------------------------------*/
private:
virtual void _ReservedMessageRunner1();
virtual void _ReservedMessageRunner2();
virtual void _ReservedMessageRunner3();
virtual void _ReservedMessageRunner4();
virtual void _ReservedMessageRunner5();
virtual void _ReservedMessageRunner6();
BMessageRunner(const BMessageRunner &);
BMessageRunner &operator=(const BMessageRunner &);
void InitData(BMessenger target, const BMessage *msg,
bigtime_t interval, int32 count, BMessenger reply_to);
status_t SetParams(bool reset_i, bigtime_t interval,
bool reset_c, int32 count);
int32 fToken;
uint32 _reserved[6];
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _MESSAGE_QUEUE_H */
+116
View File
@@ -0,0 +1,116 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2002, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Messenger.h
// Author: Ingo Weinhold ([email protected])
// Description: BMessenger delivers messages to local or remote targets.
//------------------------------------------------------------------------------
#ifndef _MESSENGER_H
#define _MESSENGER_H
// Standard Includes -----------------------------------------------------------
// System Includes -------------------------------------------------------------
#include <BeBuild.h>
#include <OS.h>
#include <ByteOrder.h>
#include <Message.h>
// Project Includes ------------------------------------------------------------
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
class BHandler;
class BLooper;
// BMessenger class ------------------------------------------------------------
class BMessenger {
public:
BMessenger();
BMessenger(const char *signature, team_id team = -1,
status_t *result = NULL);
BMessenger(const BHandler *handler, const BLooper *looper = NULL,
status_t *result = NULL);
BMessenger(const BMessenger &from);
~BMessenger();
// Target
bool IsTargetLocal() const;
BHandler *Target(BLooper **looper) const;
bool LockTarget() const;
status_t LockTargetWithTimeout(bigtime_t timeout) const;
// Message sending
status_t SendMessage(uint32 command, BHandler *replyTo = NULL) const;
status_t SendMessage(BMessage *message, BHandler *replyTo = NULL,
bigtime_t timeout = B_INFINITE_TIMEOUT) const;
status_t SendMessage(BMessage *message, BMessenger replyTo,
bigtime_t timeout = B_INFINITE_TIMEOUT) const;
status_t SendMessage(uint32 command, BMessage *reply) const;
status_t SendMessage(BMessage *message, BMessage *reply,
bigtime_t deliveryTimeout = B_INFINITE_TIMEOUT,
bigtime_t replyTimeout = B_INFINITE_TIMEOUT) const;
// Operators and misc
BMessenger &operator=(const BMessenger &from);
bool operator==(const BMessenger &other) const;
bool IsValid() const;
team_id Team() const;
//----- Private or reserved -----------------------------------------
private:
friend class BRoster;
friend class _TRoster_;
friend class BMessage;
friend inline void _set_message_reply_(BMessage *, BMessenger);
friend status_t swap_data(type_code, void *, size_t, swap_action);
friend bool operator<(const BMessenger &a, const BMessenger &b);
friend bool operator!=(const BMessenger &a, const BMessenger &b);
BMessenger(team_id team, port_id port, int32 token, bool preferred);
void InitData(const char *signature, team_id team, status_t *result);
private:
port_id fPort;
int32 fHandlerToken;
team_id fTeam;
int32 extra0;
int32 extra1;
bool fPreferredTarget;
bool extra2;
bool extra3;
bool extra4;
};
_IMPEXP_BE bool operator<(const BMessenger &a, const BMessenger &b);
_IMPEXP_BE bool operator!=(const BMessenger &a, const BMessenger &b);
#endif // _MESSENGER_H
+134
View File
@@ -0,0 +1,134 @@
/*******************************************************************************
/
/ File: PropertyInfo.h
/
/ Description: Utility class for maintain scripting information
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#ifndef _PROPERTY_INFO_H
#define _PROPERTY_INFO_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Flattenable.h>
#include <TypeConstants.h> /* For convenience */
/*----------------------------------------------------------------*/
/*----- the property_info structure ------------------------------*/
struct _oproperty_info_;
struct compound_type {
struct field_pair {
char *name; // name of entry in message
type_code type; // type_code of entry in message
};
field_pair pairs[5];
};
struct property_info {
char *name;
uint32 commands[10];
uint32 specifiers[10];
char *usage;
uint32 extra_data;
uint32 types[10];
compound_type ctypes[3];
uint32 _reserved[10];
};
enum value_kind {
B_COMMAND_KIND = 0,
B_TYPE_CODE_KIND = 1
};
struct value_info {
char *name;
uint32 value;
value_kind kind;
char *usage;
uint32 extra_data;
uint32 _reserved[10];
};
#define B_PROPERTY_INFO_TYPE 'SCTD'
/*----------------------------------------------------------------*/
/*----- BPropertyInfo class --------------------------------------*/
class BPropertyInfo : public BFlattenable {
public:
BPropertyInfo(property_info *p = NULL,
value_info *ci = NULL,
bool free_on_delete = false);
virtual ~BPropertyInfo();
virtual int32 FindMatch(BMessage *msg,
int32 index,
BMessage *spec,
int32 form,
const char *prop,
void *data = NULL) const;
virtual bool IsFixedSize() const;
virtual type_code TypeCode() const;
virtual ssize_t FlattenedSize() const;
virtual status_t Flatten(void *buffer, ssize_t size) const;
virtual bool AllowsTypeCode(type_code code) const;
virtual status_t Unflatten(type_code c,
const void *buf,
ssize_t s);
const property_info *Properties() const;
const value_info *Values() const;
int32 CountProperties() const;
int32 CountValues() const;
void PrintToStream() const;
/*----- Private or reserved -----------------------------------------*/
protected:
static bool FindCommand(uint32, int32, property_info *);
static bool FindSpecifier(uint32, property_info *);
private:
virtual void _ReservedPropertyInfo1();
virtual void _ReservedPropertyInfo2();
virtual void _ReservedPropertyInfo3();
virtual void _ReservedPropertyInfo4();
BPropertyInfo(const BPropertyInfo &);
BPropertyInfo &operator=(const BPropertyInfo &);
void FreeMem();
void FreeInfoArray(property_info *p, int32);
void FreeInfoArray(value_info *p, int32);
void FreeInfoArray(_oproperty_info_ *p, int32);
static property_info *ConvertToNew(const _oproperty_info_ *p);
static _oproperty_info_ *ConvertFromNew(const property_info *p);
property_info *fPropInfo;
value_info *fValueInfo;
int32 fPropCount;
bool fInHeap;
bool fOldInHeap;
uint16 fValueCount;
_oproperty_info_ *fOldPropInfo;
uint32 _reserved[2]; /* was 4 */
/* Deprecated */
private:
const property_info *PropertyInfo() const;
BPropertyInfo(property_info *p,
bool free_on_delete);
static bool MatchCommand(uint32, int32, property_info *);
static bool MatchSpecifier(uint32, property_info *);
};
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif /* _PROPERTY_INFO_H */
+227
View File
@@ -0,0 +1,227 @@
/******************************************************************************
/
/ File: Roster.h
/
/ Description: BRoster class lets you launch apps and keeps
/ track of apps that are running.
/ Global be_roster represents the default BRoster.
/ app_info structure provides info for a running app.
/
/ Copyright 1995-98, Be Incorporated, All Rights Reserved.
/
******************************************************************************/
#ifndef _ROSTER_H
#define _ROSTER_H
#include <BeBuild.h>
#include <Messenger.h>
#include <Mime.h>
#include <Clipboard.h>
class BList;
class BMessage;
class BNodeInfo;
extern "C" int _init_roster_();
/*-------------------------------------------------------------*/
/* --------- app_info Struct and Values ------------------------ */
struct app_info {
app_info();
~app_info();
thread_id thread;
team_id team;
port_id port;
uint32 flags;
entry_ref ref;
char signature[B_MIME_TYPE_LENGTH];
};
#define B_LAUNCH_MASK (0x3)
#define B_SINGLE_LAUNCH (0x0)
#define B_MULTIPLE_LAUNCH (0x1)
#define B_EXCLUSIVE_LAUNCH (0x2)
#define B_BACKGROUND_APP (0x4)
#define B_ARGV_ONLY (0x8)
#define _B_APP_INFO_RESERVED1_ (0x10000000)
enum {
B_REQUEST_LAUNCHED = 0x00000001,
B_REQUEST_QUIT = 0x00000002,
B_REQUEST_ACTIVATED = 0x00000004
};
enum {
B_SOME_APP_LAUNCHED = 'BRAS',
B_SOME_APP_QUIT = 'BRAQ',
B_SOME_APP_ACTIVATED = 'BRAW'
};
/*-------------------------------------------------------------*/
/* --------- BRoster class----------------------------------- */
class BRoster {
public:
BRoster();
~BRoster();
/* Querying for apps */
bool IsRunning(const char *mime_sig) const;
bool IsRunning(entry_ref *ref) const;
team_id TeamFor(const char *mime_sig) const;
team_id TeamFor(entry_ref *ref) const;
void GetAppList(BList *team_id_list) const;
void GetAppList(const char *sig, BList *team_id_list) const;
status_t GetAppInfo(const char *sig, app_info *info) const;
status_t GetAppInfo(entry_ref *ref, app_info *info) const;
status_t GetRunningAppInfo(team_id team, app_info *info) const;
status_t GetActiveAppInfo(app_info *info) const;
status_t FindApp(const char *mime_type, entry_ref *app) const;
status_t FindApp(entry_ref *ref, entry_ref *app) const;
/* Launching, activating, and broadcasting to apps */
status_t Broadcast(BMessage *msg) const;
status_t Broadcast(BMessage *msg, BMessenger reply_to) const;
status_t StartWatching(BMessenger target,
uint32 event_mask = B_REQUEST_LAUNCHED | B_REQUEST_QUIT) const;
status_t StopWatching(BMessenger target) const;
status_t ActivateApp(team_id team) const;
status_t Launch(const char *mime_type, BMessage *initial_msgs = NULL,
team_id *app_team = NULL) const;
status_t Launch(const char *mime_type, BList *message_list,
team_id *app_team = NULL) const;
status_t Launch(const char *mime_type, int argc, char **args,
team_id *app_team = NULL) const;
status_t Launch(const entry_ref *ref, const BMessage *initial_message = NULL,
team_id *app_team = NULL) const;
status_t Launch(const entry_ref *ref, const BList *message_list,
team_id *app_team = NULL) const;
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *app_team = NULL) const;
/* Recent document and app support */
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *ofType = NULL,
const char *openedByAppSig = NULL) const;
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *ofTypeList[], int32 ofTypeListCount,
const char *openedByAppSig = NULL) const;
void GetRecentFolders(BMessage *refList, int32 maxCount,
const char *openedByAppSig = NULL) const;
void GetRecentApps(BMessage *refList, int32 maxCount) const;
void AddToRecentDocuments(const entry_ref *doc,
const char *appSig = NULL) const;
void AddToRecentFolders(const entry_ref *folder,
const char *appSig = NULL) const;
/*----- Private or reserved ------------------------------*/
private:
friend class BApplication;
friend class BWindow;
friend class _BAppCleanup_;
friend int _init_roster_();
friend status_t _send_to_roster_(BMessage *, BMessage *, bool);
friend bool _is_valid_roster_mess_(bool);
friend status_t BMimeType::StartWatching(BMessenger);
friend status_t BMimeType::StopWatching(BMessenger);
friend status_t BClipboard::StartWatching(BMessenger);
friend status_t BClipboard::StopWatching(BMessenger);
enum mtarget {
MAIN_MESSENGER,
MIME_MESSENGER,
USE_GIVEN
};
status_t _StartWatching(mtarget t, BMessenger *roster_mess, uint32 what,
BMessenger notify, uint32 event_mask) const;
status_t _StopWatching(mtarget t, BMessenger *roster_mess, uint32 what,
BMessenger notify) const;
uint32 AddApplication( const char *mime_sig,
entry_ref *ref,
uint32 flags,
team_id team,
thread_id thread,
port_id port,
bool full_reg) const;
void SetSignature(team_id team, const char *mime_sig) const;
void SetThread(team_id team, thread_id tid) const;
void SetThreadAndTeam(uint32 entry_token,
thread_id tid,
team_id team) const;
void CompleteRegistration(team_id team,
thread_id,
port_id port) const;
bool IsAppPreRegistered( entry_ref *ref,
team_id team,
app_info *info) const;
void RemovePreRegApp(uint32 entry_token) const;
void RemoveApp(team_id team) const;
status_t xLaunchAppPrivate( const char *mime_sig,
const entry_ref *ref,
BList* msg_list,
int cargs,
char **args,
team_id *app_team) const;
bool UpdateActiveApp(team_id team) const;
void SetAppFlags(team_id team, uint32 flags) const;
void DumpRoster() const;
status_t resolve_app(const char *in_type,
const entry_ref *ref,
entry_ref *app_ref,
char *app_sig,
uint32 *app_flags,
bool *was_document) const;
status_t translate_ref(const entry_ref *ref,
BMimeType *app_meta,
entry_ref *app_ref,
BFile *app_file,
char *app_sig,
bool *was_document) const;
status_t translate_type(const char *mime_type,
BMimeType *meta,
entry_ref *app_ref,
BFile *app_file,
char *app_sig) const;
status_t sniff_file(const entry_ref *file,
BNodeInfo *finfo,
char *mime_type) const;
bool is_wildcard(const char *sig) const;
status_t get_unique_supporting_app(const BMessage *apps,
char *out_sig) const;
status_t get_random_supporting_app(const BMessage *apps,
char *out_sig) const;
char **build_arg_vector(char **args, int *pargs,
const entry_ref *app_ref,
const entry_ref *doc_ref) const;
status_t send_to_running(team_id tema,
const entry_ref *app_ref,
int cargs, char **args,
const BList *msg_list,
const entry_ref *ref) const;
void InitMessengers();
BMessenger fMess;
BMessenger fMimeMess;
uint32 _fReserved[3];
};
/*-----------------------------------------------------*/
/*----- Global be_roster ------------------------------*/
extern _IMPEXP_BE const BRoster *be_roster;
/*-----------------------------------------------------*/
/*-----------------------------------------------------*/
#endif /* _ROSTER_H */