Changeset View
Changeset View
Standalone View
Standalone View
drkonqi/bugzillaintegration/reportassistantpages_bugzilla.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | #include "drkonqi.h" | 54 | #include "drkonqi.h" | ||
55 | #include "drkonqi_globals.h" | 55 | #include "drkonqi_globals.h" | ||
56 | #include "applicationdetailsexamples.h" | 56 | #include "applicationdetailsexamples.h" | ||
57 | 57 | | |||
58 | static const char kWalletEntryName[] = "drkonqi_bugzilla"; | 58 | static const char kWalletEntryName[] = "drkonqi_bugzilla"; | ||
59 | static const char kWalletEntryUsername[] = "username"; | 59 | static const char kWalletEntryUsername[] = "username"; | ||
60 | static const char kWalletEntryPassword[] = "password"; | 60 | static const char kWalletEntryPassword[] = "password"; | ||
61 | 61 | | |||
62 | static const char konquerorKWalletEntryName[] = KDE_BUGZILLA_URL "index.cgi#login"; | 62 | static QString konquerorKWalletEntryName = KDE_BUGZILLA_URL + "index.cgi#login"; | ||
63 | static const char konquerorKWalletEntryUsername[] = "Bugzilla_login"; | 63 | static const char konquerorKWalletEntryUsername[] = "Bugzilla_login"; | ||
64 | static const char konquerorKWalletEntryPassword[] = "Bugzilla_password"; | 64 | static const char konquerorKWalletEntryPassword[] = "Bugzilla_password"; | ||
65 | 65 | | |||
66 | //BEGIN BugzillaLoginPage | 66 | //BEGIN BugzillaLoginPage | ||
67 | 67 | | |||
68 | BugzillaLoginPage::BugzillaLoginPage(ReportAssistantDialog * parent) : | 68 | BugzillaLoginPage::BugzillaLoginPage(ReportAssistantDialog * parent) : | ||
69 | ReportAssistantPage(parent), | 69 | ReportAssistantPage(parent), | ||
70 | m_wallet(0), m_walletWasOpenedBefore(false), | 70 | m_wallet(0), m_walletWasOpenedBefore(false), | ||
Show All 26 Lines | 72 | { | |||
97 | ui.m_noticeLabel->setText( | 97 | ui.m_noticeLabel->setText( | ||
98 | xi18nc("@info/rich","<note>You need a user account on the " | 98 | xi18nc("@info/rich","<note>You need a user account on the " | ||
99 | "<link url='%1'>KDE bug tracking system</link> in order to " | 99 | "<link url='%1'>KDE bug tracking system</link> in order to " | ||
100 | "file a bug report, because we may need to contact you later " | 100 | "file a bug report, because we may need to contact you later " | ||
101 | "for requesting further information. If you do not have " | 101 | "for requesting further information. If you do not have " | ||
102 | "one, you can freely <link url='%2'>create one here</link>. " | 102 | "one, you can freely <link url='%2'>create one here</link>. " | ||
103 | "Please do not use disposable email accounts.</note>", | 103 | "Please do not use disposable email accounts.</note>", | ||
104 | DrKonqi::crashedApplication()->bugReportAddress(), | 104 | DrKonqi::crashedApplication()->bugReportAddress(), | ||
105 | QLatin1String(KDE_BUGZILLA_CREATE_ACCOUNT_URL))); | 105 | KDE_BUGZILLA_CREATE_ACCOUNT_URL)); | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | bool BugzillaLoginPage::isComplete() | 108 | bool BugzillaLoginPage::isComplete() | ||
109 | { | 109 | { | ||
110 | return bugzillaManager()->getLogged(); | 110 | return bugzillaManager()->getLogged(); | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | void BugzillaLoginPage::bugzillaVersionFound() | 113 | void BugzillaLoginPage::bugzillaVersionFound() | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 191 | if (m_wallet) { | |||
197 | QString username = values.value(QLatin1String(kWalletEntryUsername)); | 197 | QString username = values.value(QLatin1String(kWalletEntryUsername)); | ||
198 | QString password = values.value(QLatin1String(kWalletEntryPassword)); | 198 | QString password = values.value(QLatin1String(kWalletEntryPassword)); | ||
199 | 199 | | |||
200 | if (!username.isEmpty() && !password.isEmpty()) { | 200 | if (!username.isEmpty() && !password.isEmpty()) { | ||
201 | ui.m_userEdit->setText(username); | 201 | ui.m_userEdit->setText(username); | ||
202 | ui.m_passwordEdit->setText(password); | 202 | ui.m_passwordEdit->setText(password); | ||
203 | } | 203 | } | ||
204 | } | 204 | } | ||
205 | } else if (kWalletEntryExists(QLatin1String(konquerorKWalletEntryName))) { | 205 | } else if (kWalletEntryExists(konquerorKWalletEntryName)) { | ||
206 | //If the DrKonqi entry is empty, but a Konqueror entry exists, use and copy it. | 206 | //If the DrKonqi entry is empty, but a Konqueror entry exists, use and copy it. | ||
207 | openWallet(); | 207 | openWallet(); | ||
208 | if (m_wallet) { | 208 | if (m_wallet) { | ||
209 | m_wallet->setFolder(KWallet::Wallet::FormDataFolder()); | 209 | m_wallet->setFolder(KWallet::Wallet::FormDataFolder()); | ||
210 | 210 | | |||
211 | //Fetch Konqueror data | 211 | //Fetch Konqueror data | ||
212 | QMap<QString, QString> values; | 212 | QMap<QString, QString> values; | ||
213 | m_wallet->readMap(QLatin1String(konquerorKWalletEntryName), values); | 213 | m_wallet->readMap(konquerorKWalletEntryName, values); | ||
214 | QString username = values.value(QLatin1String(konquerorKWalletEntryUsername)); | 214 | QString username = values.value(QLatin1String(konquerorKWalletEntryUsername)); | ||
215 | QString password = values.value(QLatin1String(konquerorKWalletEntryPassword)); | 215 | QString password = values.value(QLatin1String(konquerorKWalletEntryPassword)); | ||
216 | 216 | | |||
217 | if (!username.isEmpty() && !password.isEmpty()) { | 217 | if (!username.isEmpty() && !password.isEmpty()) { | ||
218 | //Copy to DrKonqi own entries | 218 | //Copy to DrKonqi own entries | ||
219 | values.clear(); | 219 | values.clear(); | ||
220 | values.insert(QLatin1String(kWalletEntryUsername), username); | 220 | values.insert(QLatin1String(kWalletEntryUsername), username); | ||
221 | values.insert(QLatin1String(kWalletEntryPassword), password); | 221 | values.insert(QLatin1String(kWalletEntryPassword), password); | ||
Show All 29 Lines | 249 | } else if (!kcookiejarLoaded.value()) { | |||
251 | return false; | 251 | return false; | ||
252 | } | 252 | } | ||
253 | 253 | | |||
254 | 254 | | |||
255 | QDBusInterface kcookiejar(QLatin1String("org.kde.kded5"), | 255 | QDBusInterface kcookiejar(QLatin1String("org.kde.kded5"), | ||
256 | QLatin1String("/modules/kcookiejar"), | 256 | QLatin1String("/modules/kcookiejar"), | ||
257 | QLatin1String("org.kde.KCookieServer")); | 257 | QLatin1String("org.kde.KCookieServer")); | ||
258 | QDBusReply<QString> advice = kcookiejar.call(QLatin1String("getDomainAdvice"), | 258 | QDBusReply<QString> advice = kcookiejar.call(QLatin1String("getDomainAdvice"), | ||
259 | QLatin1String(KDE_BUGZILLA_URL)); | 259 | KDE_BUGZILLA_URL); | ||
260 | 260 | | |||
261 | if (!advice.isValid()) { | 261 | if (!advice.isValid()) { | ||
262 | KMessageBox::error(this, i18n("Failed to communicate with KCookieServer.")); | 262 | KMessageBox::error(this, i18n("Failed to communicate with KCookieServer.")); | ||
263 | return false; | 263 | return false; | ||
264 | } | 264 | } | ||
265 | 265 | | |||
266 | qDebug() << "Got reply from KCookieServer:" << advice.value(); | 266 | qDebug() << "Got reply from KCookieServer:" << advice.value(); | ||
267 | 267 | | |||
268 | if (advice.value() == QLatin1String("Reject")) { | 268 | if (advice.value() == QLatin1String("Reject")) { | ||
269 | QString msg = i18nc("@info 1 is the bugzilla website url", | 269 | QString msg = i18nc("@info 1 is the bugzilla website url", | ||
270 | "Cookies are not allowed in your KDE network settings. In order to " | 270 | "Cookies are not allowed in your KDE network settings. In order to " | ||
271 | "proceed, you need to allow %1 to set cookies.", KDE_BUGZILLA_URL); | 271 | "proceed, you need to allow %1 to set cookies.", KDE_BUGZILLA_URL); | ||
272 | 272 | | |||
273 | KGuiItem yesItem = KStandardGuiItem::yes(); | 273 | KGuiItem yesItem = KStandardGuiItem::yes(); | ||
274 | yesItem.setText(i18nc("@action:button 1 is the bugzilla website url", | 274 | yesItem.setText(i18nc("@action:button 1 is the bugzilla website url", | ||
275 | "Allow %1 to set cookies", KDE_BUGZILLA_URL)); | 275 | "Allow %1 to set cookies", KDE_BUGZILLA_URL)); | ||
276 | 276 | | |||
277 | KGuiItem noItem = KStandardGuiItem::no(); | 277 | KGuiItem noItem = KStandardGuiItem::no(); | ||
278 | noItem.setText(i18nc("@action:button do not allow the bugzilla website " | 278 | noItem.setText(i18nc("@action:button do not allow the bugzilla website " | ||
279 | "to set cookies", "No, do not allow")); | 279 | "to set cookies", "No, do not allow")); | ||
280 | 280 | | |||
281 | if (KMessageBox::warningYesNo(this, msg, QString(), yesItem, noItem) == KMessageBox::Yes) { | 281 | if (KMessageBox::warningYesNo(this, msg, QString(), yesItem, noItem) == KMessageBox::Yes) { | ||
282 | QDBusReply<bool> success = kcookiejar.call(QLatin1String("setDomainAdvice"), | 282 | QDBusReply<bool> success = kcookiejar.call(QStringLiteral("setDomainAdvice"), | ||
283 | QLatin1String(KDE_BUGZILLA_URL), | 283 | KDE_BUGZILLA_URL, | ||
284 | QLatin1String("Accept")); | 284 | QStringLiteral("Accept")); | ||
285 | if (!success.isValid() || !success.value()) { | 285 | if (!success.isValid() || !success.value()) { | ||
286 | qWarning() << "Failed to set domain advice in KCookieServer"; | 286 | qWarning() << "Failed to set domain advice in KCookieServer"; | ||
287 | return false; | 287 | return false; | ||
288 | } else { | 288 | } else { | ||
289 | return true; | 289 | return true; | ||
290 | } | 290 | } | ||
291 | } else { | 291 | } else { | ||
292 | return false; | 292 | return false; | ||
▲ Show 20 Lines • Show All 597 Lines • Show Last 20 Lines |