//replace html url Q_FOREACH ( const QgsComposerHtml *currentHtml, composerHtmls ) { QgsComposerHtml * html = const_cast<QgsComposerHtml *>( currentHtml ); QgsComposerFrame *htmlFrame = html->frame( 0 ); QString htmlId = htmlFrame->id(); QString url = parameterMap.value( htmlId.toUpper() ); if ( url.isEmpty() ) { //remove exported Htmls referenced in the request //but with empty string if ( parameterMap.contains( htmlId.toUpper() ) ) { c->removeMultiFrame( html ); delete currentHtml; } else { html->update(); } continue; } QUrl newUrl( url ); html->setUrl( newUrl ); html->update(); }
int main(int argc, char **argv){ substr("test string",0,1); Url u = newUrl("http://*****:*****@www.google.com/?q=ansi"); debugUrl(&u); freeUrl(&u); }
void tab::createConnects() { connect(urlAddress, SIGNAL(returnPressed()), this, SLOT(newUrl())); connect(addressCompleter, SIGNAL(itemChoosed(QString)), this, SLOT(newUrl(QString))); connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl))); connect(webView, SIGNAL(titleChanged(QString)), this, SLOT(chTitle(QString))); connect(webView, SIGNAL(iconChanged()), this, SLOT(chIcon())); connect(webView, SIGNAL(statusBarMessage(QString)), this, SLOT(statusBarMessage(QString))); connect(webView, SIGNAL(selectionChanged()), this, SLOT(selectionChange())); connect(webView, SIGNAL(loadStarted()), this, SLOT(loadStart())); connect(webView, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int))); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinish(bool))); connect(webView, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClick(QUrl))); connect(webView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequest(QPoint))); connect(webView->page(), SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(downloadRequest(QNetworkReply*))); connect(webView->page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequset(QNetworkRequest))); connect(webView->page(), SIGNAL(printRequested(QWebFrame*)), this, SLOT(printPage(QWebFrame*))); }
void KDirListerV2Private::addUrl(QString url, KDirListerV2::OpenUrlFlags flags) { // We take a different path if we want to reload a url that is currently being monitored. // Otherwise we add a new url if(m_urlToIndex.contains(url) && flags.testFlag(KDirListerV2::Reload)) { removeUrlBookkeepingAndData(url); } newUrl(url); }
bool Downloader::request(const QString& theMethod, const QUrl& url, const QString& theData, bool FireForget) { if (Error) return false; qDebug() << "Downloader::request: " << url; netManager.setProxy(M_PREFS->getProxy(url)); QNetworkRequest req(url); req.setRawHeader(QByteArray("Content-Type"), QByteArray("text/xml")); req.setRawHeader(QByteArray("User-Agent"), USER_AGENT.toLatin1()); QByteArray dataArray(theData.toUtf8()); QBuffer dataBuffer(&dataArray); currentReply = netManager.sendCustomRequest(req, theMethod.toLatin1(), &dataBuffer); if (AnimationTimer) { AnimationTimer->start(200); connect(currentReply,SIGNAL(downloadProgress(qint64, qint64)), this,SLOT(progress(qint64, qint64))); } if (FireForget) return true; if (Loop.exec() == QDialog::Rejected) return false; if (AnimationTimer) SAFE_DELETE(AnimationTimer); /* Test for redirections */ QVariant redir = currentReply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (redir.isValid()) { LocationText = redir.toString(); if (!LocationText.isEmpty()) { QUrl newUrl(LocationText); return request(theMethod, newUrl, theData, FireForget); } } /* Handler error? */ if (currentReply->error()) QMessageBox::information(0,tr("error"), currentReply->errorString()); /* Read the data */ Content = currentReply->readAll(); Result = currentReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); ResultText = currentReply->errorString(); ErrorText = currentReply->rawHeader("Error"); return !Error; }
Url::Url(chstr url) : valid(false), port(0), queryDelimiter('&') { if (url == "") { hlog::warn(logTag, "URL cannot be empty!"); return; } hstr newUrl = url; if (url.startsWith(HTTP_SCHEME)) { newUrl = newUrl(strlen(HTTP_SCHEME), -1); } this->host = newUrl; int index = 0; hstr query; hstr* current = &this->host; hstr* next = NULL; harray<hstr*> parts; parts += &this->path; parts += &query; parts += &this->fragment; harray<char> chars; chars += '/'; chars += '?'; chars += '#'; while (parts.size() > 0) { index = newUrl.indexOf(chars.removeFirst()); next = parts.removeFirst(); if (index >= 0) { *current = newUrl(0, index); *next = newUrl = newUrl(index, -1); current = next; } } this->_checkValues(query); }
// Perform searches and replacements on URL bool HTTPHeader::urlRegExp(int filtergroup) { // exit immediately if list is empty if (not o.fg[filtergroup]->url_regexp_list_comp.size()) return false; #ifdef DGDEBUG std::cout << "Starting URL reg exp replace" << std::endl; #endif String newUrl(url()); if (regExp(newUrl, o.fg[filtergroup]->url_regexp_list_comp, o.fg[filtergroup]->url_regexp_list_rep)) { setURL(newUrl); return true; } return false; }
void ImageshackUploader::parseReply(const QByteArray &text) { // QFile file("d:/result.txt"); // file.open(QIODevice::WriteOnly); // file.write(text); // file.close(); // QFile file("d:/result-imageshack.htm"); // file.open(QIODevice::ReadOnly); // QByteArray text = file.readAll(); // file.close(); QSgml parser; parser.String2Sgml(text); if ( text.contains("error id=") ) { QString mess; // <error id="auth_error">You must provide a valid auth token or dev key. see http://code.google.com/p/imageshackapi/</error> for(QSgml::iterator i = parser.begin(); i!=parser.end(); ++i ) if (i->Name == "error") { if ( !i->Children.isEmpty() ) mess = i->Children[0]->Value; break; } LogHandler::getInstance()->reportError( tr("%1 service reply with error (%2)").arg(m_name).arg(mess) ); return; } //<links> // <image_link>http://img221.imageshack.us/img221/3412/latotale.png</image_link> // <image_html><a href="http://img221.imageshack.us/i/latotale.png/" target=&q ... // ... for(QSgml::iterator i = parser.begin(); i!=parser.end(); ++i ) if (i->Name == "image_link") { if ( !i->Children.isEmpty() ) { m_url = i->Children[0]->Value; emit newUrl(m_url); break; } } }
RequestDataJob::RequestDataJob(const QUrl& url, QOAuth::HttpMethod method, QOAuth::ParamMap paramMap, QObject* parent) : QObject(parent) ,m_inlineString(moeApp->inlineString (paramMap, QOAuth::ParseForRequestContent)) ,m_request(url) ,m_method(method) { if (method == QOAuth::POST) { m_request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); for (QOAuth::ParamMap::iterator it = paramMap.begin(); it != paramMap.end(); it++) { it.value() = QUrl::toPercentEncoding(QString::fromUtf8(it.value())); } m_request.setRawHeader("Authorization", moeApp->createParametersString(m_request.url(), method, paramMap, QOAuth::ParseForRequestContent)); } else if (method == QOAuth::GET) { QUrl newUrl(url.toString().append(moeApp->createParametersString(m_request.url(), method, paramMap, QOAuth::ParseForInlineQuery))); m_request.setUrl(newUrl); // qDebug() << m_request.url(); } }
void ParserCWHandler::updateRequest( MC2String& urlStr, LangTypes::language_t clientLang ) const { const char* instance = Properties::getProperty( "WF_INSTANCE", "eu" ); for ( repmap::const_iterator it = m_repurls.begin() ; it != m_repurls.end() ; ++it ) { if ( urlStr.find( (*it).first ) != MC2String::npos ) { MC2String rstr( (*it).second.replaceWith ); STLStringUtility::replaceString( rstr, "[INSTANCE]", instance ); STLStringUtility::replaceString( urlStr, (*it).first, rstr.c_str() ); if ( (*it).second.defaultPage != "" ) { // Check if no page then replace with defaultPage URL url( urlStr ); MC2String file( url.getFile() ); if ( file.size() > 0 && file[ file.size() -1 ] == '/' ) { MC2String path( url.getPath() ); MC2String::size_type qPos = path.find( '?' ); if ( qPos == MC2String::npos ) { qPos = path.find( '#' ); } MC2String params; if ( qPos != MC2String::npos ) { params = path.substr( qPos ); } MC2String defaultPage( url.getFile() ); defaultPage.append( (*it).second.defaultPage ); defaultPage.append( params ); // ?u=... // TODO: Convert clientLang to languageCode and back // to get only translated languages (There is a webpage). STLStringUtility::replaceString( defaultPage, "[ISO639-1]", LangTypes::getLanguageAsISO639( clientLang ) ); URL newUrl( url.getProto(), url.getHost(), url.getPort(), defaultPage.c_str() ); urlStr = newUrl.getSpec(); } } } } }
void QgsComposerHtmlWidget::on_mUrlLineEdit_editingFinished() { if ( mHtml ) { QUrl newUrl( mUrlLineEdit->text() ); if ( newUrl == mHtml->url() ) { return; } QgsComposition* composition = mHtml->composition(); if ( composition ) { composition->beginMultiFrameCommand( mHtml, tr( "Change html url" ) ); mHtml->setUrl( newUrl ); mHtml->update(); composition->endMultiFrameCommand(); } } }
void QUrl::decode( QString& url ) { if ( url.isEmpty() ) return; int newlen = 0; QCString curl = url.utf8(); int oldlen = curl.length(); QCString newUrl(oldlen); int i = 0; while ( i < oldlen ) { uchar c = (uchar)curl[ i++ ]; if ( c == '%' && i <= oldlen - 2 ) { c = hex_to_int( (uchar)curl[ i ] ) * 16 + hex_to_int( (uchar)curl[ i + 1 ] ); i += 2; } newUrl [ newlen++ ] = c; } newUrl.truncate( newlen ); url = QString::fromUtf8(newUrl.data()); }
// Method executed when the user ends the wizard, either with 'accept' or 'reject'. // accept the custom config to be the main one if Accepted. void OwncloudSetupWizard::slotAssistantFinished( int result ) { MirallConfigFile cfg( _configHandle ); if( result == QDialog::Rejected ) { // the old config remains valid. Remove the temporary one. cfg.cleanupCustomConfig(); qDebug() << "Rejected the new config, use the old!"; } else if( result == QDialog::Accepted ) { qDebug() << "Config Changes were accepted!"; // go through all folders and remove the journals if the server changed. MirallConfigFile prevCfg; QUrl prevUrl( prevCfg.ownCloudUrl() ); QUrl newUrl( cfg.ownCloudUrl() ); bool urlHasChanged = (prevUrl.host() != newUrl.host() || prevUrl.path() != newUrl.path()); // if the user changed, its also a changed url. if( prevCfg.ownCloudUser() != cfg.ownCloudUser() ) { urlHasChanged = true; qDebug() << "The User has changed, same as url change."; } const QString localFolder = _ocWizard->localFolder(); bool acceptCfg = true; if( urlHasChanged ) { _folderMan->unloadAllFolders(); bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool(); if( startFromScratch ) { // first try to rename (backup) the current local dir. bool renameOk = false; while( !renameOk ) { renameOk = _folderMan->startFromScratch(localFolder); if( ! renameOk ) { QMessageBox::StandardButton but; but = QMessageBox::question( 0, tr("Folder rename failed"), tr("Can't remove and back up the folder because the folder or a file in it is open in another program." "Please close the folder or file and hit retry or cancel the setup."), QMessageBox::Retry | QMessageBox::Abort, QMessageBox::Retry); if( but == QMessageBox::Abort ) { renameOk = true; acceptCfg = false; } } } } } // save the user credentials and afterwards clear the cred store. if( acceptCfg ) { cfg.acceptCustomConfig(); } // Now write the resulting folder definition if folder names are set. if( acceptCfg && urlHasChanged ) { _folderMan->removeAllFolderDefinitions(); _folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(), localFolder, _remoteFolder, false ); _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder)); } else { // url is unchanged. Only the password was changed. if( acceptCfg ) { qDebug() << "Only password was changed, no changes to folder configuration."; } else { qDebug() << "User interrupted change of configuration."; } } } // clear the custom config handle _configHandle.clear(); ownCloudInfo::instance()->setCustomConfigHandle( QString::null ); // notify others. emit ownCloudWizardDone( result ); }
// Method executed when the user ends the wizard, either with 'accept' or 'reject'. // accept the custom config to be the main one if Accepted. void OwncloudSetupWizard::slotAssistantFinished( int result ) { MirallConfigFile cfg( _configHandle ); if( result == QDialog::Rejected ) { // the old config remains valid. Remove the temporary one. cfg.cleanupCustomConfig(); qDebug() << "Rejected the new config, use the old!"; } else if( result == QDialog::Accepted ) { qDebug() << "Config Changes were accepted!"; // go through all folders and remove the journals if the server changed. MirallConfigFile prevCfg; QUrl prevUrl( prevCfg.ownCloudUrl() ); QUrl newUrl( cfg.ownCloudUrl() ); bool urlHasChanged = (prevUrl.host() != newUrl.host() || prevUrl.path() != newUrl.path()); // if the user changed, its also a changed url. if( prevCfg.ownCloudUser() != cfg.ownCloudUser() ) { urlHasChanged = true; qDebug() << "The User has changed, same as url change."; } // save the user credentials and afterwards clear the cred store. cfg.acceptCustomConfig(); // Now write the resulting folder definition if folder names are set. const QString localFolder = _ocWizard->localFolder(); if( !( localFolder.isEmpty() || _remoteFolder.isEmpty() ) ) { // both variables are set. if( urlHasChanged ) { _folderMan->removeAllFolderDefinitions(); _folderMan->addFolderDefinition( QLatin1String("owncloud"), Theme::instance()->appName(), localFolder, _remoteFolder, false ); _ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder)); bool startFromScratch = _ocWizard->field( "OCSyncFromScratch" ).toBool(); if( startFromScratch ) { // clean the entire directory. if( _folderMan->startFromScratch( localFolder ) ) { _ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully prepared syncing from scratch!</font>")); } else { _ocWizard->appendToConfigurationLog(tr("<font color=\"red\">Failed to prepare syncing from scratch!</font>")); } } } else { // url is unchanged. Only the password was changed. qDebug() << "Only password was changed, no changes to folder configuration."; } } } else { qDebug() << "WRN: Got unknown dialog result code " << result; } // clear the custom config handle _configHandle.clear(); ownCloudInfo::instance()->setCustomConfigHandle( QString::null ); // notify others. emit ownCloudWizardDone( result ); }
void WebCrawlerDialog::gatherData(){ qDebug()<< "WebCrawlerDialog::gatherData()..."; bool extLinks=true, intLinks=false; QString seedUrl = (ui.seedUrlEdit)->text(); qDebug()<< "WebCrawlerDialog::gatherData() initial seed url " << seedUrl << " simplifying and lowering it"; seedUrl = seedUrl.simplified().toLower() ; qDebug()<< "WebCrawlerDialog::gatherData() adding / to seed url "; seedUrl = seedUrl + "/"; QUrl newUrl(seedUrl); qDebug()<< "WebCrawlerDialog::gatherData() QUrl " << newUrl.toString() << " scheme " << newUrl.scheme() << " host " << newUrl.host() << " path " << newUrl.path(); if ( newUrl.scheme() != "http" && newUrl.scheme() != "https" && newUrl.scheme() != "ftp" && newUrl.scheme() != "ftps") { qDebug()<< "WebCrawlerDialog::gatherData() URL scheme missing " << newUrl.scheme() << " setting the default scheme http "; newUrl = QUrl ("http://" + seedUrl); qDebug() << newUrl; } if (! newUrl.isValid() || newUrl.host() == "") { emit webCrawlerDialogError(seedUrl); qDebug()<< "WebCrawlerDialog::gatherData() not valid URL"; return; } seedUrl = newUrl.toString(); qDebug()<< "WebCrawlerDialog::gatherData() final seed url " << newUrl << " scheme " << newUrl.scheme() << " host " << newUrl.host() << " path " << newUrl.path(); int maxLinksPerPage = (ui.maxLinksPerPageSpinBox) -> value(); int totalUrlsToCrawl = (ui.totalUrlsToCrawlSpinBox) -> value(); if ( ui.extLinksCheckBox -> isChecked() ) { qDebug()<< " External links will be crawled... " ; extLinks = true; } else { qDebug()<< " No external links... "; extLinks = false; } if ( ui.intLinksCheckBox -> isChecked() ) { qDebug()<< " Internal links will be crawled too. " ; intLinks = true; } else { qDebug()<< " No internal links. "; intLinks = false; if (!intLinks && !extLinks) return; } qDebug()<< " seedUrl: " << seedUrl; qDebug()<< " maxLinksPerPage " << maxLinksPerPage << " totalUrlsToCrawl " << totalUrlsToCrawl ; emit userChoices( seedUrl, totalUrlsToCrawl, maxLinksPerPage, extLinks, intLinks ); }