QList<bbpimAccount::Account> AccountFolderManager::GetAccounts(bool fresh)
{
    if (fresh || m_accountsMap.empty()) {
        fetchAccounts();
    }

    QList<bbpimAccount::Account> list;
    for (AccountMap::const_iterator i = m_accountsMap.begin(); i != m_accountsMap.end(); i++) {
        list.append(i->second);
    }

    return list;
}
bbpimAccount::Account AccountFolderManager::GetAccount(bbpim::AccountId accountId, bool fresh)
{
    if (fresh || m_accountsMap.find(accountId) == m_accountsMap.end()) {
        fetchAccounts();
    }

    AccountMap::const_iterator found = m_accountsMap.find(accountId);

    if (found != m_accountsMap.end()) {
        return found->second;
    } else {
        return bbpimAccount::Account(); // return invalid account if not found
    }
}
Esempio n. 3
0
void ImapSync_UI::sync(){
	if(process->state() == QProcess::Running){
		onFinished(0, QProcess::CrashExit);
	}else{
		//Get the args with which we're going to run imapsync
		QStringList args = fetchArgs();
		if(args.isEmpty()){
			QMessageBox::critical(this, "Error", "Missing mandatory config (host1 or host2)");
			return;
		}

		QStringList accounts = fetchAccounts();
		if(accounts.isEmpty()){
			QMessageBox::critical(this, "Error", "Missing mandatory config (accounts)");
			return;
		}

		QListIterator<QString>itr(accounts);
		while(itr.hasNext()){
			//Save the constructed args
			QString cmd = args.join(" "),
					user1 = itr.next(),
					password1 = itr.next(),
					user2 = itr.next(),
					password2 = itr.next();

			final_args.append(
				QString("%1 --user1 %2 --password1 %3 --user2 %4 --password2 %5").arg(cmd, user1, password1, user2, password2)
			);
		}

		nargs = 0;

		//Start processing the final_args list
		processFinalArgs();
	}
}