Example #1
0
int URLData::addTopTen(std::string str, int hits)
{
    //add the website to the list (key: website, value: number of hits)
    URLHits newURL(str, hits);
    listTopTen.push_back(newURL);
    return 0;
}
Example #2
0
bool NetworkJob::handleRedirect()
{
    ASSERT(m_handle);
    if (!m_handle)
        return false;

    String location = m_response.httpHeaderField("Location");
    if (location.isNull())
        return false;

    KURL newURL(m_response.url(), location);
    if (!newURL.isValid())
        return false;

    ResourceRequest newRequest = m_handle->firstRequest();
    newRequest.setURL(newURL);
    newRequest.setMustHandleInternally(true);

    String method = newRequest.httpMethod().upper();
    if ((method != "GET") && (method != "HEAD")) {
        newRequest.setHTTPMethod("GET");
        newRequest.setHTTPBody(0);
        newRequest.setHTTPHeaderField("Content-Length", String());
        newRequest.setHTTPHeaderField("Content-Type", String());
    }

    // Do not send existing credentials with the new request.
    m_handle->getInternal()->m_currentWebChallenge.nullify();

    return startNewJobWithRequest(newRequest, true);
}
Example #3
0
void KfmView::openURL( const char *_url )
{
    redirectTimer.stop();

    // dirty hack to get the restoring of frames working correctly
    if( strncmp( _url, "restored:", 9 ) == 0 )
    {
	_url += 9;
	emit newURL(_url);
	return;
    }

    checkLocalProperties (_url);
    emit newURL( _url );
    manager->openURL( _url );
}
Example #4
0
void KfmView::openURL( const char *_url, bool _refresh, int _xoffset, int _yoffset )
{
    redirectTimer.stop();
    checkLocalProperties (_url);
    emit newURL( _url );
    manager->openURL( _url, _refresh, _xoffset, _yoffset );
}
Example #5
0
void serversDialog::editServer() {

	addEditServer *editServer = new addEditServer(this,&serverList->selectedItems().at(0)->text()) ;
	connect(editServer,SIGNAL(newURL(QString)),this,SLOT(editServerURL(QString))) ;
	editServer->show() ;

}
Example #6
0
void serversDialog::addServer() {

	addEditServer *addServer = new addEditServer(this) ;
	connect(addServer,SIGNAL(newURL(QString)),this,SLOT(addServerURL(QString))) ;
	addServer->show() ;

}
Example #7
0
void KfmView::openURL( const char *_url, const char *_data )
{
    redirectTimer.stop();

    checkLocalProperties (_url);
    emit newURL( _url );
    manager->openURL( _url, FALSE, 0, 0, _data );
}
Example #8
0
void addEditServer::urlAccepted() {

	if(QUrl(serverURL->text(),QUrl::StrictMode).isValid() == TRUE) {
		emit(newURL(serverURL->text())) ;
		this->deleteLater() ;
	} else {
		QMessageBox::warning(this,tr("URL not valid"),tr("The entered URL is not valid.")) ;
		serverURL->selectAll() ;
	}

}
Example #9
0
QUrl Info::makeValidTeXURL(const QUrl &url, QWidget *mainWidget, bool istexfile, bool checkForFileExistence)
{
	QUrl newURL(url);

	//add a .tex extension
	if(!istexfile) {
		newURL = repairExtension(newURL, mainWidget, checkForFileExistence);
	}

	//remove characters TeX does not accept, make sure the newURL does not exists yet
	if(containsInvalidCharacters(newURL)) {
		newURL = repairInvalidCharacters(newURL, mainWidget, checkForFileExistence);
	}

	return newURL;
}
Example #10
0
    std::string URLToPath(const std::string& url)
    {
        Poco::URI inURI = Poco::URI(url);
        try
        {
            if (url == BlankPageURL())
            {
                return BlankURLToFilePath();
            }
            if (inURI.getScheme() == "ti")
            {
                return TiURLToPath(url);
            }
            else if (inURI.getScheme() == "app")
            {
                return AppURLToPath(url);
            }
            else if (inURI.getScheme().empty())
            {
                // There is no scheme for this URL, so we have to/ guess at this point if
                // it's a path or a relative app:// URL. If a file can be found, assume thi
                // is a file path.
                if (FileUtils::IsFile(url))
                    return url;

                // Otherwise treat this like an app:// URL relative to the root.
                std::string newURL("app://");
                newURL.append(url);
                return AppURLToPath(newURL);
            }
        }
        catch (ValueException& e)
        {
            SharedString ss = e.DisplayString();
            Logger* log = Logger::Get("URLUtils");
            log->Error("Could not convert %s to a path: %s", url.c_str(), ss->c_str());
        }
        return url;
    }
