From ac39aae2625a094bebca0161281b2d8534bab361 Mon Sep 17 00:00:00 2001
From: Owen <owenca@users.noreply.github.com>
Date: Sun, 3 Dec 2017 23:51:07 +0000
Subject: [PATCH 2/2] Accepts URLs as command line arguments.
Fixes #9793
---
src/apps/mediaplayer/MainApp.cpp | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/apps/mediaplayer/MainApp.cpp b/src/apps/mediaplayer/MainApp.cpp
index d61e8e9..af37a1b 100644
a
|
b
|
MainApp::ArgvReceived(int32 argc, char** argv)
|
229 | 229 | char cwd[B_PATH_NAME_LENGTH]; |
230 | 230 | getcwd(cwd, sizeof(cwd)); |
231 | 231 | |
232 | | BMessage message(B_REFS_RECEIVED); |
233 | | |
234 | 232 | for (int i = 1; i < argc; i++) { |
| 233 | BUrl url(argv[i]); |
| 234 | if (url.IsValid()) { |
| 235 | BMessage archivedUrl; |
| 236 | url.Archive(&archivedUrl); |
| 237 | |
| 238 | BMessage msg(M_URL_RECEIVED); |
| 239 | if (msg.AddMessage("mediaplayer:url", &archivedUrl) == B_OK) |
| 240 | RefsReceived(&msg); |
| 241 | |
| 242 | continue; |
| 243 | } |
| 244 | |
235 | 245 | BPath path; |
236 | 246 | if (argv[i][0] != '/') |
237 | 247 | path.SetTo(cwd, argv[i]); |
… |
… |
MainApp::ArgvReceived(int32 argc, char** argv)
|
241 | 251 | if (!entry.Exists() || !entry.IsFile()) |
242 | 252 | continue; |
243 | 253 | |
| 254 | BMessage message(B_REFS_RECEIVED); |
244 | 255 | entry_ref ref; |
245 | | if (entry.GetRef(&ref) == B_OK) |
246 | | message.AddRef("refs", &ref); |
| 256 | if (entry.GetRef(&ref) == B_OK && message.AddRef("refs", &ref) == B_OK) |
| 257 | RefsReceived(&message); |
247 | 258 | } |
248 | | |
249 | | if (message.HasRef("refs")) |
250 | | RefsReceived(&message); |
251 | 259 | } |
252 | 260 | |
253 | 261 | |