Ejemplo n.º 1
0
void UrlLoader::loadNext()
{
    QString qstr;
    if (getUrl(qstr)) {
        QUrl url(qstr, QUrl::StrictMode);
        if (url.isValid()) {
            m_stdOut << "Loading " << qstr << " ......" << ++m_loaded << endl;
            m_frame->load(url);
        } else
            loadNext();
    } else
        disconnect(m_frame, 0, this, 0);
}
Ejemplo n.º 2
0
bool deleteUrls ( ) {
	static long s_ii2 = 0;
	for ( ; s_ii2 < s_numUrls ; ) {
		// pre-inc it
		s_ii2++;
		// reject using html api
		SafeBuf sb;
		sb.safePrintf( "/admin/inject?c=qatest123&delete=1&u=");
		sb.urlEncode ( s_urlPtrs[s_ii2] );
		return getUrl ( sb.getBufStart() , qatestWrapper );
	}
	return true;
}
Ejemplo n.º 3
0
std::string LLUrlEntrySLLabel::getTooltip(const std::string &string) const
{
	// return a tooltip corresponding to the URL type instead of the generic one (EXT-4574)
	std::string url = getUrl(string);
	LLUrlMatch match;
	if (LLUrlRegistry::instance().findUrl(url, match))
	{
		return match.getTooltip();
	}

	// unrecognized URL? should not happen
	return LLUrlEntryBase::getTooltip(string);
}
Ejemplo n.º 4
0
const char *Transport::getServerObject() {
  const char *url = getUrl();
  int strip = 0;
  if (strncmp(url, "http://", 7) == 0) {
    strip = 7;
  } else if (strncmp(url, "https://", 8) == 0) {
    strip = 8;
  }
  if (strip == 0) return url;
  const char *p = strchr(url + strip, '/');
  if (p) return p;

  return "";
}
Ejemplo n.º 5
0
void DefaultQuery::doRequest()
{
  QNetworkRequest request;

  QUrl url(getUrl());
  url.setPort(getServerPort());
  request.setUrl(url);

  //  DEBUG() << "doing post to" << url << " with body: " << getRequestBody();
  DEBUG() << "posting http request to "<<url.toString()<<" with body "<<getRequestBody();
  QNetworkReply *reply = m_manager->post(request, getRequestBody());
  m_sendTime = QDateTime::currentDateTime();
  connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(handleError()));
}
Ejemplo n.º 6
0
void JsExtender::loadPicture()
{
	QString result = "loadPicFailed";
	QByteArray buffer;
	try {
		buffer = getUrl( SSLConnect::PictureInfo, "" );
	} catch( std::runtime_error &e ) {
		jsCall( "handleError", QString::fromUtf8( e.what() ) );
		jsCall( "setPicture", "", result );
		return;
	}
	if ( !buffer.size() )
	{
		jsCall( "setPicture", "", result );
		return;
	}

	QPixmap pix;
	if ( pix.loadFromData( buffer ) )
	{
		QPixmap small = pix.scaled( 90, 120, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
		QTemporaryFile file( QString( "%1%2XXXXXX" )
			.arg( QDir::tempPath() ).arg( QDir::separator() ) );
		file.setAutoRemove( false );
		if ( file.open() )
		{
			m_tempFile = file.fileName();
			if ( small.save( m_tempFile + "_small.jpg" ) && pix.save( m_tempFile + "_big.jpg" ) )
			{
				jsCall( "setPicture", QUrl::fromLocalFile(m_tempFile).toString(), "" );
				return;
			}
		}
		jsCall( "setPicture", "", QString( "loadPicFailed3|%1" ).arg( file.errorString() ) );
	} else { //probably got xml error string
		QString result2 = "loadPicFailed2";
		xml.clear();
		xml.addData( buffer );		
		while ( !xml.atEnd() )
		{
			xml.readNext();
			if ( xml.isStartElement() && xml.name() == "fault_code" )
			{
				result2 = xml.readElementText();
				break;
			}
		}
		jsCall( "setPicture", "", result2 );
	}
}
Ejemplo n.º 7
0
void CSyncSource::syncClientChanges()
{
    const char* arUpdateTypes[] = {"create", "update", "delete"};
    for( int i = 0; i < 3 && getSync().isContinueSync(); i++ )
    {
        String strUrl = getUrl() + "/" + arUpdateTypes[i];
        strUrl += "objects";
        String strQuery = CSyncEngine::SYNC_SOURCE_FORMAT() + "&client_id=" + getSync().getClientID();

        m_arSyncBlobs.removeAllElements();
        String strBody;
        makePushBody(strBody, arUpdateTypes[i]);
        if ( strBody.length() > 0 )
        {
		    LOG(INFO) + "Push client changes to server. Source: " + getName() + "Size :" + strBody.length();
		    LOG(TRACE) + "Push body: " + strBody;		
 
            NetResponse( resp, getNet().pushData(strUrl+strQuery,strBody, &getSync()) );
            if ( !resp.isOK() )
            {
                getSync().setState(CSyncEngine::esStop);
                m_nErrCode = RhoRuby.ERR_REMOTESERVER;
                continue;
            }
        }
 
        if ( m_arSyncBlobs.size() > 0 )
        {
		    LOG(INFO) + "Push blobs to server. Source: " + getName() + "Count :" + m_arSyncBlobs.size();
            //oo conflicts
            if ( i < 1 ) //create
                getDB().executeSQL("UPDATE changed_values SET sent=2 WHERE source_id=? and update_type=? and (attrib_type IS NULL or attrib_type!=?) and sent=1", 
                    getID(), arUpdateTypes[i], "blob.file" );
            else
            //
                getDB().executeSQL("DELETE FROM changed_values WHERE source_id=? and update_type=? and (attrib_type IS NULL or attrib_type!=? and sent=1)", 
                    getID(), arUpdateTypes[i], "blob.file" );

            syncClientBlobs(strUrl+strQuery);
        }else if ( strBody.length() > 0 )
        {
            //oo conflicts
            if ( i < 1 ) //create
                getDB().executeSQL("UPDATE changed_values SET sent=2 WHERE source_id=? and update_type=? and sent=1", getID(), arUpdateTypes[i] );
            else
            //
                getDB().executeSQL("DELETE FROM changed_values WHERE source_id=? and update_type=? and sent=1", getID(), arUpdateTypes[i] );
        }
    }
}
Ejemplo n.º 8
0
void SoundSourceProxy::initSoundSource() {
    DEBUG_ASSERT(!m_pSoundSource);
    DEBUG_ASSERT(!m_pAudioSource);
    while (!m_pSoundSource) {
        mixxx::SoundSourceProviderPointer pProvider(getSoundSourceProvider());
        if (!pProvider) {
            if (!getUrl().isEmpty()) {
                qWarning() << "No SoundSourceProvider for file"
                           << getUrl().toString();
            }
            // Failure
            return;
        }
        m_pSoundSource = pProvider->newSoundSource(m_url);
        if (!m_pSoundSource) {
            qWarning() << "SoundSourceProvider"
                       << pProvider->getName()
                       << "failed to create a SoundSource for file"
                       << getUrl().toString();
            // Switch to next provider...
            nextSoundSourceProvider();
            // ...and continue loop
            DEBUG_ASSERT(!m_pSoundSource);
        } else {
            QString trackType(m_pSoundSource->getType());
            qDebug() << "SoundSourceProvider"
                     << pProvider->getName()
                     << "created a SoundSource for file"
                     << getUrl().toString()
                     << "of type"
                     << trackType;
            if (m_pTrack) {
                m_pTrack->setType(trackType);
            }
        }
    }
}
void VLCVideoTextureObjChunk::changed(ConstFieldMaskArg whichField, 
                                      UInt32            origin,
                                      BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if (0x0000 != (whichField & UrlFieldMask)) {
        // init VLC internal structures
        if (getUrl().length()>0) {            
            createVLCInstance();            
        }
    } else
    if ((0x0000 != (whichField & WidthFieldMask)) ||
        (0x0000 != (whichField & HeightFieldMask))) 
    {
        // reinit VLC internal structures
        if (getUrl().length()>1)
        {            
            resizeVideo();
        }
    }

    if (0x0000 != (whichField & StatusFieldMask)) {
        // update VLC        
    }

    if (0x0000 != (whichField & TimestampFieldMask)) {
        // update VLC
        if (getUrl().length()>1)
        { 
            if (!this->getIsMaster()) 
            {
                updateTime();
            }
        }
    }
}
Ejemplo n.º 10
0
// ensure search results are consistent
bool searchTest2 () {
	long nq = sizeof(s_queries)/sizeof(char *);
	for ( ; s_qi2 < nq ; ) {
		// pre-inc it
		s_qi2++;
		// inject using html api
		SafeBuf sb;
		// qa=1 tell gb to exclude "variable" or "random" things
		// from the serps so we can checksum it consistently
		sb.safePrintf ( "/search?c=qatest123&qa=1&q=" );
		sb.urlEncode ( s_queries[s_qi2] );
		return getUrl ( sb.getBufStart() , doneSearching2 );
	}
	return true;
}	
Ejemplo n.º 11
0
mixxx::AudioSourcePointer SoundSourceProxy::openAudioSource(const mixxx::AudioSourceConfig& audioSrcCfg) {
    DEBUG_ASSERT(m_pTrack);
    while (!m_pAudioSource) {
        if (!m_pSoundSource) {
            qWarning() << "Failed to open AudioSource for file"
                       << getUrl().toString();
            return m_pAudioSource; // failure -> exit loop
        }
        const mixxx::SoundSource::OpenResult openResult = m_pSoundSource->open(audioSrcCfg);
        if (mixxx::SoundSource::OpenResult::UNSUPPORTED_FORMAT != openResult) {
            qDebug() << "Opened AudioSource for file"
                     << getUrl().toString()
                     << "with provider"
                     << getSoundSourceProvider()->getName();
            if ((mixxx::SoundSource::OpenResult::SUCCEEDED == openResult) && m_pSoundSource->verifyReadable()) {
                m_pAudioSource =
                        AudioSourceProxy::create(m_pTrack, m_pSoundSource);
                if (m_pAudioSource->isEmpty()) {
                    qWarning() << "Empty audio data in file"
                               << getUrl().toString();
                }
                // Overwrite metadata with actual audio properties
                if (m_pTrack) {
                    m_pTrack->setChannels(m_pAudioSource->getChannelCount());
                    m_pTrack->setSampleRate(m_pAudioSource->getSamplingRate());
                    if (m_pAudioSource->hasDuration()) {
                        m_pTrack->setDuration(m_pAudioSource->getDuration());
                    }
                    if (m_pAudioSource->hasBitrate()) {
                        m_pTrack->setBitrate(m_pAudioSource->getBitrate());
                    }
                }
                return m_pAudioSource; // success -> exit loop
            } else {
                qWarning() << "Invalid audio data in file"
                           << getUrl().toString();
                // Do NOT retry with the next SoundSource provider if
                // the file itself is malformed!
                m_pSoundSource->close();
                break; // exit loop
            }
        }
        qWarning() << "Failed to open AudioSource for file"
                   << getUrl().toString()
                   << "with provider"
                   << getSoundSourceProvider()->getName();
        // Continue with the next SoundSource provider
        nextSoundSourceProvider();
        initSoundSource();
    }
    // m_pSoundSource might be invalid when reaching this point
    qWarning() << "Failed to open AudioSource for file"
               << getUrl().toString();
    return m_pAudioSource;
}
Mixxx::AudioSourcePointer SoundSourceProxy::openAudioSource(const Mixxx::AudioSourceConfig& audioSrcCfg) {
    DEBUG_ASSERT(!m_pTrack.isNull());
    while (m_pAudioSource.isNull()) {
        if (m_pSoundSource.isNull()) {
            qWarning() << "Failed to open AudioSource for file"
                    << getUrl();
            return m_pAudioSource; // failure -> exit loop
        }
        if (OK == m_pSoundSource->open(audioSrcCfg)) {
            qDebug() << "Opened AudioSource for file"
                    << getUrl()
                    << "with provider"
                    << getSoundSourceProvider()->getName();
            if (m_pSoundSource->isValid()) {
                m_pAudioSource =
                        AudioSourceProxy::create(m_pTrack, m_pSoundSource);
                if (m_pAudioSource->isEmpty()) {
                    qWarning() << "Empty audio data in file"
                            << getUrl();
                }
                // Overwrite metadata with actual audio properties
                if (!m_pTrack.isNull()) {
                    m_pTrack->setChannels(m_pAudioSource->getChannelCount());
                    m_pTrack->setSampleRate(m_pAudioSource->getSamplingRate());
                    if (m_pAudioSource->hasDuration()) {
                        m_pTrack->setDuration(m_pAudioSource->getDuration());
                    }
                    if (m_pAudioSource->hasBitrate()) {
                        m_pTrack->setBitrate(m_pAudioSource->getBitrate());
                    }
                }
                return m_pAudioSource; // success -> exit loop
            } else {
                qWarning() << "Invalid audio data in file"
                        << getUrl();
                // Do NOT retry with the next SoundSource provider if
                // only the file itself is malformed!
                m_pSoundSource->close();
                break; // exit loop
            }
        }
        qWarning() << "Failed to open AudioSource for file"
                << getUrl()
                << "with provider"
                << getSoundSourceProvider()->getName();
        // Continue with the next SoundSource provider
        nextSoundSourceProvider();
        initSoundSource();
    }
    // m_pSoundSource might be invalid when reaching this point
    qWarning() << "Failed to open AudioSource for file"
            << getUrl();
    return m_pAudioSource;
}
Ejemplo n.º 13
0
void UrlLoader::loadNext()
{
    m_timeoutTimer.stop();
    m_extraTimeTimer.stop();
    m_checkIfFinishedTimer.stop();
    m_numFramesLoading = 0;
    QString qstr;
    if (getUrl(qstr)) {
        QUrl url(qstr, QUrl::StrictMode);
        if (url.isValid()) {
            m_stdOut << "Loading " << qstr << " ......" << ++m_loaded << endl;
            m_browserWindow->load(url.toString());
        } else
            loadNext();
    } else
        disconnect(m_browserWindow, 0, this, 0);
}
QByteArray LedDevicePhilipsHue::get(QString route) {
	QString url = getUrl(route);
	// Perfrom request
	QNetworkRequest request(url);
	QNetworkReply* reply = manager->get(request);
	// Connect requestFinished signal to quit slot of the loop.
	QEventLoop loop;
	loop.connect(reply, SIGNAL(finished()), SLOT(quit()));
	// Go into the loop until the request is finished.
	loop.exec();
	// Read all data of the response.
	QByteArray response = reply->readAll();
	// Free space.
	reply->deleteLater();
	// Return response
	return response;
}
Ejemplo n.º 15
0
void Window::search(const QString &query, const QString &engine)
{
	WebContentsWidget *widget = qobject_cast<WebContentsWidget*>(m_contentsWidget);

	if (!widget)
	{
		widget = new WebContentsWidget(isPrivate(), NULL, this);

		setContentsWidget(widget);
	}

	m_ui->addressWidget->clearFocus();

	widget->search(query, engine);

	m_ui->addressWidget->setUrl(getUrl());
}
Ejemplo n.º 16
0
void AddressWidget::verifyLookup(const QHostInfo &host)
{
	killTimer(m_lookupTimer);

	m_lookupTimer = 0;

	if (host.error() == QHostInfo::NoError)
	{
		emit requestedLoadUrl(getUrl());
	}
	else
	{
		emit requestedSearch(m_lookupQuery, SettingsManager::getValue(QLatin1String("Search/DefaultSearchEngine")).toString());
	}

	m_lookupQuery.clear();
}
Ejemplo n.º 17
0
void WebWidget::openInApplication(QAction *action)
{
	QObject *menu = sender();

	if (menu == m_pageApplicationsMenu)
	{
		Utils::runApplication(action->data().toString(), getUrl());
	}
	else if (menu == m_linkApplicationsMenu && m_hitResult.linkUrl.isValid())
	{
		Utils::runApplication(action->data().toString(), m_hitResult.linkUrl);
	}
	else if (menu == m_frameApplicationsMenu && m_hitResult.frameUrl.isValid())
	{
		Utils::runApplication(action->data().toString(), m_hitResult.frameUrl);
	}
}
Ejemplo n.º 18
0
Json::Value getJsonFromUrl(const char* url, const char* extraHeader)
{
	Json::Value res;
	Json::Reader reader;

	std::string data = getUrl(url, extraHeader);

	if(data.empty())
		return res;

	bool ok = reader.parse(data, res);

	if(!ok)
		return Json::Value();

	return res;
}
Ejemplo n.º 19
0
/* expected hook, this is where custom stuff happens */
PAM_EXTERN int pam_sm_authenticate(pam_handle_t* pamh, int flags, int argc, const char **argv) {
	int ret = 0;

	const char* pUsername = NULL;
	const char* pUrl = NULL;
	const char* pCaFile = NULL;

	struct pam_message msg;
	struct pam_conv* pItem;
	struct pam_response* pResp;
	const struct pam_message* pMsg = &msg;

	msg.msg_style = PAM_PROMPT_ECHO_OFF;
	msg.msg = "Cool buddy: ";
	
	printf("I got called\n");

	if (pam_get_user(pamh, &pUsername, NULL) != PAM_SUCCESS) {
		return PAM_AUTH_ERR;
	}

	pUrl = getArg("url", argc, argv);
	if (!pUrl) {
		return PAM_AUTH_ERR;
	}

	pCaFile = getArg("cafile", argc, argv);
	if (pam_get_item(pamh, PAM_CONV, (const void**)&pItem) != PAM_SUCCESS || !pItem) {
		fprintf(stderr, "Couldn't get pam_conv\n");
		return PAM_AUTH_ERR;
	}

	pItem->conv(1, &pMsg, &pResp, pItem->appdata_ptr);

	ret = PAM_SUCCESS;

	if (getUrl(pUrl, pUsername, pResp[0].resp, pCaFile) != 0) {
		ret = PAM_AUTH_ERR;
	}
	
	memset(pResp[0].resp, 0, strlen(pResp[0].resp));
	free(pResp);
	
	return ret;
}
void NetfondsHistoryDownload::download(QStringList symbols)
{
  _stop = FALSE;
  QNetworkAccessManager manager;
  QEventLoop eventLoop;
  QProgressDialog progressDialog("Downloading...", "Cancel", 0, symbols.size());
  connect(&progressDialog, SIGNAL(canceled()), this, SLOT(stop()));
  connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
  progressDialog.setWindowModality(Qt::ApplicationModal);
  progressDialog.show();
  for (int loop = 0; (!_stop && loop < symbols.size()); loop++)
  {
    progressDialog.setValue(loop);
    QString symbol = symbols.at(loop);
    symbol = symbol.trimmed();
    if (symbol.isEmpty())
      continue;

      QString name;

      name = symbol;

      // get the url
      QString url;
      getUrl(symbol, url);
      QStringList mess;
      mess << url;
      mess << tr("Downloading") << symbol;
      emit signalMessage(mess.join(" "));
      mess << "...";
      progressDialog.setLabelText(QString("Downloading ").append(symbol).append("..."));

      // download the data
      QNetworkReply *reply = manager.get(QNetworkRequest(QUrl(url)));

      connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
      QObject::connect(&manager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
      eventLoop.exec();

      // parse the data and save quotes
      QByteArray ba = reply->readAll();
      parseHistory(ba, symbol, name);
  }

}
Ejemplo n.º 21
0
void Fritzbox::modifySettings(queryItemsList list) {
	// prepare post data
	QByteArray data;
	for (queryItemsList::iterator iter = list.begin(); iter != list.end(); iter++) {
		data.append("tam:settings/TAM" + QString::number(tamId) + "/" + iter->first + "=" + iter->second + "&");
	}

	//additional stuff
	QUrl url = getUrl();
	data.append(url.encodedQuery());

	// request
	QNetworkRequest request(url);
	// execute
	reply = network.post(request, data);
	connect(reply, SIGNAL(finished()), this, SLOT(parseSettings()));

}
bool cYTFeedParser::ParseFeed(std::string &url)
{
	videos.clear();

	std::string answer;
	curfeedfile = thumbnail_dir;
	curfeedfile += "/";
	curfeedfile += curfeed;
	curfeedfile += ".xml";
#ifdef CACHE_FILES
	if(!DownloadUrl(url, cfile))
		return false;
#else
	if (!getUrl(url, answer))
		return false;
#endif
	return parseFeedJSON(answer);
}
Ejemplo n.º 23
0
LocHisWidget::LocHisWidget(QWidget *parent) :
    QWidget(parent)
{
    search = new LocationHistorySearchWidget();
    results = new LocHisSearchResultsWidget();
    layout = new QVBoxLayout();
    layout->addWidget(search);
    layout->addWidget(results);
    setLayout(layout);

    tracker = new NetTracker();
    connect(search,SIGNAL(request(QUrl)),
            tracker,SLOT(getUrl(QUrl)));
    connect(tracker,SIGNAL(stringRecieved(QString)),
            results,SLOT(stringReply(QString)));
    connect(tracker,SIGNAL(jsonRecieved(QVariant)),
            results,SLOT(jsonReply(QVariant)));
}
Ejemplo n.º 24
0
void WebWidget::updateImageActions()
{
	const bool isImage = !m_hitResult.imageUrl.isEmpty();
	const bool isOpened = getUrl().matches(m_hitResult.imageUrl, (QUrl::NormalizePathSegments | QUrl::RemoveFragment | QUrl::StripTrailingSlash));
	const QString fileName = fontMetrics().elidedText(m_hitResult.imageUrl.fileName(), Qt::ElideMiddle, 256);

	if (m_actions.contains(ActionsManager::OpenImageInNewTabAction))
	{
		m_actions[ActionsManager::OpenImageInNewTabAction]->setOverrideText(isImage ? (fileName.isEmpty() || m_hitResult.imageUrl.scheme() == QLatin1String("data")) ? tr("Open Image in New Tab (Untitled)") : tr("Open Image in New Tab (%1)").arg(fileName) : QT_TRANSLATE_NOOP("actions", "Open Image in New Tab"));
		m_actions[ActionsManager::OpenImageInNewTabAction]->setEnabled(isImage && !isOpened);
	}

	if (m_actions.contains(ActionsManager::OpenImageInNewTabBackgroundAction))
	{
		m_actions[ActionsManager::OpenImageInNewTabBackgroundAction]->setOverrideText(isImage ? (fileName.isEmpty() || m_hitResult.imageUrl.scheme() == QLatin1String("data")) ? tr("Open Image in New Background Tab (Untitled)") : tr("Open Image in New Background Tab (%1)").arg(fileName) : QT_TRANSLATE_NOOP("actions", "Open Image in New Background Tab"));
		m_actions[ActionsManager::OpenImageInNewTabBackgroundAction]->setEnabled(isImage && !isOpened);
	}

	if (m_actions.contains(ActionsManager::SaveImageToDiskAction))
	{
		m_actions[ActionsManager::SaveImageToDiskAction]->setEnabled(isImage);
	}

	if (m_actions.contains(ActionsManager::CopyImageToClipboardAction))
	{
		m_actions[ActionsManager::CopyImageToClipboardAction]->setEnabled(isImage);
	}

	if (m_actions.contains(ActionsManager::CopyImageUrlToClipboardAction))
	{
		m_actions[ActionsManager::CopyImageUrlToClipboardAction]->setEnabled(isImage);
	}

	if (m_actions.contains(ActionsManager::ReloadImageAction))
	{
		m_actions[ActionsManager::ReloadImageAction]->setEnabled(isImage);
	}

	if (m_actions.contains(ActionsManager::ImagePropertiesAction))
	{
		m_actions[ActionsManager::ImagePropertiesAction]->setEnabled(isImage);
	}
}
Ejemplo n.º 25
0
void doMiddle()
/* doMiddle - put up middle part of web page, not including http and html headers/footers */
{
pushWarnHandler(localWarn);
printf("<FORM ACTION=\"../cgi-bin/edwWebSubmit\" METHOD=GET>\n");
struct sqlConnection *conn = edwConnectReadWrite(edwDatabase);
userEmail = edwGetEmailAndVerify();
if (userEmail == NULL)
    logIn();
else if (cgiVarExists(stopButtonName))
    stopUpload(conn);
else if (cgiVarExists("submitUrl"))
    submitUrl(conn);
else if (cgiVarExists("monitor"))
    monitorSubmission(conn);
else
    getUrl(conn);
printf("</FORM>");
}
Ejemplo n.º 26
0
void QtWebKitWebWidget::pageLoadFinished(bool ok)
{
	if (!m_isLoading)
	{
		return;
	}

	m_isLoading = false;

	m_thumbnail = QPixmap();

	m_networkAccessManager->resetStatistics();

	if (m_actions.contains(ReloadOrStopAction))
	{
		QAction *action = getAction(ReloadOrStopAction);

		ActionsManager::setupLocalAction(action, QLatin1String("Reload"));

		action->setShortcut(QKeySequence());
	}

	if (!isPrivate())
	{
		if (ok)
		{
			SessionsManager::markSessionModified();

			if (m_historyEntry >= 0)
			{
				HistoryManager::updateEntry(m_historyEntry, getUrl(), m_webView->title(), m_webView->icon());
			}
		}
		else if (m_historyEntry >= 0)
		{
			HistoryManager::removeEntry(m_historyEntry);
		}
	}


	emit loadingChanged(false);
}
Ejemplo n.º 27
0
void MacMenu::joinSession()
{
	auto dlg = new dialogs::JoinDialog;
	connect(dlg, &dialogs::JoinDialog::finished, [this, dlg](int i) {
		if(i==QDialog::Accepted) {
			QUrl url = dlg->getUrl();

			if(!url.isValid()) {
				// TODO add validator to prevent this from happening
				QMessageBox::warning(0, "Error", "Invalid address");
				return;
			}

			dlg->rememberSettings();

			MainWindow *mw = new MainWindow;
			mw->joinSession(url, dlg->recordSession());
		}
		dlg->deleteLater();
	});
	dlg->show();}
Ejemplo n.º 28
0
void QtWebKitWebWidget::setUrl(const QUrl &url, bool typed)
{
	if (url.scheme() == QLatin1String("javascript"))
	{
		evaluateJavaScript(url.path());

		return;
	}

	if (!url.fragment().isEmpty() && url.matches(getUrl(), (QUrl::RemoveFragment | QUrl::StripTrailingSlash | QUrl::NormalizePathSegments)))
	{
		m_webView->page()->mainFrame()->scrollToAnchor(url.fragment());

		return;
	}

	m_isTyped = typed;

	if (url.isValid() && url.scheme().isEmpty() && !url.path().startsWith('/'))
	{
		QUrl httpUrl = url;
		httpUrl.setScheme(QLatin1String("http"));

		m_webView->setUrl(httpUrl);
	}
	else if (url.isValid() && (url.scheme().isEmpty() || url.scheme() == "file"))
	{
		QUrl localUrl = url;
		localUrl.setScheme(QLatin1String("file"));

		m_webView->setUrl(localUrl);
	}
	else
	{
		m_webView->setUrl(url);
	}

	notifyTitleChanged();
	notifyIconChanged();
}
Ejemplo n.º 29
0
void SlotAssetsMgr::load(AssetsType type, int id, int serverVersion, CCObject* target, SEL_CallFunc successCallFunc, SEL_CallFunc failedCallFunc) {
    string urlpath = getUrl(type, id);
    string filename = AssetsUtil::getFileName(urlpath, true);
    
    // 先检测是否需要重新加载
    CheckNeedLoadResult checkResult = checkNeedLoad(type, urlpath, id, serverVersion);
    if(checkResult == CheckNeedLoad_No) {
        if(target != NULL) (target->*successCallFunc)();
        return;
    }
    
    string saveDir = getDirByRelativePath(getResRelativePath(type, id));
    
    if(isLoading(urlpath)) {
        CCLOG("[info] url: %s is loading... ", urlpath.data());
        return;
    }
    
    double totalSize = 0;
    //只处理zip文件的断点恢复
    if(string::npos != urlpath.find(".zip")) {
        totalSize = HttpMgr::getInstance()->getUrlFileSize(urlpath);
        if(totalSize > 0) {
            LoadInfoMgr::getInstance()->setInfo(urlpath, totalSize, serverVersion);
        }else {
            if(target != NULL) {
                (target->*failedCallFunc)();
                return;
            }
        }
    }
    
    bool isToResume = (checkResult == CheckNeedLoad_Resume);
    AssetsLoader* loader = new AssetsLoader(urlpath, saveDir, this);
    long initSize = isToResume ? FileUtil::getFileSize(loader->getFilePath().data()) : 0;
    _loaderList->push_back(new LoaderItem(loader,serverVersion, target, successCallFunc, failedCallFunc));
    loader->setInfo(isToResume, initSize);
    loader->startLoad();
}
Ejemplo n.º 30
0
void Window::focusInEvent(QFocusEvent *event)
{
	QWidget::focusInEvent(event);

	if (m_suspendTimer > 0)
	{
		killTimer(m_suspendTimer);

		m_suspendTimer = 0;
	}

	AddressWidget *addressWidget(findAddressWidget());

	if (Utils::isUrlEmpty(getUrl()) && (!m_contentsWidget || m_contentsWidget->getLoadingState() != WebWidget::OngoingLoadingState) && addressWidget)
	{
		addressWidget->setFocus();
	}
	else if (m_contentsWidget)
	{
		m_contentsWidget->setFocus();
	}
}