예제 #1
0
void KopeteApplication::slotAllPluginsLoaded()
{
	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

	// --noconnect not specified?
	if ( args->isSet( "connect" )  && KopetePrefs::prefs()->autoConnect() )
		Kopete::AccountManager::self()->connectAll();


	// Handle things like '--autoconnect foo,bar --autoconnect foobar'
	KStringList connectArgsC = args->getOptionList( "autoconnect" );
	QStringList connectArgs;

	for ( KStringList::ConstIterator it = connectArgsC.begin(); it != connectArgsC.end(); ++it )
	{
		QStringList split = QStringList::split( ',', QString::fromLatin1( *it ) );

		for ( QStringList::ConstIterator it2 = split.begin(); it2 != split.end(); ++it2 )
		{
			connectArgs.append( *it2 );
		}
	}
	
	for ( QStringList::ConstIterator i = connectArgs.begin(); i != connectArgs.end(); ++i )
	{
		QRegExp rx( QString::fromLatin1( "([^\\|]*)\\|\\|(.*)" ) );
		rx.search( *i );
		QString protocolId = rx.cap( 1 );
		QString accountId = rx.cap( 2 );

		if ( accountId.isEmpty() )
		{
			if ( protocolId.isEmpty() )
				accountId = *i;
			else
				continue;
		}

		QPtrListIterator<Kopete::Account> it( Kopete::AccountManager::self()->accounts() );
		Kopete::Account *account;
		while ( ( account = it.current() ) != 0 )
		{
			++it;

			if ( ( account->accountId() == accountId ) )
			{
				if ( protocolId.isEmpty() || account->protocol()->pluginId() == protocolId )
				{
					account->connect();
					break;
				}
			}
		}
	}

	// Parse any passed URLs/files
	handleURLArgs();
}
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 = d->accountPage->apply();

	// if the account wasn't created correctly then leave
	if (!account)
	{
		reject();
		return;
	}

	// Set a valid identity before registering the account
	if (!d->identity)
	{
		account->setIdentity(Kopete::IdentityManager::self()->defaultIdentity());
	}
	else
	{
		account->setIdentity(d->identity);
	}

	account = manager->registerAccount(account);
	// if the account wasn't created correctly then leave
	if (!account)
	{
		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);

	// setup the custom colour
	if (d->uiFinish.mUseColor->isChecked())
	{
		account->setColor(d->uiFinish.mColorButton->color());
	}

	// connect if necessary
	if (d->uiFinish.mConnectNow->isChecked())
	{
		account->connect();
	}

	KAssistantDialog::accept();
}
예제 #3
0
void KopeteIface::connect(const QString &protocolId, const QString &accountId )
{
    QPtrListIterator<Kopete::Account> it( Kopete::AccountManager::self()->accounts() );
    Kopete::Account *account;
    while ( ( account = it.current() ) != 0 )
    {
        ++it;

        if( ( account->accountId() == accountId) )
        {
            if( protocolId.isEmpty() || account->protocol()->pluginId() == protocolId )
            {
                account->connect();
                break;
            }
        }
    }
}