void TodoTab::handleExport () { const QString& filename = QFileDialog::getSaveFileName (this, tr ("Todos export"), QDir::homePath (), tr ("iCalendar files (*.ics)")); QFile file (filename); if (!file.open (QIODevice::WriteOnly)) { qWarning () << Q_FUNC_INFO << "unable to open file" << filename << file.errorString (); emit gotEntity (Util::MakeNotification ("Otlozhu", tr ("Unable to export to %1: %2.") .arg (filename) .arg (file.errorString ()), Priority::Critical)); return; } ICalGenerator gen; auto storage = Core::Instance ().GetTodoManager ()->GetTodoStorage (); for (int i = 0; i < storage->GetNumItems (); ++i) gen << storage->GetItemAt (i); file.write (gen ()); emit gotEntity (Util::MakeNotification ("Otlozhu", tr ("Todo items were successfully exported to %1.") .arg (QFileInfo (filename).fileName ()), Priority::Info)); }
AccountWrapper* ProtoWrapper::handleNewAccount (Tp::AccountPtr acc) { if (ProtoName_ != acc->protocolName ()) return 0; Q_FOREACH (AccountWrapper *w, Accounts_) if (w->GetOurID () == acc->uniqueIdentifier ()) return w; qDebug () << Q_FUNC_INFO << ProtoName_ << acc->nickname () << acc->iconName (); auto w = new AccountWrapper (acc, this); connect (w, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); connect (w, SIGNAL (delegateEntity (LeechCraft::Entity, int*, QObject**)), this, SIGNAL (delegateEntity (LeechCraft::Entity, int*, QObject**))); connect (w, SIGNAL (removeFinished (AccountWrapper*)), this, SLOT (handleAccountRemoved (AccountWrapper*))); Accounts_ << w; emit accountAdded (w); return w; }
void Plugin::handleFSRequested () { auto dis = new FSDisplayer (Proxy_, Finder_, FavManager_, RecentManager_, this); connect (dis, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); }
Q_FOREACH (QObject *obj, wrappers) { connect (obj, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); connect (obj, SIGNAL (delegateEntity (LeechCraft::Entity, int*, QObject**)), this, SIGNAL (delegateEntity (LeechCraft::Entity, int*, QObject**))); }
void Plugin::InitWidget (ChatHistoryWidget *wh) { connect (wh, SIGNAL (removeSelf (QWidget*)), this, SIGNAL (removeTab (QWidget*))); connect (wh, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); }
void PsiPlusImportPage::SendImportHist (QStandardItem *accItem) { QVariantMap data = accItem->data (Roles::AccountData).toMap (); HistImporter *hi = new HistImporter (data ["ParentProfile"].toString (), data ["Name"].toString (), data ["Jid"].toString (), data ["Contacts"].toStringList ()); connect (hi, SIGNAL (gotEntity (LeechCraft::Entity)), qobject_cast<ImportWizard*> (wizard ())->GetPlugin (), SIGNAL (gotEntity (LeechCraft::Entity))); }
TodoManager::TodoManager (const QString& ctx, QObject *parent) : QObject (parent) , Context_ (ctx) , Storage_ (new TodoStorage (ctx, this)) , Model_ (new StorageModel (this)) , NotifMgr_ (new NotificationsManager (Storage_)) { Model_->SetStorage (Storage_); connect (NotifMgr_, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); }
ReportWizard* Plugin::initiateReporting () { auto wizard = new ReportWizard (Proxy_); connect (wizard, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); connect (wizard, SIGNAL (delegateEntity (LeechCraft::Entity, int*, QObject**)), this, SIGNAL (delegateEntity (LeechCraft::Entity, int*, QObject**))); wizard->show (); return wizard; }
void Plugin::Init (ICoreProxy_ptr proxy) { Util::InstallTranslator ("azoth_vader"); XSD_.reset (new Util::XmlSettingsDialog); XSD_->RegisterObject (&XmlSettingsManager::Instance (), "azothvadersettings.xml"); Core::Instance ().SetCoreProxy (proxy); Core::Instance ().GetProtocol ()->setParent (this); connect (&Core::Instance (), SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); }
void Core::HandleSearchRequest (const QString& url) { const int pos = url.indexOf (' '); const QString& category = url.mid (1, pos - 1); const QString& query = url.mid (pos + 1); Entity e; if (XmlSettingsManager::Instance ()->property ("UseSummaryForSearches").toBool ()) { e = Util::MakeEntity (query, QString (), FromUserInitiated, "x-leechcraft/category-search-request"); e.Additional_ ["Categories"] = QStringList (category); } else { e = Util::MakeEntity (query, QString (), FromUserInitiated | OnlyHandle, "x-leechcraft/data-filter-request"); e.Additional_ ["DataFilter"] = category.toUtf8 (); } emit gotEntity (e); }
void DBUpdateThreadWorker::NotifyUpdates (int newItems, int updatedItems, const Channel_ptr& channel) { const auto& method = XmlSettingsManager::Instance ()-> property ("NotificationsFeedUpdateBehavior").toString (); bool shouldShow = true; if (method == "ShowNo") shouldShow = false; else if (method == "ShowNew") shouldShow = newItems; else if (method == "ShowAll") shouldShow = newItems + updatedItems; if (!shouldShow) return; QStringList substrs; if (newItems) substrs << tr ("%n new item(s)", "Channel update", newItems); if (updatedItems) substrs << tr ("%n updated item(s)", "Channel update", updatedItems); const auto& str = tr ("Updated channel \"%1\" (%2).") .arg (channel->Title_) .arg (substrs.join (", ")); emit gotEntity (Util::MakeNotification ("Aggregator", str, PInfo_)); }
void GmailNotifier::sendMeNotification (const QString& title, const QString& msg, int num) { if (msg == LastMsg_) return; if (num && XmlSettingsManager::Instance ()->property ("ShowUnreadNumInTray").toBool ()) { CheckCreateAction (); NotifierAction_->setText (tr ("%n new message(s)", 0, num)); NotifierAction_->setToolTip (msg); auto font = qApp->font (); font.setBold (true); font.setItalic (true); const QIcon srcIcon (":/gmailnotifier/gmailicon.svg"); QIcon result; for (auto sz : { 16, 22, 32, 48, 64, 96, 128, 192 }) { const auto& px = srcIcon.pixmap (sz, sz); result.addPixmap (Util::DrawOverlayText (px, QString::number (num), font, QPen (Qt::black))); } NotifierAction_->setIcon (result); } LastMsg_ = msg; emit gotEntity (Util::MakeNotification (title, msg, PInfo_)); }
void Plugin::NotifyBirthday (ICLEntry *entry, int days) { const auto& hrId = entry->GetEntryName (); const QString& notify = days ? tr ("%1 has birthday in %n day(s)!", 0, days).arg (hrId) : tr ("%1 has birthday today!").arg (hrId); auto e = Util::MakeNotification (tr ("Birthday reminder"), notify, PInfo_); e.Additional_ ["org.LC.AdvNotifications.SenderID"] = GetUniqueID (); e.Additional_ ["org.LC.AdvNotifications.EventCategory"] = AN::CatOrganizer; e.Additional_ ["org.LC.AdvNotifications.EventID"] = "org.LC.Plugins.Azoth.BirthdayNotifier.Birthday/" + entry->GetEntryID (); e.Additional_ ["org.LC.AdvNotifications.VisualPath"] = QStringList (hrId); e.Additional_ ["org.LC.AdvNotifications.EventType"] = AN::TypeOrganizerEventDue; e.Additional_ ["org.LC.AdvNotifications.FullText"] = notify; e.Additional_ ["org.LC.AdvNotifications.ExtendedText"] = notify; e.Additional_ ["org.LC.AdvNotifications.Count"] = 1; const auto& px = QPixmap::fromImage (entry->GetAvatar ()); if (!px.isNull ()) e.Additional_ ["NotificationPixmap"] = px; emit gotEntity (e); }
void VacuumImportPage::SendImportHist (QStandardItem *accItem) { QVariantMap data = accItem->data (Roles::AccountData).toMap (); QString acc = data ["Jid"].toString (); const int pos = acc.indexOf ('@'); if (acc <= 0) return; acc.replace (pos, 1, "_at_"); acc.replace (0, pos, acc.left (pos).toUtf8 ().toPercentEncoding (QByteArray (), "_")); const QString& path = QDir::homePath () + "/.vacuum/archive/" + acc; qDebug () << Q_FUNC_INFO << data << path; QDir dir (path); Q_FOREACH (const QString& encJid, dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot)) { const auto& hist = HandleJID (dir, encJid, data); if (hist.isEmpty ()) continue; Entity e; e.Additional_ ["History"] = hist; e.Mime_ = "x-leechcraft/im-history-import"; e.Additional_ ["AccountName"] = data ["Name"]; e.Additional_ ["AccountID"] = data ["Jid"]; e.Parameters_ = OnlyHandle | FromUserInitiated; emit gotEntity (e); } }
bool DBUpdateThreadWorker::AddItem (const Item_ptr& item, const Channel_ptr& channel, const QVariantMap& channelDataMap, const Feed::FeedSettings& settings) { if (item->PubDate_.isValid ()) { if (item->PubDate_.daysTo (QDateTime::currentDateTime ()) >= settings.ItemAge_) return false; } else item->FixDate (); item->ChannelID_ = channel->ChannelID_; SB_->AddItem (item); RegexpMatcherManager::Instance ().HandleItem (item); QVariantList itemData; itemData << GetItemMapItemPart (item).unite (channelDataMap); emit hookGotNewItems (Util::DefaultHookProxy_ptr (new Util::DefaultHookProxy), itemData); if (settings.AutoDownloadEnclosures_) for (const auto& e : item->Enclosures_) { auto de = Util::MakeEntity (QUrl (e.URL_), XmlSettingsManager::Instance ()-> property ("EnclosuresDownloadPath").toString (), 0, e.Type_); de.Additional_ [" Tags"] = channel->Tags_; emit gotEntity (de); } return true; }
void PlatformLayer::EmitWokeUp () { Entity e = Util::MakeEntity ("WokeUp", QString (), TaskParameter::Internal, "x-leechcraft/power-state-changed"); emit gotEntity (e); }
void DBusConnector::handleWokeUp () { Entity e = Util::MakeEntity ("WokeUp", QString (), TaskParameter::Internal, "x-leechcraft/power-state-changed"); emit gotEntity (e); }
void SearchersList::handleOpenURL () { auto act = qobject_cast<QAction*> (sender ()); const auto& e = Util::MakeEntity (act->data (), QString (), FromUserInitiated | OnlyHandle); emit gotEntity (e); }
void VLCWrapper::HandlePlayed () { emit itemPlayed (CurrentItem_); Entity scrobbleEntity; scrobbleEntity.Additional_ = CurrentItemMeta_.ToVariantMap (); scrobbleEntity.Mime_ = "x-leechcraft/now-playing-track-info"; emit gotEntity (scrobbleEntity); emit currentItemMeta (CurrentItemMeta_); const QString& text = tr ("Now playing: %1 from %2 by %3") .arg ("<em>" + CurrentItemMeta_.Title_ + "</em>") .arg ("<em>" + CurrentItemMeta_.Album_ + "</em>") .arg ("<em>" + CurrentItemMeta_.Artist_ + "</em>"); Entity e = Util::MakeNotification ("Laure", text, PInfo_); emit gotEntity (e); }
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 PlatformLayer::EmitGonnaSleep (int timeout) { Entity e = Util::MakeEntity ("Sleeping", QString (), TaskParameter::Internal, "x-leechcraft/power-state-changed"); e.Additional_ ["TimeLeft"] = timeout; emit gotEntity (e); }
void CustomWebView::subscribeToLink () { QList<QVariant> list = qobject_cast<QAction*> (sender ())->data ().toList (); Entity e = Util::MakeEntity (list.at (0), QString (), FromUserInitiated | OnlyHandle, list.at (1).toString ()); emit gotEntity (e); }
void Plugin::handlePlatformStarted () { connect (PL_, SIGNAL (batteryInfoUpdated (Liznoo::BatteryInfo)), this, SLOT (handleBatteryInfo (Liznoo::BatteryInfo))); connect (PL_, SIGNAL (gotEntity (LeechCraft::Entity)), this, SIGNAL (gotEntity (LeechCraft::Entity))); QTimer *timer = new QTimer (this); connect (timer, SIGNAL (timeout ()), this, SLOT (handleUpdateHistory ())); timer->start (3000); }
void CustomWebView::savePixmap () { QAction *action = qobject_cast<QAction*> (sender ()); if (!action) { qWarning () << Q_FUNC_INFO << "sender is not an action" << sender (); return; } const QPixmap& px = action->property ("Poshuku/OrigPX").value<QPixmap> (); if (px.isNull ()) return; const QUrl& url = action->property ("Poshuku/OrigURL").value<QUrl> (); const QString origName = url.scheme () == "data" ? QString () : QFileInfo (url.path ()).fileName (); QString filter; QString fname = QFileDialog::getSaveFileName (0, tr ("Save pixmap"), QDir::homePath () + '/' + origName, tr ("PNG image (*.png);;JPG image (*.jpg);;All files (*.*)"), &filter); if (fname.isEmpty ()) return; if (QFileInfo (fname).suffix ().isEmpty ()) { if (filter.contains ("png")) fname += ".png"; else if (filter.contains ("jpg")) fname += ".jpg"; } QFile file (fname); if (!file.open (QIODevice::WriteOnly)) { emit gotEntity (Util::MakeNotification ("Poshuku", tr ("Unable to save the image. Unable to open file for writing: %1.") .arg (file.errorString ()), PCritical_)); return; } const QString& suf = QFileInfo (fname).suffix (); const bool isLossless = suf.toLower () == "png"; px.save (&file, suf.toUtf8 ().constData (), isLossless ? 0 : 100); }
void Poster::handleError () { qWarning () << Q_FUNC_INFO << Reply_->errorString (); QString text = tr ("Upload of screenshot failed: %1") .arg (Reply_->errorString ()); emit gotEntity (Util::MakeNotification ("Auscrie", text, PCritical_)); deleteLater (); }
void Plugin::CheckNotifications (const BatteryInfo& info) { auto check = [&info, this] (std::function<bool (const BatteryInfo&)> f) { if (!Battery2LastInfo_.contains (info.ID_)) return f (info); return f (info) && !f (Battery2LastInfo_ [info.ID_]); }; auto checkPerc = [] (const BatteryInfo& b, const QByteArray& prop) { return b.Percentage_ <= XmlSettingsManager::Instance ()->property (prop).toInt (); }; const bool isExtremeLow = check ([checkPerc] (const BatteryInfo& b) { return checkPerc (b, "NotifyOnExtremeLowPower"); }); const bool isLow = check ([checkPerc] (const BatteryInfo& b) { return checkPerc (b, "NotifyOnLowPower"); }); if (isExtremeLow || isLow) emit gotEntity (Util::MakeNotification ("Liznoo", tr ("Battery charge level is below %1.") .arg (info.Percentage_), isLow ? PWarning_ : PCritical_)); if (XmlSettingsManager::Instance ()->property ("NotifyOnPowerTransitions").toBool ()) { const bool startedCharging = check ([] (const BatteryInfo& b) { return b.TimeToFull_ && !b.TimeToEmpty_; }); const bool startedDischarging = check ([] (const BatteryInfo& b) { return !b.TimeToFull_ && b.TimeToEmpty_; }); if (startedCharging) emit gotEntity (Util::MakeNotification ("Liznoo", tr ("The device started charging."), PInfo_)); else if (startedDischarging) emit gotEntity (Util::MakeNotification ("Liznoo", tr ("The device started discharging."), PWarning_)); } }
void Plugin::entryServiceRequested () { const QString& url = sender ()->property ("URL").toString (); QObject *buddyObj = sender ()->property ("Azoth/Vader/Entry").value<QObject*> (); MRIMBuddy *buddy = qobject_cast<MRIMBuddy*> (buddyObj); const QString& subst = VaderUtil::SubstituteNameDomain (url, buddy->GetHumanReadableID ()); const Entity& e = Util::MakeEntity (QUrl (subst), QString (), static_cast<LeechCraft::TaskParameters> (OnlyHandle | FromUserInitiated)); emit gotEntity (e); }
void Core::DeletePassword (QObject *accObj) { IAccount *account = qobject_cast<IAccount*> (accObj); QVariantList keys; keys << account->GetAccountID (); Entity e = Util::MakeEntity (keys, QString (), Internal, "x-leechcraft/data-persistent-clear"); emit gotEntity (e); }
void Poster::handleFinished () { QString result = Reply_->readAll (); QString pasteUrl = Workers_ [Service_]->GetLink (result); if (pasteUrl.isEmpty ()) { emit gotEntity (Util::MakeNotification ("Auscrie", tr ("Page parse failed"), PCritical_)); return; } QApplication::clipboard ()->setText (pasteUrl, QClipboard::Clipboard); QApplication::clipboard ()->setText (pasteUrl, QClipboard::Selection); QString text = tr ("Image pasted: %1, the URL was copied to the clipboard") .arg (pasteUrl); emit gotEntity (Util::MakeNotification ("Auscrie", text, PInfo_)); deleteLater (); }
void RepoInfoFetcher::handlePackageUnarchFinished (int exitCode, QProcess::ExitStatus) { sender ()->deleteLater (); int id = sender ()->property ("TaskID").toInt (); PendingPackage pp = PendingPackages_.take (id); if (exitCode) { emit gotEntity (Util::MakeNotification (tr ("Component unpack error"), tr ("Unable to unpack the component file. gunzip error: %1. " "Problematic file is at %2.") .arg (exitCode) .arg (sender ()->property ("Filename").toString ()), PCritical_)); return; } QByteArray data = qobject_cast<QProcess*> (sender ())->readAllStandardOutput (); QFile::remove (sender ()->property ("Filename").toString ()); PackageInfo packageInfo; try { packageInfo = ParsePackage (data, pp.BaseURL_, pp.PackageName_, pp.NewVersions_); } catch (const std::exception& e) { qWarning () << Q_FUNC_INFO << e.what (); emit gotEntity (Util::MakeNotification (tr ("Package parse error"), tr ("Unable to parse package description file. " "More information is available in logs."), PCritical_)); return; } emit packageFetched (packageInfo, pp.ComponentId_); }