void VideoFindProxy::HandleAction () { QUrl url = qobject_cast<QAction*> (sender ())->data ().value<QUrl> (); QString fname = Util::GetTemporaryName (); Entity e = Util::MakeEntity (url, fname, LeechCraft::Internal | LeechCraft::DoNotNotifyUser | LeechCraft::DoNotSaveInHistory | LeechCraft::NotPersistent | LeechCraft::DoNotAnnounceEntity); int id = -1; QObject *pr = 0; emit delegateEntity (e, &id, &pr); if (id == -1) { emit error (tr ("Job for request<br />%1<br />wasn't delegated.") .arg (url.toString ())); return; } Jobs_ [id] = fname; HandleProvider (pr); }
void Plugin::handleDownload (QUrl url) { const QString& temp = Util::GetTemporaryName ("agg_bodyfetcher"); const Entity& e = Util::MakeEntity (url, temp, Internal | DoNotNotifyUser | DoNotSaveInHistory | OnlyDownload | NotPersistent); int id = -1; QObject *obj = 0; emit delegateEntity (e, &id, &obj); if (id == -1) { qWarning () << Q_FUNC_INFO << "delegation failed"; return; } Jobs_ [id] = qMakePair (url, temp); connect (obj, SIGNAL (jobFinished (int)), this, SLOT (handleJobFinished (int)), Qt::UniqueConnection); }
void RepoInfoFetcher::FetchPackageInfo (const QUrl& baseUrl, const QString& packageName, const QList<QString>& newVersions, int componentId) { QString location = Util::GetTemporaryName ("lackman_XXXXXX.gz"); QUrl packageUrl = baseUrl; packageUrl.setPath (packageUrl.path () + Core::Instance ().NormalizePackageName (packageName) + ".xml.gz"); PendingPackage pp = { packageUrl, baseUrl, location, packageName, newVersions, componentId }; Entity e = Util::MakeEntity (packageUrl, location, LeechCraft::Internal | LeechCraft::DoNotNotifyUser | LeechCraft::DoNotSaveInHistory | LeechCraft::NotPersistent | LeechCraft::DoNotAnnounceEntity); int id = -1; QObject *pr; emit delegateEntity (e, &id, &pr); if (id == -1) { emit gotEntity (Util::MakeNotification (tr ("Error fetching package information"), tr ("Could not find plugin to fetch package information at %1.") .arg (packageUrl.toString ()), PCritical_)); return; } PendingPackages_ [id] = pp; connect (pr, SIGNAL (jobFinished (int)), this, SLOT (handlePackageFinished (int)), Qt::UniqueConnection); connect (pr, SIGNAL (jobRemoved (int)), this, SLOT (handlePackageRemoved (int)), Qt::UniqueConnection); connect (pr, SIGNAL (jobError (int, IDownload::Error)), this, SLOT (handlePackageError (int, IDownload::Error)), Qt::UniqueConnection); }
void Core::Handle (LeechCraft::Entity e) { QUrl url = e.Entity_.toUrl (); if (e.Mime_ == "text/x-opml") { if (url.scheme () == "file") StartAddingOPML (url.toLocalFile ()); else { QString name = LeechCraft::Util::GetTemporaryName (); LeechCraft::Entity e = Util::MakeEntity (url, name, LeechCraft::Internal | LeechCraft::DoNotNotifyUser | LeechCraft::DoNotSaveInHistory | LeechCraft::NotPersistent | LeechCraft::DoNotAnnounceEntity); PendingOPML po = { name }; int id = -1; QObject *pr; emit delegateEntity (e, &id, &pr); if (id == -1) { ErrorNotification (tr ("Import error"), tr ("Could not find plugin to download OPML %1.") .arg (url.toString ())); return; } HandleProvider (pr, id); PendingOPMLs_ [id] = po; } QMap<QString, QVariant> s = e.Additional_; if (s.contains ("ShowTrayIcon")) XmlSettingsManager::Instance ()->setProperty ("ShowIconInTray", s.value ("ShowIconInTray").toBool ()); if (s.contains ("UpdateOnStartup")) XmlSettingsManager::Instance ()->setProperty ("UpdateOnStartup", s.value ("UpdateOnStartup").toBool ()); if (s.contains ("UpdateTimeout")) XmlSettingsManager::Instance ()->setProperty ("UpdateInterval", s.value ("UpdateTimeout").toInt ()); if (s.contains ("MaxArticles")) XmlSettingsManager::Instance ()->setProperty ("ItemsPerChannel", s.value ("MaxArticles").toInt ()); if (s.contains ("MaxAge")) XmlSettingsManager::Instance ()->setProperty ("ItemsMaxAge", s.value ("MaxAge").toInt ()); } else { QString str = url.toString (); if (str.startsWith ("feed://")) str.replace (0, 4, "http"); else if (str.startsWith ("feed:")) str.remove (0, 5); else if (str.startsWith ("itpc://")) str.replace (0, 4, "http"); LeechCraft::Aggregator::AddFeed af (str); if (af.exec () == QDialog::Accepted) AddFeed (af.GetURL (), af.GetTags ()); } }
void EditorPage::on_Inject__released () { if (!Save ()) return; Entity e = Util::MakeEntity (QUrl::fromLocalFile (Filename_), QString (), FromUserInitiated | OnlyHandle, "x-leechcraft/script-wrap-request"); e.Additional_ ["Object"] = QVariant::fromValue<QObject**> (&WrappedObject_); Q_FOREACH (QAction *action, DoctypeMenu_->actions ()) if (action->isChecked ()) { e.Additional_ ["Language"] = FixLanguage (action->text ()); break; } S_TextEdit_ = Ui_.Console_; DefaultMsgHandler_ = qInstallMsgHandler (output); emit delegateEntity (e, 0, 0); if (!WrappedObject_) { qWarning () << Q_FUNC_INFO << "script wrapping failed"; QMessageBox::critical (this, "LeechCraft", tr ("Script wrapping failed.")); qInstallMsgHandler (DefaultMsgHandler_); S_TextEdit_ = 0; DefaultMsgHandler_ = 0; return; } try { Core::Instance ().GetProxy ()-> GetPluginsManager ()->InjectPlugin (WrappedObject_); } catch (const std::exception& e) { qWarning () << Q_FUNC_INFO << "script injection failed" << e.what (); QMessageBox::critical (this, "LeechCraft", tr ("Script injection failed: %1") .arg (e.what ())); WrappedObject_->deleteLater (); qInstallMsgHandler (DefaultMsgHandler_); S_TextEdit_ = 0; DefaultMsgHandler_ = 0; return; } qDebug () << Q_FUNC_INFO << "obtained" << WrappedObject_; Ui_.Inject_->setEnabled (false); Ui_.Release_->setEnabled (true); }