UnixHTTPURLInputStream::UnixHTTPURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
    : BinHTTPInputStreamCommon(urlSource.getMemoryManager()),
      fSocket(0)
{
    //
    //  Convert the hostName to the platform's code page for gethostbyname and
    //  inet_addr functions.
    //

    MemoryManager *memoryManager = urlSource.getMemoryManager();

    const XMLCh*        hostName = urlSource.getHost();

    if (hostName == 0)
      ThrowXMLwithMemMgr1(NetAccessorException,
                          XMLExcepts::File_CouldNotOpenFile,
                          urlSource.getURLText(),
                          memoryManager);

    char*               hostNameAsCharStar = XMLString::transcode(hostName, memoryManager);
    ArrayJanitor<char>  janHostNameAsCharStar(hostNameAsCharStar, memoryManager);

    XMLURL url(urlSource);
    int redirectCount = 0;
    SocketJanitor janSock(0);

    do {
        //
        // Set up a socket.
        //

#if HAVE_GETADDRINFO
        struct addrinfo hints, *res, *ai;

        CharBuffer portBuffer(10, memoryManager);
        portBuffer.appendDecimalNumber(url.getPortNum());

        memset(&hints, 0, sizeof(struct addrinfo));
        hints.ai_family = PF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
        int n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
        if(n != 0)
        {
            hints.ai_flags = AI_NUMERICHOST;
            n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
            if(n != 0)
                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_TargetResolution, hostName, memoryManager);
        }
        janSock.reset();
        for (ai = res; ai != NULL; ai = ai->ai_next) {
            // Open a socket with the correct address family for this address.
            fSocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
            if (fSocket < 0)
                continue;
            janSock.reset(&fSocket);
            if (connect(fSocket, ai->ai_addr, ai->ai_addrlen) < 0)
            {
                freeaddrinfo(res);
                ThrowXMLwithMemMgr1(NetAccessorException,
                         XMLExcepts::NetAcc_ConnSocket, url.getURLText(), memoryManager);
            }
            break;
        }
        freeaddrinfo(res);
        if (fSocket < 0)
        {
            ThrowXMLwithMemMgr1(NetAccessorException,
                     XMLExcepts::NetAcc_CreateSocket, url.getURLText(), memoryManager);
        }
#else
        struct hostent *hostEntPtr = 0;
        struct sockaddr_in sa;

        // Use the hostName in the local code page ....
        if((hostEntPtr = gethostbyname(hostNameAsCharStar)) == NULL)
        {
            unsigned long  numAddress = inet_addr(hostNameAsCharStar);
            if ((hostEntPtr =
                    gethostbyaddr((char *) &numAddress,
                        sizeof(unsigned long), AF_INET)) == NULL)
            {
                ThrowXMLwithMemMgr1(NetAccessorException,
                    XMLExcepts::NetAcc_TargetResolution, hostName, memoryManager);
            }
        }

        memset(&sa, '\0', sizeof(sockaddr_in));  // iSeries fix ??
        memcpy((void *) &sa.sin_addr,
            (const void *) hostEntPtr->h_addr, hostEntPtr->h_length);
        sa.sin_family = hostEntPtr->h_addrtype;
        sa.sin_port = htons((unsigned short)url.getPortNum());

        janSock.reset();
        fSocket = socket(hostEntPtr->h_addrtype, SOCK_STREAM, 0);
        if(fSocket < 0)
        {
            ThrowXMLwithMemMgr1(NetAccessorException,
                XMLExcepts::NetAcc_CreateSocket, url.getURLText(), memoryManager);
        }
        janSock.reset(&fSocket);

        if(connect(fSocket, (struct sockaddr *) &sa, sizeof(sa)) < 0)
        {
            ThrowXMLwithMemMgr1(NetAccessorException,
                XMLExcepts::NetAcc_ConnSocket, url.getURLText(), memoryManager);
        }
#endif

        int status = sendRequest(url, httpInfo);

        if(status == 200) {
            // HTTP 200 OK response means we're done.
            break;
        }
        // a 3xx response means there was an HTTP redirect
        else if(status >= 300 && status <= 307) {
            redirectCount++;

            XMLCh *newURLString = findHeader("Location");
            ArrayJanitor<XMLCh> janNewURLString(newURLString, memoryManager);

            if(newURLString == 0 || *newURLString == 0) {
                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::File_CouldNotOpenFile, url.getURLText(), memoryManager);
            }

            XMLURL newURL(memoryManager);
            newURL.setURL(url, newURLString);
            if(newURL.getProtocol() != XMLURL::HTTP) {
                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::File_CouldNotOpenFile, newURL.getURLText(), memoryManager);
            }

            url = newURL;
            hostName = newURL.getHost();

            if (hostName == 0)
              ThrowXMLwithMemMgr1(NetAccessorException,
                                  XMLExcepts::File_CouldNotOpenFile,
                                  newURL.getURLText(),
                                  memoryManager);

            janHostNameAsCharStar.release();
            hostNameAsCharStar = XMLString::transcode(hostName, memoryManager);
            janHostNameAsCharStar.reset(hostNameAsCharStar, memoryManager);
        }
        else {
            // Most likely a 404 Not Found error.
            ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::File_CouldNotOpenFile, url.getURLText(), memoryManager);
        }
    } while(redirectCount < 6);

    janSock.release();
}