void Plugin::RegisterAccount (const QString& accName)
	{
		Account_ptr acc (new Account (this));
		acc->SetAccountName (accName);

		if (!acc->ExecConfigDialog ())
			return;

		Accounts_ << acc;
		WriteAccounts ();
		emit accountAdded (acc.get ());
	}
Exemple #2
0
void Plugin::ReadAccounts ()
{
    QSettings settings (QSettings::IniFormat, QSettings::UserScope,
                        QCoreApplication::organizationName (),
                        QCoreApplication::applicationName () + "_NSM_GD_Accounts");
    int size = settings.beginReadArray ("Accounts");
    for (int i = 0; i < size; ++i)
    {
        settings.setArrayIndex (i);
        const QByteArray& data = settings.value ("SerializedData").toByteArray ();
        Account_ptr acc = Account::Deserialize (data, this);
        Accounts_ << acc;
        emit accountAdded (acc.get ());
    }
    settings.endArray ();
}
Exemple #3
0
	void AccountsManager::AddAccountImpl (Account_ptr account)
	{
		Accounts_ << account;

		const QList<QStandardItem*> row
		{
			new QStandardItem { account->GetName () },
			new QStandardItem { account->GetServer () }
		};
		AccountsModel_->appendRow (row);

		connect (account.get (),
				SIGNAL (accountChanged ()),
				this,
				SLOT (saveAccounts ()));
		connect (account->GetFolderManager (),
				SIGNAL (foldersUpdated ()),
				this,
				SLOT (saveAccounts ()));
	}
Exemple #4
0
	void Core::LoadAccounts ()
	{
		QSettings settings (QCoreApplication::organizationName (),
				QCoreApplication::applicationName () + "_Snails_Accounts");
		Q_FOREACH (const QVariant& var, settings.value ("Accounts").toList ())
		{
			Account_ptr acc (new Account);
			try
			{
				acc->Deserialize (var.toByteArray ());
			}
			catch (const std::exception& e)
			{
				qWarning () << Q_FUNC_INFO
						<< "unable to deserialize account, sorry :("
						<< e.what ();
				continue;
			}
			AddAccountImpl (acc);
		}
	}
Exemple #5
0
	void Core::AddAccountImpl (Account_ptr account)
	{
		Accounts_ << account;

		QList<QStandardItem*> row;
		row << new QStandardItem (account->GetName ());
		row << new QStandardItem (account->GetServer ());
		row << new QStandardItem (account->GetType ());
		AccountsModel_->appendRow (row);

		ProgressManager_->AddAccount (account.get ());

		connect (account.get (),
				SIGNAL (accountChanged ()),
				this,
				SLOT (saveAccounts ()));
		connect (account->GetFolderManager (),
				SIGNAL (foldersUpdated ()),
				this,
				SLOT (saveAccounts ()));
	}