Esempio n. 1
0
char const* Diagnostic::message() const {
  diagnostic::QName const &q = qname();
  zstring temp( q.prefix() );
  temp += ':';
  temp += q.localname();
  return diagnostic::dict::lookup( temp );
}
Esempio n. 2
0
QString ImageHistogram<T>::getName() const {
    casa::String strname = ImageHistogram::m_image->name(true);
    QString qname(strname.c_str());
    qname = qname + m_regionId;

    return qname;
}
Esempio n. 3
0
QVariant WebPage::invokeCapybaraFunction(const char *name, QStringList &arguments) {
  QString qname(name);
  QString objectName("CapybaraInvocation");
  JavascriptInvocation invocation(qname, arguments);
  currentFrame()->addToJavaScriptWindowObject(objectName, &invocation);
  QString javascript = QString("Capybara.invoke()");
  return currentFrame()->evaluateJavaScript(javascript);
}
Esempio n. 4
0
//-------------------------------------------------------------------------
PyObject *py_validate_name(const char *name, nametype_t type, int flags=0)
{
  qstring qname(name);
  if ( validate_name(&qname, type, flags) )
    return PyString_FromStringAndSize(qname.c_str(), qname.length());
  else
    Py_RETURN_NONE;
}
Esempio n. 5
0
/**
 * Finds the font families that fit the given family name.
 * A family fits if the name is exactly the same or if the name is
 * contained in the family name.
 * For generic names like sans, serif or monospaced the algorithm tries
 * to find a suitable font family.
 */
