2 * Copyright 2001-2015 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
10 #include <Messenger.h>
27 char signature
[B_MIME_TYPE_LENGTH
];
31 #define B_SINGLE_LAUNCH (0x0)
32 #define B_MULTIPLE_LAUNCH (0x1)
33 #define B_EXCLUSIVE_LAUNCH (0x2)
34 #define B_LAUNCH_MASK (0x3)
35 #define B_BACKGROUND_APP (0x4)
36 #define B_ARGV_ONLY (0x8)
37 #define _B_APP_INFO_RESERVED1_ (0x10000000)
39 // watching request flags
41 B_REQUEST_LAUNCHED
= 0x00000001,
42 B_REQUEST_QUIT
= 0x00000002,
43 B_REQUEST_ACTIVATED
= 0x00000004,
46 // notification message "what"
48 B_SOME_APP_LAUNCHED
= 'BRAS',
49 B_SOME_APP_QUIT
= 'BRAQ',
50 B_SOME_APP_ACTIVATED
= 'BRAW',
62 bool IsRunning(const char* signature
) const;
63 bool IsRunning(entry_ref
* ref
) const;
65 team_id
TeamFor(const char* signature
) const;
66 team_id
TeamFor(entry_ref
* ref
) const;
68 void GetAppList(BList
* teamIDList
) const;
69 void GetAppList(const char* signature
,
70 BList
* teamIDList
) const;
73 status_t
GetAppInfo(const char* signature
,
74 app_info
* info
) const;
75 status_t
GetAppInfo(entry_ref
* ref
,
76 app_info
* info
) const;
78 status_t
GetRunningAppInfo(team_id team
,
79 app_info
* info
) const;
80 status_t
GetActiveAppInfo(app_info
* info
) const;
83 status_t
FindApp(const char* mimeType
,
84 entry_ref
* app
) const;
85 status_t
FindApp(entry_ref
* ref
, entry_ref
* app
) const;
88 status_t
Broadcast(BMessage
* message
) const;
89 status_t
Broadcast(BMessage
* message
,
90 BMessenger replyTo
) const;
93 status_t
StartWatching(BMessenger target
,
96 | B_REQUEST_QUIT
) const;
97 status_t
StopWatching(BMessenger target
) const;
99 status_t
ActivateApp(team_id team
) const;
102 status_t
Launch(const char* mimeType
,
103 BMessage
* initialMessage
= NULL
,
104 team_id
* _appTeam
= NULL
) const;
105 status_t
Launch(const char* mimeType
, BList
* messageList
,
106 team_id
* _appTeam
= NULL
) const;
107 status_t
Launch(const char* mimeType
, int argc
,
108 const char* const* args
,
109 team_id
* _appTeam
= NULL
) const;
110 status_t
Launch(const entry_ref
* ref
,
111 const BMessage
* initialMessage
= NULL
,
112 team_id
* _appTeam
= NULL
) const;
113 status_t
Launch(const entry_ref
* ref
,
114 const BList
* messageList
,
115 team_id
* _appTeam
= NULL
) const;
116 status_t
Launch(const entry_ref
* ref
, int argc
,
117 const char* const* args
,
118 team_id
* _appTeam
= NULL
) const;
120 // recent documents, folders, apps
121 void GetRecentDocuments(BMessage
* refList
,
122 int32 maxCount
, const char* fileType
= NULL
,
123 const char* signature
= NULL
) const;
124 void GetRecentDocuments(BMessage
* refList
,
125 int32 maxCount
, const char* fileTypes
[],
126 int32 fileTypesCount
,
127 const char* signature
= NULL
) const;
129 void GetRecentFolders(BMessage
* refList
,
131 const char* signature
= NULL
) const;
133 void GetRecentApps(BMessage
* refList
,
134 int32 maxCount
) const;
136 void AddToRecentDocuments(const entry_ref
* document
,
137 const char* signature
= NULL
) const;
138 void AddToRecentFolders(const entry_ref
* folder
,
139 const char* signature
= NULL
) const;
141 // private/reserved stuff starts here
146 friend class Private
;
148 status_t
_ShutDown(bool reboot
, bool confirm
,
151 status_t
_AddApplication(const char* signature
,
152 const entry_ref
* ref
, uint32 flags
,
153 team_id team
, thread_id thread
,
154 port_id port
, bool fullRegistration
,
155 uint32
* pToken
, team_id
* otherTeam
) const;
157 status_t
_SetSignature(team_id team
,
158 const char* signature
) const;
160 void _SetThread(team_id team
,
161 thread_id thread
) const;
163 status_t
_SetThreadAndTeam(uint32 entryToken
,
164 thread_id thread
, team_id team
,
165 port_id
* _port
) const;
167 status_t
_CompleteRegistration(team_id team
,
168 thread_id thread
, port_id port
) const;
170 bool _IsAppPreRegistered(const entry_ref
* ref
,
171 team_id team
, app_info
* info
) const;
173 status_t
_IsAppRegistered(const entry_ref
* ref
,
174 team_id team
, uint32 token
,
175 bool* preRegistered
, app_info
* info
) const;
177 status_t
_RemovePreRegApp(uint32 entryToken
) const;
178 status_t
_RemoveApp(team_id team
) const;
180 void _ApplicationCrashed(team_id team
);
182 status_t
_LaunchApp(const char* mimeType
,
183 const entry_ref
* ref
,
184 const BList
* messageList
, int argc
,
185 const char* const* args
,
186 const char** environment
,
187 team_id
* _appTeam
, thread_id
* _appThread
,
188 port_id
* _appPort
, uint32
* _appToken
,
189 bool launchSuspended
) const;
191 status_t
_UpdateActiveApp(team_id team
) const;
193 void _SetAppFlags(team_id team
, uint32 flags
) const;
195 void _DumpRoster() const;
197 status_t
_ResolveApp(const char* inType
, entry_ref
* ref
,
201 bool* wasDocument
) const;
203 status_t
_TranslateRef(entry_ref
* ref
,
204 BMimeType
* appMeta
, entry_ref
* appRef
,
205 BFile
* appFile
, bool* wasDocument
) const;
207 status_t
_TranslateType(const char* mimeType
,
208 BMimeType
* appMeta
, entry_ref
* appRef
,
209 BFile
* appFile
) const;
211 status_t
_GetFileType(const entry_ref
* file
,
212 BNodeInfo
* nodeInfo
, char* mimeType
) const;
213 status_t
_SendToRunning(team_id team
, int argc
,
214 const char* const* args
,
215 const BList
* messageList
,
216 const entry_ref
* ref
,
217 bool readyToRun
) const;
219 void _SetWithoutRegistrar(bool noRegistrar
);
221 void _InitMessenger();
223 static status_t
_InitMimeMessenger(void* data
);
225 BMessenger
& _MimeMessenger();
227 void _AddToRecentApps(const char* signature
) const;
229 void _ClearRecentDocuments() const;
230 void _ClearRecentFolders() const;
231 void _ClearRecentApps() const;
232 void _LoadRecentLists(const char* filename
) const;
233 void _SaveRecentLists(const char* filename
) const;
235 BMessenger fMessenger
;
236 BMessenger fMimeMessenger
;
237 int32 fMimeMessengerInitOnce
;
242 // global BRoster instance
243 extern const BRoster
* be_roster
;