diff options
Diffstat (limited to 'src/fetch/ibsfetcher.cpp')
-rw-r--r-- | src/fetch/ibsfetcher.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/src/fetch/ibsfetcher.cpp b/src/fetch/ibsfetcher.cpp index 4c86ef3..3c3d82e 100644 --- a/src/fetch/ibsfetcher.cpp +++ b/src/fetch/ibsfetcher.cpp @@ -64,9 +64,9 @@ void IBSFetcher::search(FetchKey key_, const TQString& value_) { m_matches.clear(); #ifdef IBS_TEST - KURL u = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/ibs.html")); + KURL u = KURL::fromPathOrURL(TQString::fromLatin1("/home/robby/ibs.html")); #else - KURL u(TQString::tqfromLatin1(IBS_BASE_URL)); + KURL u(TQString::fromLatin1(IBS_BASE_URL)); if(!canFetch(Kernel::self()->collectionType())) { message(i18n("%1 does not allow searching for this collection type.").tqarg(source()), MessageHandler::Warning); @@ -76,13 +76,13 @@ void IBSFetcher::search(FetchKey key_, const TQString& value_) { switch(key_) { case Title: - u.addQueryItem(TQString::tqfromLatin1("Type"), TQString::tqfromLatin1("keyword")); - u.addQueryItem(TQString::tqfromLatin1("T"), value_); + u.addQueryItem(TQString::fromLatin1("Type"), TQString::fromLatin1("keyword")); + u.addQueryItem(TQString::fromLatin1("T"), value_); break; case Person: - u.addQueryItem(TQString::tqfromLatin1("Type"), TQString::tqfromLatin1("keyword")); - u.addQueryItem(TQString::tqfromLatin1("A"), value_); + u.addQueryItem(TQString::fromLatin1("Type"), TQString::fromLatin1("keyword")); + u.addQueryItem(TQString::fromLatin1("A"), value_); break; case ISBN: @@ -91,14 +91,14 @@ void IBSFetcher::search(FetchKey key_, const TQString& value_) { s.remove('-'); // limit to first isbn s = s.section(';', 0, 0); - u.setFileName(TQString::tqfromLatin1("serdsp.asp")); - u.addQueryItem(TQString::tqfromLatin1("isbn"), s); + u.setFileName(TQString::fromLatin1("serdsp.asp")); + u.addQueryItem(TQString::fromLatin1("isbn"), s); } break; case Keyword: - u.addQueryItem(TQString::tqfromLatin1("Type"), TQString::tqfromLatin1("keyword")); - u.addQueryItem(TQString::tqfromLatin1("S"), value_); + u.addQueryItem(TQString::fromLatin1("Type"), TQString::fromLatin1("keyword")); + u.addQueryItem(TQString::fromLatin1("S"), value_); break; default: @@ -156,12 +156,12 @@ void IBSFetcher::slotComplete(KIO::Job* job_) { TQString s = Tellico::decodeHTML(TQString(m_data)); // really specific regexp - TQString pat = TQString::tqfromLatin1("http://www.internetbookshop.it/code/"); - TQRegExp anchorRx(TQString::tqfromLatin1("<a\\s+[^>]*href\\s*=\\s*[\"'](") + + TQString pat = TQString::fromLatin1("http://www.internetbookshop.it/code/"); + TQRegExp anchorRx(TQString::fromLatin1("<a\\s+[^>]*href\\s*=\\s*[\"'](") + TQRegExp::escape(pat) + - TQString::tqfromLatin1("[^\"]*)\"[^>]*><b>([^<]+)<"), false); + TQString::fromLatin1("[^\"]*)\"[^>]*><b>([^<]+)<"), false); anchorRx.setMinimal(true); - TQRegExp tagRx(TQString::tqfromLatin1("<.*>")); + TQRegExp tagRx(TQString::fromLatin1("<.*>")); tagRx.setMinimal(true); TQString u, t, d; @@ -172,10 +172,10 @@ void IBSFetcher::slotComplete(KIO::Job* job_) { emit signalResultFound(r); #ifdef IBS_TEST - KURL url = KURL::fromPathOrURL(TQString::tqfromLatin1("/home/robby/ibs2.html")); + KURL url = KURL::fromPathOrURL(TQString::fromLatin1("/home/robby/ibs2.html")); #else // the url probable contains & so be careful - KURL url = u.replace(TQString::tqfromLatin1("&"), TQChar('&')); + KURL url = u.replace(TQString::fromLatin1("&"), TQChar('&')); #endif m_matches.insert(r->uid, url); @@ -185,9 +185,9 @@ void IBSFetcher::slotComplete(KIO::Job* job_) { } u = anchorRx.cap(1); t = anchorRx.cap(2); - pos2 = s.find(TQString::tqfromLatin1("<br>"), pos, false); + pos2 = s.find(TQString::fromLatin1("<br>"), pos, false); if(pos2 > -1) { - int pos3 = s.find(TQString::tqfromLatin1("<br>"), pos2+1, false); + int pos3 = s.find(TQString::fromLatin1("<br>"), pos2+1, false); if(pos3 > -1) { d = s.mid(pos2, pos3-pos2).remove(tagRx).simplifyWhiteSpace(); } @@ -197,7 +197,7 @@ void IBSFetcher::slotComplete(KIO::Job* job_) { if(!u.isEmpty()) { SearchResult* r = new SearchResult(this, t, d, TQString()); emit signalResultFound(r); - m_matches.insert(r->uid, u.replace(TQString::tqfromLatin1("&"), TQChar('&'))); + m_matches.insert(r->uid, u.replace(TQString::fromLatin1("&"), TQChar('&'))); } #endif @@ -221,15 +221,15 @@ void IBSFetcher::slotCompleteISBN(KIO::Job* job_) { } TQString str = Tellico::decodeHTML(TQString(m_data)); - if(str.find(TQString::tqfromLatin1("Libro non presente"), 0, false /* cas-sensitive */) > -1) { + if(str.find(TQString::fromLatin1("Libro non presente"), 0, false /* cas-sensitive */) > -1) { stop(); return; } Data::EntryPtr entry = parseEntry(str); if(entry) { - TQString desc = entry->field(TQString::tqfromLatin1("author")) - + '/' + entry->field(TQString::tqfromLatin1("publisher")); - SearchResult* r = new SearchResult(this, entry->title(), desc, entry->field(TQString::tqfromLatin1("isbn"))); + TQString desc = entry->field(TQString::fromLatin1("author")) + + '/' + entry->field(TQString::fromLatin1("publisher")); + SearchResult* r = new SearchResult(this, entry->title(), desc, entry->field(TQString::fromLatin1("isbn"))); emit signalResultFound(r); m_matches.insert(r->uid, static_cast<KIO::TransferJob*>(job_)->url().url()); } @@ -259,7 +259,7 @@ Tellico::Data::EntryPtr IBSFetcher::fetchEntry(uint uid_) { // myDebug() << url.url() << endl; #if 0 kdWarning() << "Remove debug from ibsfetcher.cpp" << endl; - TQFile f(TQString::tqfromLatin1("/tmp/test.html")); + TQFile f(TQString::fromLatin1("/tmp/test.html")); if(f.open(IO_WriteOnly)) { TQTextStream t(&f); t.setEncoding(TQTextStream::UnicodeUTF8); @@ -280,9 +280,9 @@ Tellico::Data::EntryPtr IBSFetcher::fetchEntry(uint uid_) { Tellico::Data::EntryPtr IBSFetcher::parseEntry(const TQString& str_) { // myDebug() << "IBSFetcher::parseEntry()" << endl; // class might be anime_info_top - TQString pat = TQString::tqfromLatin1("%1(?:<[^>]+>)+([^<>\\s][^<>]+)"); + TQString pat = TQString::fromLatin1("%1(?:<[^>]+>)+([^<>\\s][^<>]+)"); - TQRegExp isbnRx(TQString::tqfromLatin1("isbn=([\\dxX]{13})"), false); + TQRegExp isbnRx(TQString::fromLatin1("isbn=([\\dxX]{13})"), false); TQString isbn; int pos = isbnRx.search(str_); if(pos > -1) { @@ -293,15 +293,15 @@ Tellico::Data::EntryPtr IBSFetcher::parseEntry(const TQString& str_) { // map captions in HTML to field names TQMap<TQString, TQString> fieldMap; - fieldMap.insert(TQString::tqfromLatin1("Titolo"), TQString::tqfromLatin1("title")); - fieldMap.insert(TQString::tqfromLatin1("Autore"), TQString::tqfromLatin1("author")); - fieldMap.insert(TQString::tqfromLatin1("Anno"), TQString::tqfromLatin1("pub_year")); - fieldMap.insert(TQString::tqfromLatin1("Categoria"), TQString::tqfromLatin1("genre")); - fieldMap.insert(TQString::tqfromLatin1("Rilegatura"), TQString::tqfromLatin1("binding")); - fieldMap.insert(TQString::tqfromLatin1("Editore"), TQString::tqfromLatin1("publisher")); - fieldMap.insert(TQString::tqfromLatin1("Dati"), TQString::tqfromLatin1("edition")); - - TQRegExp pagesRx(TQString::tqfromLatin1("(\\d+) p\\.(\\s*,\\s*)?")); + fieldMap.insert(TQString::fromLatin1("Titolo"), TQString::fromLatin1("title")); + fieldMap.insert(TQString::fromLatin1("Autore"), TQString::fromLatin1("author")); + fieldMap.insert(TQString::fromLatin1("Anno"), TQString::fromLatin1("pub_year")); + fieldMap.insert(TQString::fromLatin1("Categoria"), TQString::fromLatin1("genre")); + fieldMap.insert(TQString::fromLatin1("Rilegatura"), TQString::fromLatin1("binding")); + fieldMap.insert(TQString::fromLatin1("Editore"), TQString::fromLatin1("publisher")); + fieldMap.insert(TQString::fromLatin1("Dati"), TQString::fromLatin1("edition")); + + TQRegExp pagesRx(TQString::fromLatin1("(\\d+) p\\.(\\s*,\\s*)?")); Data::EntryPtr entry = new Data::Entry(coll); for(TQMap<TQString, TQString>::Iterator it = fieldMap.begin(); it != fieldMap.end(); ++it) { @@ -311,7 +311,7 @@ Tellico::Data::EntryPtr IBSFetcher::parseEntry(const TQString& str_) { if(it.data() == Latin1Literal("edition")) { int pos2 = pagesRx.search(infoRx.cap(1)); if(pos2 > -1) { - entry->setField(TQString::tqfromLatin1("pages"), pagesRx.cap(1)); + entry->setField(TQString::fromLatin1("pages"), pagesRx.cap(1)); entry->setField(it.data(), infoRx.cap(1).remove(pagesRx)); } else { entry->setField(it.data(), infoRx.cap(1)); @@ -324,44 +324,44 @@ Tellico::Data::EntryPtr IBSFetcher::parseEntry(const TQString& str_) { // image if(!isbn.isEmpty()) { - entry->setField(TQString::tqfromLatin1("isbn"), isbn); + entry->setField(TQString::fromLatin1("isbn"), isbn); #if 1 - TQString imgURL = TQString::tqfromLatin1("http://giotto.ibs.it/cop/copt13.asp?f=%1").tqarg(isbn); + TQString imgURL = TQString::fromLatin1("http://giotto.ibs.it/cop/copt13.asp?f=%1").tqarg(isbn); myLog() << "IBSFetcher() - cover = " << imgURL << endl; - TQString id = ImageFactory::addImage(imgURL, true, TQString::tqfromLatin1("http://internetbookshop.it")); + TQString id = ImageFactory::addImage(imgURL, true, TQString::fromLatin1("http://internetbookshop.it")); if(!id.isEmpty()) { - entry->setField(TQString::tqfromLatin1("cover"), id); + entry->setField(TQString::fromLatin1("cover"), id); } #else - TQRegExp imgRx(TQString::tqfromLatin1("<img\\s+[^>]*\\s*src\\s*=\\s*\"(http://[^/]*\\.ibs\\.it/[^\"]+e=%1)").tqarg(isbn)); + TQRegExp imgRx(TQString::fromLatin1("<img\\s+[^>]*\\s*src\\s*=\\s*\"(http://[^/]*\\.ibs\\.it/[^\"]+e=%1)").tqarg(isbn)); imgRx.setMinimal(true); pos = imgRx.search(str_); if(pos > -1) { myLog() << "IBSFetcher() - cover = " << imgRx.cap(1) << endl; - TQString id = ImageFactory::addImage(imgRx.cap(1), true, TQString::tqfromLatin1("http://internetbookshop.it")); + TQString id = ImageFactory::addImage(imgRx.cap(1), true, TQString::fromLatin1("http://internetbookshop.it")); if(!id.isEmpty()) { - entry->setField(TQString::tqfromLatin1("cover"), id); + entry->setField(TQString::fromLatin1("cover"), id); } } #endif } // now look for description - TQRegExp descRx(TQString::tqfromLatin1("Descrizione(?:<[^>]+>)+([^<>\\s].+)</span>"), false); + TQRegExp descRx(TQString::fromLatin1("Descrizione(?:<[^>]+>)+([^<>\\s].+)</span>"), false); descRx.setMinimal(true); pos = descRx.search(str_); if(pos == -1) { - descRx.setPattern(TQString::tqfromLatin1("In sintesi(?:<[^>]+>)+([^<>\\s].+)</span>")); + descRx.setPattern(TQString::fromLatin1("In sintesi(?:<[^>]+>)+([^<>\\s].+)</span>")); pos = descRx.search(str_); } if(pos > -1) { - Data::FieldPtr f = new Data::Field(TQString::tqfromLatin1("plot"), i18n("Plot Summary"), Data::Field::Para); + Data::FieldPtr f = new Data::Field(TQString::fromLatin1("plot"), i18n("Plot Summary"), Data::Field::Para); coll->addField(f); entry->setField(f, descRx.cap(1).simplifyWhiteSpace()); } // IBS switches the surname and family name of the author - TQStringList names = entry->fields(TQString::tqfromLatin1("author"), false); + TQStringList names = entry->fields(TQString::fromLatin1("author"), false); if(!names.isEmpty() && !names[0].isEmpty()) { for(TQStringList::Iterator it = names.begin(); it != names.end(); ++it) { if((*it).find(',') > -1) { @@ -376,18 +376,18 @@ Tellico::Data::EntryPtr IBSFetcher::parseEntry(const TQString& str_) { words.pop_front(); *it = words.join(TQChar(' ')); } - entry->setField(TQString::tqfromLatin1("author"), names.join(TQString::tqfromLatin1("; "))); + entry->setField(TQString::fromLatin1("author"), names.join(TQString::fromLatin1("; "))); } return entry; } void IBSFetcher::updateEntry(Data::EntryPtr entry_) { - TQString isbn = entry_->field(TQString::tqfromLatin1("isbn")); + TQString isbn = entry_->field(TQString::fromLatin1("isbn")); if(!isbn.isEmpty()) { search(Fetch::ISBN, isbn); return; } - TQString t = entry_->field(TQString::tqfromLatin1("title")); + TQString t = entry_->field(TQString::fromLatin1("title")); if(!t.isEmpty()) { search(Fetch::Title, t); return; |