void CQFontRenderer::findSimilarFamily(const std::string& name, std::set<std::string>& families) const
{
  QString qname(name.c_str());
  QStringList familyList = this->mpFontDatabase->families();
  QStringList::const_iterator constIterator;

  for (constIterator = familyList.constBegin(); constIterator != familyList.constEnd(); ++constIterator)
    {
      if ((*constIterator).contains(name.c_str(), Qt::CaseInsensitive))
        {
          families.insert((*constIterator).toLatin1().data());
        }
    }
}
Esempio n. 6
0
DialogObjects::DialogObjects(QWidget *parent, const std::string& name) :
    QDialog(parent),
    ui(new Ui::DialogObjects)
{
    ui->setupUi(this);
    QString qname(name.c_str());

    QString title("Select ");
    title += qname;
    ui->labelPrompt->setText(tr(title.toStdString().c_str()));

    this->setObjectName(QString(name.c_str()));

    restoreSettings();
}
Esempio n. 7
0
void TextureManager::loadSet(const char *dirname,
                             std::vector<Texture *>&vec){
    DIR *dir = opendir(dirname);
    if(!dir)
        throw Exception().set("cannot open directory '%s'",dirname);
    
    vec.clear();
    while(dirent *ent = readdir(dir)){
        const char *name = ent->d_name;
        if(strlen(name)>3){
            const char *ext = name+(strlen(name)-3);
            if(!strcasecmp(ext,"png") || !strcasecmp(ext,"tga")){
                // throws on failure
                QString qname(dirname);
                qname+="/"+QString(name);
                Texture *t = createOrFind(qname);
                vec.push_back(t);
            }
        }
    }
    if(!vec.size())
        throw Exception().set("no textures found in '%s'",dirname);
}
Esempio n. 8
0
InvocationResult WebPage::invokeCapybaraFunction(const char *name, bool allowUnattached, const QStringList &arguments) {
  QString qname(name);
  JavascriptInvocation invocation(qname, allowUnattached, arguments, this);
  return invocation.invoke(currentFrame());
}
Esempio n. 9
0
void
UrlWrapper::ArgvReceived(int32 argc, char** argv)
{
	if (argc <= 1)
		return;
	
	const char* failc = " || read -p 'Press any key'";
	const char* pausec = " ; read -p 'Press any key'";
	char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL};

	BPrivate::Support::BUrl url(argv[1]);

	BString full = url.Full();
	BString proto = url.Proto();
	BString host = url.Host();
	BString port = url.Port();
	BString user = url.User();
	BString pass = url.Pass();
	BString path = url.Path();

	if (url.InitCheck() < 0) {
		fprintf(stderr, "malformed url: '%s'\n", url.String());
		return;
	}
	
	// XXX: debug
	PRINT(("PROTO='%s'\n", proto.String()));
	PRINT(("HOST='%s'\n", host.String()));
	PRINT(("PORT='%s'\n", port.String()));
	PRINT(("USER='******'\n", user.String()));
	PRINT(("PASS='******'\n", pass.String()));
	PRINT(("PATH='%s'\n", path.String()));

	if (proto == "telnet") {
		BString cmd("telnet ");
		if (url.HasUser())
			cmd << "-l " << user << " ";
		cmd << host;
		if (url.HasPort())
			cmd << " " << port;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << failc;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		return;
	}
	
	// see draft:
	// http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/
	if (proto == "ssh") {
		BString cmd("ssh ");
		
		if (url.HasUser())
			cmd << "-l " << user << " ";
		if (url.HasPort())
			cmd << "-oPort=" << port << " ";
		cmd << host;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << failc;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		// TODO: handle errors
		return;
	}

	if (proto == "ftp") {
		BString cmd("ftp ");
		
		/*
		if (user.Length())
			cmd << "-l " << user << " ";
		cmd << host;
		*/
		cmd << full;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << failc;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		// TODO: handle errors
		return;
	}
	
	if (proto == "sftp") {
		BString cmd("sftp ");
		
		//cmd << url;
		if (url.HasPort())
			cmd << "-oPort=" << port << " ";
		if (url.HasUser())
			cmd << user << "@";
		cmd << host;
		if (url.HasPath())
			cmd << ":" << path;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << failc;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		// TODO: handle errors
		return;
	}

	if (proto == "finger") {
		BString cmd("/bin/finger ");
		
		if (url.HasUser())
			cmd << user;
		if (url.HasHost() == 0)
			host = "127.0.0.1";
		cmd << "@" << host;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << pausec;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		// TODO: handle errors
		return;
	}

	if (proto == "http") {
		BString cmd("/bin/wget ");
		
		//cmd << url;
		if (url.HasUser())
			cmd << user << "@";
		cmd << full;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << pausec;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		// TODO: handle errors
		return;
	}

	if (proto == "file") {
		BMessage m(B_REFS_RECEIVED);
		entry_ref ref;
		_DecodeUrlString(path);
		if (get_ref_for_path(path.String(), &ref) < B_OK)
			return;
		m.AddRef("refs", &ref);
		be_roster->Launch(kTrackerSig, &m);
		return;
	}

	// XXX:TODO: split options
	if (proto == "query") {
		// mktemp ?
		BString qname("/tmp/query-url-temp-");
		qname << getpid() << "-" << system_time();
		BFile query(qname.String(), O_CREAT|O_EXCL);
		// XXX: should check for failure
		
		BString s;
		int32 v;
		
		_DecodeUrlString(full);
		// TODO: handle options (list of attrs in the column, ...)

		v = 'qybF'; // QuerY By Formula XXX: any #define for that ?
		query.WriteAttr("_trk/qryinitmode", B_INT32_TYPE, 0LL, &v, sizeof(v));
		s = "TextControl";
		query.WriteAttr("_trk/focusedView", B_STRING_TYPE, 0LL, s.String(),
			s.Length()+1);
		s = full;
		PRINT(("QUERY='%s'\n", s.String()));
		query.WriteAttr("_trk/qryinitstr", B_STRING_TYPE, 0LL, s.String(),
			s.Length()+1);
		query.WriteAttr("_trk/qrystr", B_STRING_TYPE, 0LL, s.String(),
			s.Length()+1);
		s = "application/x-vnd.Be-query";
		query.WriteAttr("BEOS:TYPE", 'MIMS', 0LL, s.String(), s.Length()+1);
		

		BEntry e(qname.String());
		entry_ref er;
		if (e.GetRef(&er) >= B_OK)
			be_roster->Launch(&er);
		return;
	}

	if (proto == "sh") {
		BString cmd(full);
		if (_Warn(url.String()) != B_OK)
			return;
		PRINT(("CMD='%s'\n", cmd.String()));
		cmd << pausec;
		args[2] = (char*)cmd.String();
		be_roster->Launch(kTerminalSig, 3, args);
		// TODO: handle errors
		return;
	}

	if (proto == "beshare") {
		team_id team;
		BMessenger msgr(kBeShareSig);
		// if no instance is running, or we want a specific server, start it.
		if (!msgr.IsValid() || url.HasHost()) {
			be_roster->Launch(kBeShareSig, (BMessage*)NULL, &team);
			msgr = BMessenger(NULL, team);
		}
		if (url.HasHost()) {
			BMessage mserver('serv');
			mserver.AddString("server", host);
			msgr.SendMessage(&mserver);
			
		}
		if (url.HasPath()) {
			BMessage mquery('quer');
			mquery.AddString("query", path);
			msgr.SendMessage(&mquery);
		}
		// TODO: handle errors
		return;
	}

	if (proto == "icq" || proto == "msn") {
		// TODO
		team_id team;
		be_roster->Launch(kIMSig, (BMessage*)NULL, &team);
		BMessenger msgr(NULL, team);
		if (url.HasHost()) {
			BMessage mserver(B_REFS_RECEIVED);
			mserver.AddString("server", host);
			msgr.SendMessage(&mserver);
			
		}
		// TODO: handle errors
		return;
	}

	if (proto == "mms" || proto == "rtp" || proto == "rtsp") {
		args[0] = (char*)url.String();
		be_roster->Launch(kVLCSig, 1, args);
		return;
	}

	// Audio: ?

	// vnc: ?
	// irc: ?
	// 
	// svn: ?
	// cvs: ?
	// smb: cifsmount ?
	// nfs: mount_nfs ?
	//
	// mailto: ? Mail & Beam both handle it already (not fully though).
	//
	// mid: cid: as per RFC 2392
	// http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid
	//
	// itps: pcast: podcast: s//http/ + parse xml to get url to mp3 stream...
	// audio: s//http:/ + default MediaPlayer
	// -- see http://forums.winamp.com/showthread.php?threadid=233130
	//
	// gps: ? I should submit an RFC for that one :)

}
Esempio n. 10
0
 void ScriptObject::throwCantInstantiateError()
 {
     Multiname qname(traits()->ns(), traits()->name());
     toplevel()->argumentErrorClass()->throwError(kCantInstantiateError, core()->toErrorString(&qname));
 }
