void FormOwnCloudFeedDetails::apply() { if (m_editableFeed != nullptr) { bool renamed = false; if (m_ui->m_txtTitle->lineEdit()->text() != m_editableFeed->title()) { if (!qobject_cast<OwnCloudServiceRoot*>(m_serviceRoot)->network()->renameFeed(m_ui->m_txtTitle->lineEdit()->text(), m_editableFeed->customId())) { qWarning("ownCloud: Došlo k problému při prejmenování kanálu s ownCloud ID '%d'.", m_editableFeed->customId()); } else { renamed = true; } } // User edited auto-update status. Save it. OwnCloudFeed *new_feed_data = new OwnCloudFeed(); new_feed_data->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); new_feed_data->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value()); qobject_cast<OwnCloudFeed*>(m_editableFeed)->editItself(new_feed_data); delete new_feed_data; if (renamed) { QTimer::singleShot(200, m_serviceRoot, SLOT(syncIn())); } } else { const RootItem *parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>()); const int category_id = parent->kind() == RootItemKind::ServiceRoot ? 0 : parent->customId(); const bool response = qobject_cast<OwnCloudServiceRoot*>(m_serviceRoot)->network()->createFeed(m_ui->m_txtUrl->lineEdit()->text(), category_id); if (response) { // Feed was added online. accept(); qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information); QTimer::singleShot(100, m_serviceRoot, SLOT(syncIn())); } else { reject(); qApp->showGuiMessage(tr("Cannot add feed"), tr("Feed was not added due to error."), QSystemTrayIcon::Critical, qApp->mainFormWidget(), true); } } accept(); }
void GmailServiceRoot::start(bool freshly_activated) { Q_UNUSED(freshly_activated) loadFromDatabase(); loadCacheFromFile(accountId()); if (childCount() <= 1) { syncIn(); } m_network->oauth()->login(); }
void FormTtRssFeedDetails::apply() { if (m_editableFeed != nullptr) { // User edited auto-update status. Save it. TtRssFeed *new_feed_data = new TtRssFeed(); new_feed_data->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(m_ui->m_cmbAutoUpdateType->currentIndex()).toInt())); new_feed_data->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value()); qobject_cast<TtRssFeed*>(m_editableFeed)->editItself(new_feed_data); delete new_feed_data; } else { RootItem *parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>()); TtRssServiceRoot *root = parent->kind() == RootItemKind::Category ? qobject_cast<TtRssCategory*>(parent)->serviceRoot() : qobject_cast<TtRssServiceRoot*>(parent); const int category_id = parent->kind() == RootItemKind::ServiceRoot ? 0 : qobject_cast<TtRssCategory*>(parent)->customId(); const TtRssSubscribeToFeedResponse response = root->network()->subscribeToFeed(m_ui->m_txtUrl->lineEdit()->text(), category_id, m_ui->m_gbAuthentication->isChecked(), m_ui->m_txtUsername->lineEdit()->text(), m_ui->m_txtPassword->lineEdit()->text()); if (response.code() == STF_INSERTED) { // Feed was added online. accept(); qApp->showGuiMessage(tr("Feed added"), tr("Feed was added, triggering sync in now."), QSystemTrayIcon::Information); QTimer::singleShot(100, root, SLOT(syncIn())); } else { reject(); qApp->showGuiMessage(tr("Cannot add feed"), tr("Feed was not added due to error."), QSystemTrayIcon::Critical, qApp->mainForm(), true); } } accept(); }