[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    Re: [kopete-devel] Prevent creating duplicate accounts
From:       Dennis =?utf-8?q?Nienh=C3=BCser?= <earthwings () gentoo ! org>
Date:       2007-11-17 11:02:48
Message-ID: 200711171202.48455.earthwings () gentoo ! org
[Download RAW message or body]

Am Mittwoch, 14. November 2007 21:57:35 schrieb Dennis Nienhüser:
>
> 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 
version that fixes the original bug, but doesn't introduce api changes or new 
strings. Please review, the patch is rather short this time.

Dennis


["addaccountwizard.cpp.diff" (text/x-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", "<qt>An error occurred during account \
creation.</qt>")); +		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", "<qt>This account already \
exists.</qt>")); +		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", "<qt>An error occurred during account \
registration.</qt>")); +		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);



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic