From kopete-devel Sat Nov 17 11:02:48 2007 From: Dennis =?utf-8?q?Nienh=C3=BCser?= Date: Sat, 17 Nov 2007 11:02:48 +0000 To: kopete-devel Subject: Re: [kopete-devel] Prevent creating duplicate accounts Message-Id: <200711171202.48455.earthwings () gentoo ! org> X-MARC-Message: https://marc.info/?l=kopete-devel&m=119529741316216 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_YpsPHjstsAs4Ri2" --Boundary-00=_YpsPHjstsAs4Ri2 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Am Mittwoch, 14. November 2007 21:57:35 schrieb Dennis Nienh=C3=BCser: > > Patch is attached, I plan to commit this soon. > > Regards, > Dennis Didn't check this in yet due to string freeze. Attached is a stripped down= =20 version that fixes the original bug, but doesn't introduce api changes or n= ew=20 strings. Please review, the patch is rather short this time. Dennis --Boundary-00=_YpsPHjstsAs4Ri2 Content-Type: text/x-diff; charset="utf-8"; name="addaccountwizard.cpp.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="addaccountwizard.cpp.diff" Index: kopete/kopete/addaccountwizard/addaccountwizard.cpp =================================================================== --- kopete/kopete/addaccountwizard/addaccountwizard.cpp (revision 737901) +++ kopete/kopete/addaccountwizard/addaccountwizard.cpp (working copy) @@ -201,17 +201,38 @@ void AddAccountWizard::accept() { - // registeredAccount shouldn't probably be called here. Anyway, if the account is already registered, - // it won't be registered twice Kopete::AccountManager *manager = Kopete::AccountManager::self(); - Kopete::Account *account = manager->registerAccount(d->accountPage->apply()); - // if the account wasn't created correctly then leave + // Have the plugin extract account information + Kopete::Account *account = d->accountPage->apply(); if (!account) { + // TODO: Uncomment when message freeze is lifted + // KMessageBox::sorry( this, i18nc("@info", "An error occurred during account creation.")); + reject(); return; } + // Check that the account doesn't exist yet, otherwise the account manager would delete it during registration + // This shouldn't be the case as the protocol's account edit page should prevent this, but it's not guaranteed + if (manager->findAccount(account->protocol()->pluginId(), account->accountId())) + { + // TODO: Uncomment when message freeze is lifted + // KMessageBox::sorry( this, i18nc("@info", "This account already exists.")); + reject(); + return; + } + + // Register account and leave if it doesn't work + account = manager->registerAccount(account); + if (!account) + { + // TODO: Uncomment when message freeze is lifted + // KMessageBox::sorry( this, i18nc("@info", "An error occurred during account registration.")); + reject(); + return; + } + // Make sure the protocol is correctly enabled. This is not really needed, but still good const QString PROTO_NAME = d->proto->pluginId().remove("Protocol").toLower(); Kopete::PluginManager::self()->setPluginEnabled(PROTO_NAME , true); --Boundary-00=_YpsPHjstsAs4Ri2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kopete-devel mailing list kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel --Boundary-00=_YpsPHjstsAs4Ri2--