Launch URLs via BUrl class. Rearranged header files according to guidelines.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30759 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+10
-17
@@ -1,22 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2007, Axel Dörfler, [email protected].
|
* Copyright 2003-2007, Axel Dörfler, [email protected].
|
||||||
* Copyright 2005-2007, François Revol, [email protected].
|
* Copyright 2005-2007, François Revol, [email protected].
|
||||||
|
* Copyright 2009, Jonas Sundström, [email protected].
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! Launches an application/document from the shell */
|
/*! Launches an application/document from the shell */
|
||||||
|
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <Url.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
const char *kTrackerSignature = "application/x-vnd.Be-TRAK";
|
const char *kTrackerSignature = "application/x-vnd.Be-TRAK";
|
||||||
@@ -86,25 +89,15 @@ main(int argc, char **argv)
|
|||||||
status = B_OK;
|
status = B_OK;
|
||||||
} else if (strchr(*argv, ':')) {
|
} else if (strchr(*argv, ':')) {
|
||||||
// try to open it as an URI
|
// try to open it as an URI
|
||||||
BString mimeType = "application/x-vnd.Be.URL.";
|
BPrivate::Support::BUrl url(*argv);
|
||||||
BString arg(*argv);
|
if (url.OpenWithPreferredApplication() == B_OK)
|
||||||
mimeType.Append(arg, arg.FindFirst(":"));
|
|
||||||
|
|
||||||
// the protocol should be alphanum
|
|
||||||
// we just check if it's registered
|
|
||||||
// if not there is likely no supporting app anyway
|
|
||||||
if (BMimeType::IsValid(mimeType.String())) {
|
|
||||||
char *args[2] = { *argv, NULL };
|
|
||||||
status = be_roster->Launch(openWith ? openWith
|
|
||||||
: mimeType.String(), 1, args);
|
|
||||||
if (status == B_OK)
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
// maybe it's "file:line" or "file:line:col"
|
// maybe it's "file:line" or "file:line:col"
|
||||||
int line = 0, col = 0, i;
|
int line = 0, col = 0, i;
|
||||||
status = B_ENTRY_NOT_FOUND;
|
status = B_ENTRY_NOT_FOUND;
|
||||||
// remove gcc error's last :
|
// remove gcc error's last :
|
||||||
|
BString arg(*argv);
|
||||||
if (arg[arg.Length() - 1] == ':')
|
if (arg[arg.Length() - 1] == ':')
|
||||||
arg.Truncate(arg.Length() - 1);
|
arg.Truncate(arg.Length() - 1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user