Esempio n. 11
0
int main(int argc, char *argv[])
{

    	char buffer[BUFLEN];
   	 
   	 if (argc != 3) {
   	    fprintf(stderr,"Usage %s domain name/ip address type\n", argv[0]);
	    exit(0);
   	 }
   	 int type;
   	 if(strcmp(argv[2],"MX")==0){
	   	 type = MX;
	 }
   	 else if(strcmp(argv[2],"A")==0){
	   	 type = A;
	 }	 
	 else if(strcmp(argv[2],"CNAME")==0){
	   	 type = CNAME;
	 }
	 else if(strcmp(argv[2],"NS")==0){
	   	 type = NS;
	 }
	 else if(strcmp(argv[2],"PTR")==0){
	   	 type = A;
	 }else{
		 fprintf(stderr,"bad command\n");
		 exit(0);
	 }
	 
	struct sockaddr_in to_station;
	char buf[BUFLEN];
    	
    	// deschidere socket 
    	int s = socket(AF_INET,SOCK_DGRAM,0);
	if(s== -1){
		fprintf(stderr, "Socket open failed");
		exit(0);
	}
	
    	// cautare server dns pentru conectare 
    	FILE * f = fopen("dns_servers.conf","r");
    	         

         if( f == NULL )
         {
               puts ( "cannot open dns conf file" );
               exit(0);
         }
     
         while(1){
         
        	if(fgets(buffer,sizeof(buffer),f) != NULL){
        	    
        		if(buffer[0] == '#'){
        			printf("comentariu\n %s ",buffer);
        			continue;
        		}else{
        			printf("nu este comentariu\n %s ",buffer);
        			
        		}
        	}else{
        		
        		break;
        	}
        	
        	
        	// ne conectam la primul server dns din resolv.conf
		// iar daca nu ne satisface cererea trecem la urmatorul
        	to_station.sin_family = AF_INET;
		to_station.sin_port = htons(53);
		to_station.sin_addr.s_addr = inet_addr(buffer);

		int ok = 0;
		
		// formam mesajul pentru sento care trebuie sa contine header si question 
		// facem 2 buffere care o sa pointeze catre structurile noastre de date 
		// modificam structurile header si question si concatenam la final cele 2 buffere
		
		char* tosendheader = (char*)malloc(sizeof(dns_header_t));
		dns_header_t* mesajx = (dns_header_t*)tosendheader;
		
		mesajx->id = htons(1002);
		mesajx->rd = 1;
		mesajx->tc = 0;
		mesajx->aa = 0;
		mesajx->opcode = 0;
		
		mesajx->qr = 0;
		mesajx->rcode = 0; 
		mesajx->z = 0;
		mesajx->ra = 0;
		mesajx->qdcount = htons(1);
		mesajx->ancount = htons(0);
		mesajx->nscount = htons(0);
		mesajx->arcount = htons(0);
		
		
		char* domain = argv[1];
		
		// adaugam q name in buffer 
		char* q = qname(domain);
		
		char* tosendquestion = (char*)malloc(sizeof(dns_question_t) + strlen(q));
		
		tosendquestion = (char*) memcpy(tosendquestion,q,strlen(q));
		
		printf("buffer length aici  %i\n ", strlen(tosendquestion));
		
		printf("q: %s \n",q);
		dns_question_t *mesaj1 = (dns_question_t*)(tosendquestion +(strlen(tosendquestion))) ;
		switch(type){
			case MX :
			{
			printf("MX\n");
			mesaj1->qtype = htons(MX);
			ok = 1;
			break;
			}
			case A:
			{
			printf("A\n");
			mesaj1->qtype =htons(A);
			ok = 1;
			break;
			}
			case NS:
			{
			printf("NS\n");
			mesaj1->qtype = htons(NS);
			ok = 1;
			break;
			}
			case PTR:
			{
			printf("PTR\n");
			mesaj1->qtype = htons(PTR);
			ok = 1;
			break;
			}
			case CNAME:
			{
			printf("CNAME\n");
			mesaj1->qtype = htons(CNAME);
			ok = 1;
			break;
			}
			

		}
		printf("buffer length %i ", strlen(tosendquestion));
		
		mesaj1->qclass = htons(IN);
		printf("buffer length %i ", strlen(tosendquestion));
		
		if(ok == 1){
			printf("SUCCES\n");
		}else{
			fprintf(stderr,"Bad Input");
		}
		
		char* tosend = (char*) malloc(strlen(tosendheader) + strlen(tosendquestion) + 1);
		printf("tosend header %i\n" ,strlen(tosendheader));
		strcpy(tosend,tosendheader);
		printf("tosend question %i\n" ,strlen(tosendquestion));
		
		strcat(tosend,tosendquestion);
		printf("header %i\n question %i\n tot %i\n",strlen(tosendheader),strlen(tosendquestion), strlen(tosend));
		int sent = sendto(s , tosend , strlen(tosend) , 0 ,(struct sockaddr*) &to_station , sizeof(struct sockaddr));
		printf("sent %i\n buffer %s    %i \n" , sent,tosend,strlen(tosend));
		char* buffer;
		int x ;
		int lung = 0;
		char buf[65000];
		int size =  sizeof(struct sockaddr);
		
	lung=recvfrom(s, buf ,65000, 0, (struct sockaddr*) &to_station, (socklen_t*)(&size));
	printf("=================");
	if(lung > 0)
	{
	printf("%s\n",buf);
	printf("%i\n",lung);
	}else{
		fprintf(stderr,"failed");
		exit(0);
	}
	
		if(ok == 1){
			printf("Succes \n");
			exit(0);
		}
		
		
         }
        
    	
	
    return 0;
}
Esempio n. 12
0
void XmlParser::OnStartElement(const XML_Char* name, const XML_Char** atts)
{
    const XML_Char** p = atts;
    std::map<exlib::string, exlib::string> nss;
    exlib::string def_ns;
    bool has_def = false;

    while (p[0] && p[1]) {
        const XML_Char* ns = p[0];

        if (!qstrcmp(ns, "xmlns", 5)) {
            if (ns[5] == ':')
                nss.insert(std::pair<exlib::string, exlib::string>(ns + 6, p[1]));
            else if (!ns[5]) {
                def_ns = p[1];
                has_def = true;
            }
        }
        p += 2;
    }

    obj_ptr<XmlElement> el;
    const char* str = qstrchr(name, ':');

    if (str) {
        exlib::string prefix(name, str - name);
        exlib::string qname(str + 1);
        std::map<exlib::string, exlib::string>::iterator it;

        it = nss.find(prefix);
        if (it != nss.end())
            def_ns = it->second;
        else
            m_now->lookupNamespaceURI(prefix, def_ns);
    } else if (!has_def) {
        int32_t type;
        m_now->get_nodeType(type);
        if (type == xml_base::_ELEMENT_NODE)
            ((XmlElement*)(XmlNode_base*)m_now)->get_defaultNamespace(def_ns);
    }

    if (!def_ns.empty())
        el = new XmlElement(m_document, def_ns, name, m_isXml);
    else
        el = new XmlElement(m_document, name, m_isXml);

    newNode(el, true);

    while (atts[0] && atts[1]) {
        name = atts[0];

        str = qstrchr(name, ':');
        if (str && str[1]) {
            exlib::string ns(name, str - name);
            exlib::string qname(str + 1);
            std::map<exlib::string, exlib::string>::iterator it;

            it = nss.find(ns);
            if (it != nss.end())
                def_ns = it->second;
            else
                m_now->lookupNamespaceURI(ns, def_ns);
        } else
            def_ns.clear();

        if (!def_ns.empty())
            el->setAttributeNS(def_ns, name, atts[1]);
        else
            el->setAttribute(name, atts[1]);

        atts += 2;
    }
}
Esempio n. 13
0
void
UrlWrapper::ArgvReceived(int32 argc, char** argv)
{
    if (argc <= 1)
        return;

    const char* failc = " || read -p 'Press any key'";
    const char* pausec = " ; read -p 'Press any key'";
    char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL};
    status_t err;

    BUrl url(argv[1]);

    BString full = BUrl(url).SetProtocol(BString()).UrlString();
    BString proto = url.Protocol();
    BString host = url.Host();
    BString port = BString() << url.Port();
    BString user = url.UserInfo();
    BString pass = url.Password();
    BString path = url.Path();

    if (!url.IsValid()) {
        fprintf(stderr, "malformed url: '%s'\n", url.UrlString().String());
        return;
    }

    // XXX: debug
    PRINT(("PROTO='%s'\n", proto.String()));
    PRINT(("HOST='%s'\n", host.String()));
    PRINT(("PORT='%s'\n", port.String()));
    PRINT(("USER='******'\n", user.String()));
    PRINT(("PASS='******'\n", pass.String()));
    PRINT(("PATH='%s'\n", path.String()));

    if (proto == "about") {
        app_info info;
        BString sig;
        // BUrl could get an accessor for the full - proto part...
        sig = host << "/" << path;
        BMessage msg(B_ABOUT_REQUESTED);
        if (be_roster->GetAppInfo(sig.String(), &info) == B_OK) {
            BMessenger msgr(sig.String());
            msgr.SendMessage(&msg);
            return;
        }
        if (be_roster->Launch(sig.String(), &msg) == B_OK)
            return;
        be_roster->Launch("application/x-vnd.Haiku-About");
        return;
    }

    if (proto == "telnet") {
        BString cmd("telnet ");
        if (url.HasUserInfo())
            cmd << "-l " << user << " ";
        cmd << host;
        if (url.HasPort())
            cmd << " " << port;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << failc;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        return;
    }

    // see draft:
    // http://tools.ietf.org/wg/secsh/draft-ietf-secsh-scp-sftp-ssh-uri/
    if (proto == "ssh") {
        BString cmd("ssh ");

        if (url.HasUserInfo())
            cmd << "-l " << user << " ";
        if (url.HasPort())
            cmd << "-oPort=" << port << " ";
        cmd << host;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << failc;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        // TODO: handle errors
        return;
    }

    if (proto == "ftp") {
        BString cmd("ftp ");

        cmd << proto << "://";
        /*
        if (user.Length())
        	cmd << "-l " << user << " ";
        cmd << host;
        */
        cmd << full;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << failc;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        // TODO: handle errors
        return;
    }

    if (proto == "sftp") {
        BString cmd("sftp ");

        //cmd << url;
        if (url.HasPort())
            cmd << "-oPort=" << port << " ";
        if (url.HasUserInfo())
            cmd << user << "@";
        cmd << host;
        if (url.HasPath())
            cmd << ":" << path;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << failc;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        // TODO: handle errors
        return;
    }

    if (proto == "finger") {
        BString cmd("/bin/finger ");

        if (url.HasUserInfo())
            cmd << user;
        if (url.HasHost() == 0)
            host = "127.0.0.1";
        cmd << "@" << host;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << pausec;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        // TODO: handle errors
        return;
    }

    if (proto == "http" || proto == "https" /*|| proto == "ftp"*/) {
        BString cmd("/bin/wget ");

        //cmd << url;
        cmd << proto << "://";
        if (url.HasUserInfo())
            cmd << user << "@";
        cmd << full;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << pausec;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        // TODO: handle errors
        return;
    }

    if (proto == "file") {
        BMessage m(B_REFS_RECEIVED);
        entry_ref ref;
        _DecodeUrlString(path);
        if (get_ref_for_path(path.String(), &ref) < B_OK)
            return;
        m.AddRef("refs", &ref);
        be_roster->Launch(kTrackerSig, &m);
        return;
    }

    // XXX:TODO: split options
    if (proto == "query") {
        // mktemp ?
        BString qname("/tmp/query-url-temp-");
        qname << getpid() << "-" << system_time();
        BFile query(qname.String(), O_CREAT|O_EXCL);
        // XXX: should check for failure

        BString s;
        int32 v;

        _DecodeUrlString(full);
        // TODO: handle options (list of attrs in the column, ...)

        v = 'qybF'; // QuerY By Formula XXX: any #define for that ?
        query.WriteAttr("_trk/qryinitmode", B_INT32_TYPE, 0LL, &v, sizeof(v));
        s = "TextControl";
        query.WriteAttr("_trk/focusedView", B_STRING_TYPE, 0LL, s.String(),
                        s.Length()+1);
        s = full;
        PRINT(("QUERY='%s'\n", s.String()));
        query.WriteAttr("_trk/qryinitstr", B_STRING_TYPE, 0LL, s.String(),
                        s.Length()+1);
        query.WriteAttr("_trk/qrystr", B_STRING_TYPE, 0LL, s.String(),
                        s.Length()+1);
        s = "application/x-vnd.Be-query";
        query.WriteAttr("BEOS:TYPE", 'MIMS', 0LL, s.String(), s.Length()+1);


        BEntry e(qname.String());
        entry_ref er;
        if (e.GetRef(&er) >= B_OK)
            be_roster->Launch(&er);
        return;
    }

    if (proto == "sh") {
        BString cmd(full);
        if (_Warn(url.UrlString()) != B_OK)
            return;
        PRINT(("CMD='%s'\n", cmd.String()));
        cmd << pausec;
        args[2] = (char*)cmd.String();
        be_roster->Launch(kTerminalSig, 3, args);
        // TODO: handle errors
        return;
    }

    if (proto == "beshare") {
        team_id team;
        BMessenger msgr(kBeShareSig);
        // if no instance is running, or we want a specific server, start it.
        if (!msgr.IsValid() || url.HasHost()) {
            be_roster->Launch(kBeShareSig, (BMessage*)NULL, &team);
            msgr = BMessenger(NULL, team);
        }
        if (url.HasHost()) {
            BMessage mserver('serv');
            mserver.AddString("server", host);
            msgr.SendMessage(&mserver);

        }
        if (url.HasPath()) {
            BMessage mquery('quer');
            mquery.AddString("query", path);
            msgr.SendMessage(&mquery);
        }
        // TODO: handle errors
        return;
    }

    if (proto == "icq" || proto == "msn") {
        // TODO
        team_id team;
        be_roster->Launch(kIMSig, (BMessage*)NULL, &team);
        BMessenger msgr(NULL, team);
        if (url.HasHost()) {
            BMessage mserver(B_REFS_RECEIVED);
            mserver.AddString("server", host);
            msgr.SendMessage(&mserver);

        }
        // TODO: handle errors
        return;
    }

    if (proto == "mms" || proto == "rtp" || proto == "rtsp") {
        args[0] = (char*)url.UrlString().String();
        be_roster->Launch(kVLCSig, 1, args);
        return;
    }

    if (proto == "nfs") {
        BString parameter(host);
        _DecodeUrlString(path);
        if (url.HasPort())
            parameter << ":" << port;
        //XXX: should not always be absolute! FIXME
        parameter << ":/" << path;
        BString prettyPath(path);
        prettyPath.Remove(0, prettyPath.FindLast("/") + 1);
        if (path == "" || path == "/")
            prettyPath = "root";
        prettyPath << " on " << host;
        prettyPath.Prepend("/");
        if (mkdir(prettyPath.String(), 0755) < 0) {
            perror("mkdir");
            return;
        }
        dev_t volume;
        uint32 flags = 0;
        fprintf(stderr, "parms:'%s'\n", parameter.String());
        volume = fs_mount_volume(prettyPath.String(), NULL, "nfs4", flags,
                                 parameter.String());
        if (volume < B_OK) {
            fprintf(stderr, "fs_mount_volume: %s\n", strerror(volume));
            return;
        }

        BMessage m(B_REFS_RECEIVED);
        entry_ref ref;
        if (get_ref_for_path(prettyPath.String(), &ref) < B_OK)
            return;
        m.AddRef("refs", &ref);
        be_roster->Launch(kTrackerSig, &m);
        return;
    }

    if (proto == "doi") {
        BString url("http://dx.doi.org/");
        BString mimetype;

        url << full;
        BUrl u(url.String());
        args[0] = const_cast<char*>("urlwrapper"); //XXX
        args[1] = (char*)u.UrlString().String();
        args[2] = NULL;
        mimetype = kURLHandlerSigBase;
        mimetype += u.Protocol();

        err = be_roster->Launch(mimetype.String(), 1, args + 1);
        if (err != B_OK && err != B_ALREADY_RUNNING)
            err = be_roster->Launch(kAppSig, 1, args + 1);
        // TODO: handle errors
        return;
    }

    /*

    More ?
    cf. http://en.wikipedia.org/wiki/URI_scheme
    cf. http://www.iana.org/assignments/uri-schemes.html

    Audio: (SoundPlay specific, identical to http:// to a shoutcast server)

    vnc: ?
    irc: ?
    im: http://tools.ietf.org/html/rfc3860

    svn: handled by checkitout
    cvs: handled by checkitout
    git: handled by checkitout
    rsync: handled by checkitout - http://tools.ietf.org/html/rfc5781

    smb: cifsmount ?
    nfs: mount_nfs ? http://tools.ietf.org/html/rfc2224
    ipp: http://tools.ietf.org/html/rfc3510

    mailto: ? Mail & Beam both handle it already (not fully though).
    imap: to describe mail accounts ? http://tools.ietf.org/html/rfc5092
    pop: http://tools.ietf.org/html/rfc2384
    mid: cid: as per RFC 2392
    http://www.rfc-editor.org/rfc/rfc2392.txt query MAIL:cid
    message:<MID> http://daringfireball.net/2007/12/message_urls_leopard_mail

    itps: pcast: podcast: s//http/ + parse xml to get url to mp3 stream...
    audio: s//http:/ + default MediaPlayer
    -- see http://forums.winamp.com/showthread.php?threadid=233130

    gps: ? I should submit an RFC for that one :)

    webcal: (is http: to .ics file)

    data: (but it's dangerous)

    */


}