Cleaned up protocol configuration. Put compile-time config in a header file, so the rdef doesn't include mimes for urls we won't support.

Added http: support with wget in a Terminal.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20829 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2007-04-25 22:11:52 +00:00
parent 2b30a321fe
commit f1f76bb624
3 changed files with 114 additions and 18 deletions

View File

@ -1,3 +1,16 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* François Revol, revol@free.fr
*/
/*
* urlwrapper: wraps URL mime types around command line apps
* or other apps that don't handle them directly.
*/
#include <Alert.h>
#include <Application.h>
#include <AppFileInfo.h>
@ -10,14 +23,8 @@
#include <unistd.h>
#include <Debug.h>
#define HANDLE_FILE
#define HANDLE_QUERY
//#define HANDLE_MID_CID // http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid
#define HANDLE_SH
#define HANDLE_BESHARE
//#define HANDLE_IM
#define HANDLE_VLC
#define HANDLE_AUDIO
/* compile-time configuration */
#include "urlwrapper.h"
const char *kAppSig = "application/x-vnd.haiku.urlwrapper";
const char *kTrackerSig = "application/x-vnd.Be-TRAK";
@ -322,6 +329,23 @@ void UrlWrapperApp::ArgvReceived(int32 argc, char **argv)
return;
}
#ifdef HANDLE_HTTP_WGET
if (u.proto == "http") {
BString cmd("wget ");
//cmd << url;
if (u.HasUser())
cmd << u.user << "@";
cmd << u.full;
PRINT(("CMD='%s'\n", cmd.String()));
cmd << pausec;
args[2] = (char *)cmd.String();
be_roster->Launch(kTerminalSig, 3, args);
// TODO: handle errors
return;
}
#endif
#ifdef HANDLE_FILE
if (u.proto == "file") {
BMessage m(B_REFS_RECEIVED);
@ -336,7 +360,7 @@ void UrlWrapperApp::ArgvReceived(int32 argc, char **argv)
#endif
#ifdef HANDLE_QUERY
// XXX:TODO
// XXX:TODO: unencode the formula + split options
if (u.proto == "query") {
// mktemp ?
BString qname("/tmp/query-url-temp-");

46
src/bin/urlwrapper.h Normal file
View File

@ -0,0 +1,46 @@
/*
* Copyright 2007, Haiku. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* François Revol, revol@free.fr
*/
/*
* urlwrapper: compile-time configuration of supported protocols.
*/
/*
* comment out to disable handling a specific protocol
*/
/* file: redirects to Tracker */
#define HANDLE_FILE
/* http: downloads with wget in a Terminal */
#define HANDLE_HTTP_WGET
/* query: BeOS/Haiku-specific: this should allow putting queries in web pages :) */
#define HANDLE_QUERY
/* mid: cid: as per RFC 2392 */
/* http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid */
/* UNIMPLEMENTED */
//#define HANDLE_MID_CID
/* sh: executes a shell command (before warning user of danger) */
#define HANDLE_SH
/* beshare: optionaly connect to a server and start a query */
#define HANDLE_BESHARE
/* icq: msn: ... should open im_client to this user */
/* UNIMPLEMENTED */
//#define HANDLE_IM
/* mms: rtp: rtsp: opens the stream with VLC */
#define HANDLE_VLC
/* audio: redirects SoundPlay-urls for shoutcast streams */
/* UNIMPLEMENTED */
//#define HANDLE_AUDIO

View File

@ -1,20 +1,46 @@
#include "urlwrapper.h"
resource app_signature "application/x-vnd.haiku.urlwrapper";
resource app_flags B_MULTIPLE_LAUNCH | B_BACKGROUND_APP | B_ARGV_ONLY;
resource(1, "BEOS:FILE_TYPES") message
{
#ifdef HANDLE_FILE
"types" = "application/x-vnd.Be.URL.file",
#endif
#ifdef HANDLE_HTTP_WGET
"types" = "application/x-vnd.Be.URL.http",
#endif
#ifdef HANDLE_QUERY
"types" = "application/x-vnd.Be.URL.query",
#endif
#ifdef HANDLE_MID_CID
"types" = "application/x-vnd.Be.URL.mid",
"types" = "application/x-vnd.Be.URL.cid",
#endif
#ifdef HANDLE_SH
"types" = "application/x-vnd.Be.URL.sh",
#endif
#ifdef HANDLE_BESHARE
"types" = "application/x-vnd.Be.URL.beshare",
#endif
#ifdef HANDLE_IM
"types" = "application/x-vnd.Be.URL.icq",
"types" = "application/x-vnd.Be.URL.msn",
#endif
#ifdef HANDLE_VLC
"types" = "application/x-vnd.Be.URL.mms",
"types" = "application/x-vnd.Be.URL.rtp",
"types" = "application/x-vnd.Be.URL.rtsp",
#endif
#ifdef HANDLE_AUDIO
"types" = "application/x-vnd.Be.URL.audio",
#endif
/* default urls */
"types" = "application/x-vnd.Be.URL.telnet",
"types" = "application/x-vnd.Be.URL.ssh",
"types" = "application/x-vnd.Be.URL.ftp",
"types" = "application/x-vnd.Be.URL.sftp",
"types" = "application/x-vnd.Be.URL.finger",
"types" = "application/x-vnd.Be.URL.sh",
"types" = "application/x-vnd.Be.URL.file",
"types" = "application/x-vnd.Be.URL.query",
"types" = "application/x-vnd.Be.URL.beshare",
"types" = "application/x-vnd.Be.URL.mms",
"types" = "application/x-vnd.Be.URL.rtp",
"types" = "application/x-vnd.Be.URL.rtsp",
"types" = "application/x-vnd.Be.URL.audio"
"types" = "application/x-vnd.Be.URL.finger"
};