Changeset View
Changeset View
Standalone View
Standalone View
src/bugzillaintegration/reportassistantpages_bugzilla.cpp
Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | |||||
106 | 106 | | |||
107 | bool BugzillaLoginPage::isComplete() | 107 | bool BugzillaLoginPage::isComplete() | ||
108 | { | 108 | { | ||
109 | return bugzillaManager()->getLogged(); | 109 | return bugzillaManager()->getLogged(); | ||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | void BugzillaLoginPage::bugzillaVersionFound() | 112 | void BugzillaLoginPage::bugzillaVersionFound() | ||
113 | { | 113 | { | ||
114 | qDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; | ||||
114 | // Login depends on first knowing the Bugzilla software version number. | 115 | // Login depends on first knowing the Bugzilla software version number. | ||
115 | m_bugzillaVersionFound = true; | 116 | m_bugzillaVersionFound = true; | ||
116 | updateLoginButtonStatus(); | 117 | updateLoginButtonStatus(); | ||
117 | } | 118 | } | ||
118 | 119 | | |||
119 | void BugzillaLoginPage::updateLoginButtonStatus() | 120 | void BugzillaLoginPage::updateLoginButtonStatus() | ||
120 | { | 121 | { | ||
122 | qDebug() << "!ui.m_userEdit->text().isEmpty()" << !ui.m_userEdit->text().isEmpty() << "!ui.m_passwordEdit->password().isEmpty()" << !ui.m_passwordEdit->password().isEmpty() | ||||
123 | << "m_bugzillaVersionFound" << m_bugzillaVersionFound; | ||||
121 | ui.m_loginButton->setEnabled( !ui.m_userEdit->text().isEmpty() && | 124 | ui.m_loginButton->setEnabled( !ui.m_userEdit->text().isEmpty() && | ||
122 | !ui.m_passwordEdit->password().isEmpty() && | 125 | !ui.m_passwordEdit->password().isEmpty() && | ||
123 | m_bugzillaVersionFound ); | 126 | m_bugzillaVersionFound ); | ||
124 | } | 127 | } | ||
125 | 128 | | |||
126 | void BugzillaLoginPage::loginError(const QString & err, const QString & extendedMessage) | 129 | void BugzillaLoginPage::loginError(const QString & err, const QString & extendedMessage) | ||
127 | { | 130 | { | ||
128 | loginFinished(false); | 131 | loginFinished(false); | ||
129 | ui.m_statusWidget->setIdle(xi18nc("@info:status","Error when trying to login: " | 132 | ui.m_statusWidget->setIdle(xi18nc("@info:status","Error when trying to login: " | ||
130 | "<message>%1.</message>", err)); | 133 | "<message>%1</message>", err)); | ||
131 | if (!extendedMessage.isEmpty()) { | 134 | if (!extendedMessage.isEmpty()) { | ||
132 | new UnhandledErrorDialog(this, err, extendedMessage); | 135 | new UnhandledErrorDialog(this, err, extendedMessage); | ||
133 | } | 136 | } | ||
134 | } | 137 | } | ||
135 | 138 | | |||
136 | void BugzillaLoginPage::aboutToShow() | 139 | void BugzillaLoginPage::aboutToShow() | ||
137 | { | 140 | { | ||
138 | if (bugzillaManager()->getLogged()) { | 141 | if (bugzillaManager()->getLogged()) { | ||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Line(s) | 219 | if (!username.isEmpty() && !password.isEmpty()) { | |||
226 | ui.m_passwordEdit->setPassword(password); | 229 | ui.m_passwordEdit->setPassword(password); | ||
227 | } | 230 | } | ||
228 | } | 231 | } | ||
229 | 232 | | |||
230 | } | 233 | } | ||
231 | } | 234 | } | ||
232 | } | 235 | } | ||
233 | 236 | | |||
234 | bool BugzillaLoginPage::canSetCookies() | | |||
235 | { | | |||
236 | if (bugzillaManager()->securityMethod() != BugzillaManager::UseCookies) { | | |||
237 | qCDebug(DRKONQI_LOG) << "Bugzilla software no longer issues cookies."; | | |||
238 | return false; | | |||
239 | } | | |||
240 | QDBusInterface kded(QStringLiteral("org.kde.kded5"), | | |||
241 | QStringLiteral("/kded"), | | |||
242 | QStringLiteral("org.kde.kded5")); | | |||
243 | QDBusReply<bool> kcookiejarLoaded = kded.call(QStringLiteral("loadModule"), | | |||
244 | QStringLiteral("kcookiejar")); | | |||
245 | if (!kcookiejarLoaded.isValid()) { | | |||
246 | KMessageBox::error(this, i18n("Failed to communicate with kded. Make sure it is running.")); | | |||
247 | return false; | | |||
248 | } else if (!kcookiejarLoaded.value()) { | | |||
249 | KMessageBox::error(this, i18n("Failed to load KCookieServer. Check your KDE installation.")); | | |||
250 | return false; | | |||
251 | } | | |||
252 | | ||||
253 | | ||||
254 | QDBusInterface kcookiejar(QStringLiteral("org.kde.kded5"), | | |||
255 | QStringLiteral("/modules/kcookiejar"), | | |||
256 | QStringLiteral("org.kde.KCookieServer")); | | |||
257 | QDBusReply<QString> advice = kcookiejar.call(QStringLiteral("getDomainAdvice"), | | |||
258 | KDE_BUGZILLA_URL); | | |||
259 | | ||||
260 | if (!advice.isValid()) { | | |||
261 | KMessageBox::error(this, i18n("Failed to communicate with KCookieServer.")); | | |||
262 | return false; | | |||
263 | } | | |||
264 | | ||||
265 | qCDebug(DRKONQI_LOG) << "Got reply from KCookieServer:" << advice.value(); | | |||
266 | | ||||
267 | if (advice.value() == QLatin1String("Reject")) { | | |||
268 | QString msg = i18nc("@info 1 is the bugzilla website url", | | |||
269 | "Cookies are not allowed in your KDE network settings. In order to " | | |||
270 | "proceed, you need to allow %1 to set cookies.", KDE_BUGZILLA_URL); | | |||
271 | | ||||
272 | KGuiItem yesItem = KStandardGuiItem::yes(); | | |||
273 | yesItem.setText(i18nc("@action:button 1 is the bugzilla website url", | | |||
274 | "Allow %1 to set cookies", KDE_BUGZILLA_URL)); | | |||
275 | | ||||
276 | KGuiItem noItem = KStandardGuiItem::no(); | | |||
277 | noItem.setText(i18nc("@action:button do not allow the bugzilla website " | | |||
278 | "to set cookies", "No, do not allow")); | | |||
279 | | ||||
280 | if (KMessageBox::warningYesNo(this, msg, QString(), yesItem, noItem) == KMessageBox::Yes) { | | |||
281 | QDBusReply<bool> success = kcookiejar.call(QStringLiteral("setDomainAdvice"), | | |||
282 | KDE_BUGZILLA_URL, | | |||
283 | QStringLiteral("Accept")); | | |||
284 | if (!success.isValid() || !success.value()) { | | |||
285 | qCWarning(DRKONQI_LOG) << "Failed to set domain advice in KCookieServer"; | | |||
286 | return false; | | |||
287 | } else { | | |||
288 | return true; | | |||
289 | } | | |||
290 | } else { | | |||
291 | return false; | | |||
292 | } | | |||
293 | } | | |||
294 | | ||||
295 | return true; | | |||
296 | } | | |||
297 | | ||||
298 | void BugzillaLoginPage::loginClicked() | 237 | void BugzillaLoginPage::loginClicked() | ||
299 | { | 238 | { | ||
300 | if (!(ui.m_userEdit->text().isEmpty() || ui.m_passwordEdit->password().isEmpty())) { | 239 | if (!(ui.m_userEdit->text().isEmpty() || ui.m_passwordEdit->password().isEmpty())) { | ||
301 | | ||||
302 | if ((bugzillaManager()->securityMethod() == BugzillaManager::UseCookies) | | |||
303 | && (!canSetCookies())) { | | |||
304 | return; | | |||
305 | } | | |||
306 | | ||||
307 | updateWidget(false); | 240 | updateWidget(false); | ||
308 | 241 | | |||
309 | if (ui.m_savePasswordCheckBox->checkState()==Qt::Checked) { //Wants to save data | 242 | if (ui.m_savePasswordCheckBox->checkState()==Qt::Checked) { //Wants to save data | ||
310 | if (!m_wallet) { | 243 | if (!m_wallet) { | ||
311 | openWallet(); | 244 | openWallet(); | ||
312 | } | 245 | } | ||
313 | //Got wallet open ? | 246 | //Got wallet open ? | ||
314 | if (m_wallet) { | 247 | if (m_wallet) { | ||
▲ Show 20 Lines • Show All 572 Lines • Show Last 20 Lines |