git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16430 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-02-16 17:37:36 +00:00
parent 8242ac7f2f
commit eb797182df
4 changed files with 327 additions and 339 deletions
+107 -128
View File
@@ -1,39 +1,19 @@
//------------------------------------------------------------------------------
// 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: Roster.h
// Author: Ingo Weinhold ([email protected])
// 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 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold ([email protected])
*/
#ifndef _ROSTER_H
#define _ROSTER_H
#include <Entry.h>
#include <Messenger.h>
#include <OS.h>
// app_info
struct app_info {
app_info();
~app_info();
@@ -71,125 +51,124 @@ enum {
class BList;
// BRoster
class BRoster {
public:
BRoster();
~BRoster();
public:
BRoster();
~BRoster();
// running apps
bool IsRunning(const char *mimeSig) const;
bool IsRunning(entry_ref *ref) const;
team_id TeamFor(const char *mimeSig) const;
team_id TeamFor(entry_ref *ref) const;
void GetAppList(BList *teamIDList) const;
void GetAppList(const char *sig, BList *teamIDList) const;
// running apps
bool IsRunning(const char *mimeSig) const;
bool IsRunning(entry_ref *ref) const;
team_id TeamFor(const char *mimeSig) const;
team_id TeamFor(entry_ref *ref) const;
void GetAppList(BList *teamIDList) const;
void GetAppList(const char *sig, BList *teamIDList) const;
// app infos
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;
// app infos
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;
// find app
status_t FindApp(const char *mimeType, entry_ref *app) const;
status_t FindApp(entry_ref *ref, entry_ref *app) const;
// find app
status_t FindApp(const char *mimeType, entry_ref *app) const;
status_t FindApp(entry_ref *ref, entry_ref *app) const;
// broadcast
status_t Broadcast(BMessage *message) const;
status_t Broadcast(BMessage *message, BMessenger replyTo) const;
// broadcast
status_t Broadcast(BMessage *message) const;
status_t Broadcast(BMessage *message, BMessenger replyTo) const;
// watching
status_t StartWatching(BMessenger target,
uint32 eventMask = B_REQUEST_LAUNCHED
| B_REQUEST_QUIT) const;
status_t StopWatching(BMessenger target) const;
// watching
status_t StartWatching(BMessenger target,
uint32 eventMask = B_REQUEST_LAUNCHED | B_REQUEST_QUIT) const;
status_t StopWatching(BMessenger target) const;
status_t ActivateApp(team_id team) const;
status_t ActivateApp(team_id team) const;
// launch app
status_t Launch(const char *mimeType, BMessage *initialMessage = 0,
// launch app
status_t Launch(const char *mimeType, BMessage *initialMessage = 0,
team_id *appTeam = 0) const;
status_t Launch(const char *mimeType, BList *messageList,
status_t Launch(const char *mimeType, BList *messageList,
team_id *appTeam = 0) const;
status_t Launch(const char *mimeType, int argc, char **args,
status_t Launch(const char *mimeType, int argc, char **args,
team_id *appTeam = 0) const;
status_t Launch(const entry_ref *ref, const BMessage *initialMessage = 0,
status_t Launch(const entry_ref *ref, const BMessage *initialMessage = 0,
team_id *appTeam = 0) const;
status_t Launch(const entry_ref *ref, const BList *messageList,
status_t Launch(const entry_ref *ref, const BList *messageList,
team_id *appTeam = 0) const;
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
status_t Launch(const entry_ref *ref, int argc, const char * const *args,
team_id *appTeam = 0) const;
// recent documents, folders, apps
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *fileType = 0,
const char *appSig = 0) const;
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *fileTypes[], int32 fileTypesCount,
const char *appSig = 0) const;
void GetRecentFolders(BMessage *refList, int32 maxCount,
const char *appSig = 0) const;
void GetRecentApps(BMessage *refList, int32 maxCount) const;
void AddToRecentDocuments(const entry_ref *doc,
const char *appSig = 0) const;
void AddToRecentFolders(const entry_ref *folder,
const char *appSig = 0) const;
// recent documents, folders, apps
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *fileType = 0,
const char *appSig = 0) const;
void GetRecentDocuments(BMessage *refList, int32 maxCount,
const char *fileTypes[], int32 fileTypesCount,
const char *appSig = 0) const;
void GetRecentFolders(BMessage *refList, int32 maxCount,
const char *appSig = 0) const;
void GetRecentApps(BMessage *refList, int32 maxCount) const;
void AddToRecentDocuments(const entry_ref *doc,
const char *appSig = 0) const;
void AddToRecentFolders(const entry_ref *folder,
const char *appSig = 0) const;
// private/reserved stuff starts here
class Private;
// private/reserved stuff starts here
class Private;
private:
class ArgVector;
friend class Private;
private:
class ArgVector;
friend class Private;
status_t ShutDown(bool reboot, bool confirm, bool synchronous);
status_t _ShutDown(bool reboot, bool confirm, bool synchronous);
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
uint32 flags, team_id team, thread_id thread,
port_id port, bool fullReg, uint32 *pToken,
team_id *otherTeam) const;
status_t SetSignature(team_id team, const char *mimeSig) const;
void SetThread(team_id team, thread_id thread) const;
status_t SetThreadAndTeam(uint32 entryToken, thread_id thread,
team_id team) const;
status_t CompleteRegistration(team_id team, thread_id thread,
port_id port) const;
bool IsAppPreRegistered(const entry_ref *ref, team_id team,
app_info *info) const;
status_t RemovePreRegApp(uint32 entryToken) const;
status_t RemoveApp(team_id team) const;
status_t xLaunchAppPrivate(const char *mimeType, const entry_ref *ref,
const BList *messageList, int argc,
const char *const *args,
team_id *appTeam) const;
bool UpdateActiveApp(team_id team) const;
void SetAppFlags(team_id team, uint32 flags) const;
void DumpRoster() const;
status_t resolve_app(const char *inType, entry_ref *ref, entry_ref *appRef,
char *appSig, uint32 *appFlags,
bool *wasDocument) const;
status_t translate_ref(entry_ref *ref, BMimeType *appMeta,
entry_ref *appRef, BFile *appFile,
bool *wasDocument) const;
status_t translate_type(const char *mimeType, BMimeType *appMeta,
entry_ref *appRef, BFile *appFile) const;
status_t sniff_file(const entry_ref *file, BNodeInfo *nodeInfo,
char *mimeType) const;
status_t send_to_running(team_id team, int argc, const char *const *args,
const BList *messageList, const entry_ref *ref,
bool readyToRun) const;
void InitMessengers();
void AddToRecentApps(const char *appSig) const;
void ClearRecentDocuments() const;
void ClearRecentFolders() const;
void ClearRecentApps() const;
void LoadRecentLists(const char *filename) const;
void SaveRecentLists(const char *filename) const;
status_t _AddApplication(const char *mimeSig, const entry_ref *ref,
uint32 flags, team_id team, thread_id thread,
port_id port, bool fullReg, uint32 *pToken,
team_id *otherTeam) const;
status_t _SetSignature(team_id team, const char *mimeSig) const;
void _SetThread(team_id team, thread_id thread) const;
status_t _SetThreadAndTeam(uint32 entryToken, thread_id thread,
team_id team) const;
status_t _CompleteRegistration(team_id team, thread_id thread,
port_id port) const;
bool _IsAppPreRegistered(const entry_ref *ref, team_id team,
app_info *info) const;
status_t _RemovePreRegApp(uint32 entryToken) const;
status_t _RemoveApp(team_id team) const;
status_t _LaunchApp(const char *mimeType, const entry_ref *ref,
const BList *messageList, int argc,
const char *const *args,
team_id *appTeam) const;
bool _UpdateActiveApp(team_id team) const;
void _SetAppFlags(team_id team, uint32 flags) const;
void _DumpRoster() const;
status_t _ResolveApp(const char *inType, entry_ref *ref, entry_ref *appRef,
char *appSig, uint32 *appFlags,
bool *wasDocument) const;
status_t _TranslateRef(entry_ref *ref, BMimeType *appMeta,
entry_ref *appRef, BFile *appFile,
bool *wasDocument) const;
status_t _TranslateType(const char *mimeType, BMimeType *appMeta,
entry_ref *appRef, BFile *appFile) const;
status_t _SniffFile(const entry_ref *file, BNodeInfo *nodeInfo,
char *mimeType) const;
status_t _SendToRunning(team_id team, int argc, const char *const *args,
const BList *messageList, const entry_ref *ref,
bool readyToRun) const;
void _InitMessengers();
void _AddToRecentApps(const char *appSig) const;
void _ClearRecentDocuments() const;
void _ClearRecentFolders() const;
void _ClearRecentApps() const;
void _LoadRecentLists(const char *filename) const;
void _SaveRecentLists(const char *filename) const;
BMessenger fMess;
BMessenger fMimeMess;
uint32 _reserved[3];
BMessenger fMessenger;
BMessenger fMimeMessenger;
uint32 _reserved[3];
};
// global BRoster instance
+52 -48
View File
@@ -1,76 +1,80 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
/*
* Copyright 2001-2006, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold ([email protected])
*/
#ifndef _ROSTER_PRIVATE_H
#define _ROSTER_PRIVATE_H
#include <Messenger.h>
#include <Roster.h>
class BRoster::Private {
public:
Private() : fRoster(const_cast<BRoster*>(be_roster)) {}
Private(BRoster &roster) : fRoster(&roster) {}
Private(BRoster *roster) : fRoster(roster) {}
public:
Private() : fRoster(const_cast<BRoster*>(be_roster)) {}
Private(BRoster &roster) : fRoster(&roster) {}
Private(BRoster *roster) : fRoster(roster) {}
void SetTo(BMessenger mainMessenger, BMessenger mimeMessenger);
void SetTo(BMessenger mainMessenger, BMessenger mimeMessenger);
status_t SendTo(BMessage *message, BMessage *reply, bool mime);
bool IsMessengerValid(bool mime) const;
status_t SendTo(BMessage *message, BMessage *reply, bool mime);
bool IsMessengerValid(bool mime) const;
status_t ShutDown(bool reboot, bool confirm, bool synchronous)
{ return fRoster->ShutDown(reboot, confirm, synchronous); }
status_t ShutDown(bool reboot, bool confirm, bool synchronous)
{ return fRoster->_ShutDown(reboot, confirm, synchronous); }
// needed by BApplication
// needed by BApplication
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
uint32 flags, team_id team, thread_id thread,
port_id port, bool fullReg, uint32 *token,
team_id *otherTeam) const
{ return fRoster->AddApplication(mimeSig, ref, flags, team, thread,
port, fullReg, token, otherTeam); }
status_t AddApplication(const char *mimeSig, const entry_ref *ref,
uint32 flags, team_id team, thread_id thread,
port_id port, bool fullReg, uint32 *token,
team_id *otherTeam) const
{ return fRoster->_AddApplication(mimeSig, ref, flags, team, thread,
port, fullReg, token, otherTeam); }
status_t SetSignature(team_id team, const char *mimeSig) const
{ return fRoster->SetSignature(team, mimeSig); }
status_t SetSignature(team_id team, const char *mimeSig) const
{ return fRoster->_SetSignature(team, mimeSig); }
status_t CompleteRegistration(team_id team, thread_id thread,
port_id port) const
{ return fRoster->CompleteRegistration(team, thread, port); }
status_t CompleteRegistration(team_id team, thread_id thread,
port_id port) const
{ return fRoster->_CompleteRegistration(team, thread, port); }
bool IsAppPreRegistered(const entry_ref *ref, team_id team,
app_info *info) const
{ return fRoster->IsAppPreRegistered(ref, team, info); }
bool IsAppPreRegistered(const entry_ref *ref, team_id team,
app_info *info) const
{ return fRoster->_IsAppPreRegistered(ref, team, info); }
status_t RemoveApp(team_id team) const
{ return fRoster->RemoveApp(team); }
status_t RemoveApp(team_id team) const
{ return fRoster->_RemoveApp(team); }
// needed by GetRecentTester
// needed by GetRecentTester
void AddToRecentApps(const char *appSig) const
{ fRoster->AddToRecentApps(appSig); }
void AddToRecentApps(const char *appSig) const
{ fRoster->_AddToRecentApps(appSig); }
void ClearRecentDocuments() const
{ fRoster->ClearRecentDocuments(); }
void ClearRecentDocuments() const
{ fRoster->_ClearRecentDocuments(); }
void ClearRecentFolders() const
{ fRoster->ClearRecentFolders(); }
void ClearRecentFolders() const
{ fRoster->_ClearRecentFolders(); }
void ClearRecentApps() const
{ fRoster->ClearRecentApps(); }
void ClearRecentApps() const
{ fRoster->_ClearRecentApps(); }
void LoadRecentLists(const char *file) const
{ fRoster->LoadRecentLists(file); }
void LoadRecentLists(const char *file) const
{ fRoster->_LoadRecentLists(file); }
void SaveRecentLists(const char *file) const
{ fRoster->SaveRecentLists(file); }
void SaveRecentLists(const char *file) const
{ fRoster->_SaveRecentLists(file); }
static void InitBeRoster();
static void DeleteBeRoster();
static void InitBeRoster();
static void DeleteBeRoster();
private:
BRoster *fRoster;
private:
BRoster *fRoster;
};
#endif // _ROSTER_PRIVATE_H