PrivacyDlg::PrivacyDlg(JabberAccount* acc, QWidget* parent) : KDialog(parent), acc_(acc)
{
	QWidget * w = new QWidget (this);
	ui_.setupUi(w);
	setMainWidget (w);
	setAttribute(Qt::WA_DeleteOnClose);
	setCaption(i18n("%1: Privacy Lists", (acc->myself()->nickName() ) ) );
	setButtons (KDialog::Close);
	ui_.lv_rules->setFocus (Qt::PopupFocusReason);

	PrivacyManager* manager = acc->client()->privacyManager();
	connect(manager,SIGNAL(listsReceived(QString,QString,QStringList)),SLOT(updateLists(QString,QString,QStringList)));
	connect(manager,SIGNAL(listReceived(PrivacyList)),SLOT(refreshList(PrivacyList)));
	connect(manager,SIGNAL(listError()),SLOT(list_failed()));
	//connect(manager,SIGNAL(listNamesError()),SLOT(listNamesError()));
	//connect(manager,SIGNAL(listReceiveError()),SLOT(listReceiveError()));

	connect(ui_.cb_active,SIGNAL(activated(int)),SLOT(active_selected(int)));
	connect(ui_.cb_default,SIGNAL(activated(int)),SLOT(default_selected(int)));
	connect(ui_.cb_lists,SIGNAL(activated(int)),SLOT(list_selected(int)));
	connect(ui_.cb_lists,SIGNAL(currentIndexChanged(int)),SLOT(list_changed(int)));
	connect(manager,SIGNAL(changeActiveList_success()),SLOT(change_succeeded()));
	connect(manager,SIGNAL(changeActiveList_error()),SLOT(change_failed()));
	connect(manager,SIGNAL(changeDefaultList_success()),SLOT(change_succeeded()));
	connect(manager,SIGNAL(changeDefaultList_error()),SLOT(change_failed()));
	connect(manager,SIGNAL(changeList_success()),SLOT(changeList_succeeded()));
	connect(manager,SIGNAL(changeList_error()),SLOT(changeList_failed()));

	connect(ui_.pb_newList,SIGNAL(clicked()),SLOT(newList()));
	connect(ui_.pb_deleteList,SIGNAL(clicked()),SLOT(removeList()));
	
	connect(ui_.pb_add,SIGNAL(clicked()),SLOT(addRule()));
	connect(ui_.pb_edit,SIGNAL(clicked()),SLOT(editCurrentRule()));
	connect(ui_.pb_remove,SIGNAL(clicked()),SLOT(removeCurrentRule()));
	connect(ui_.pb_up,SIGNAL(clicked()),SLOT(moveCurrentRuleUp()));
	connect(ui_.pb_down,SIGNAL(clicked()),SLOT(moveCurrentRuleDown()));
	connect(ui_.pb_apply,SIGNAL(clicked()),SLOT(applyList()));
	
	ui_.pb_newList->setIcon(KIcon("list-add"));
	ui_.pb_deleteList->setIcon(KIcon("list-remove"));
	ui_.pb_add->setIcon(KIcon("list-add"));
	ui_.pb_remove->setIcon(KIcon("list-remove"));
	ui_.pb_up->setIcon(KIcon("arrow-up"));
	ui_.pb_down->setIcon(KIcon("arrow-down"));
	ui_.pb_edit->setIcon(KIcon("edit-rename"));
	ui_.pb_apply->setIcon(KIcon("dialog-ok-apply"));

	setWidgetsEnabled(false);

	// Disable all buttons
	ui_.pb_deleteList->setEnabled(false);
	setEditRuleEnabled(false);
	ui_.pb_add->setEnabled(false);
	ui_.pb_apply->setEnabled(false);

	// FIXME: Temporarily disabling auto-activate
	ui_.ck_autoActivate->hide();
	
	manager->requestListNames();
}
YaPrivacyManager::YaPrivacyManager(PsiAccount* account)
	: PsiPrivacyManager(account->client()->rootTask())
	, account_(account)
	, accountAvailable_(false)
	, isAvailable_(false)
{
	connect(account, SIGNAL(updatedActivity()), SLOT(accountStateChanged()));

	connect(this, SIGNAL(listReceived(const PrivacyList&)), SLOT(listReceived(const PrivacyList&)));
	connect(this, SIGNAL(listsReceived(const QString&, const QString&, const QStringList&)), SLOT(listsReceived(const QString&, const QString&, const QStringList&)));
	connect(this, SIGNAL(listsError()), SLOT(listsError()));

	connect(this, SIGNAL(changeDefaultList_success()), SLOT(changeDefaultList_success()));
	connect(this, SIGNAL(changeDefaultList_error()), SLOT(changeDefaultList_error()));
	connect(this, SIGNAL(changeActiveList_success()), SLOT(changeActiveList_success()));
	connect(this, SIGNAL(changeActiveList_error()), SLOT(changeActiveList_error()));
}
Exemple #3
0
PrivacyDlg::PrivacyDlg(const QString& account_name, PrivacyManager* manager, QWidget* parent) : QDialog(parent), manager_(manager)
{
	ui_.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowTitle(tr("%1: Privacy Lists").arg(account_name));
	setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint);

	connect(manager_,SIGNAL(listsReceived(const QString&, const QString&, const QStringList&)),SLOT(updateLists(const QString&, const QString&, const QStringList&)));
	connect(manager_,SIGNAL(listReceived(const PrivacyList&)),SLOT(refreshList(const PrivacyList&)));
	connect(manager_,SIGNAL(listError()),SLOT(list_failed()));
	//connect(manager_,SIGNAL(listNamesError()),SLOT(listNamesError()));
	//connect(manager_,SIGNAL(listReceiveError()),SLOT(listReceiveError()));

	connect(ui_.cb_active,SIGNAL(activated(int)),SLOT(active_selected(int)));
	connect(ui_.cb_default,SIGNAL(activated(int)),SLOT(default_selected(int)));
	connect(ui_.cb_lists,SIGNAL(activated(int)),SLOT(list_selected(int)));
	connect(ui_.cb_lists,SIGNAL(currentIndexChanged(int)),SLOT(list_changed(int)));
	connect(manager_,SIGNAL(changeActiveList_success(QString)),SLOT(changeActiveList_succeeded(QString)));
	connect(manager_,SIGNAL(changeActiveList_error()),SLOT(change_failed()));
	connect(manager_,SIGNAL(changeDefaultList_success(QString)),SLOT(changeDefaultList_succeeded(QString)));
	connect(manager_,SIGNAL(changeDefaultList_error()),SLOT(change_failed()));
	connect(manager_,SIGNAL(changeList_success(QString)),SLOT(changeList_succeeded(QString)));
	connect(manager_,SIGNAL(changeList_error()),SLOT(changeList_failed()));

	connect(ui_.pb_newList,SIGNAL(clicked()),SLOT(newList()));
	connect(ui_.pb_deleteList,SIGNAL(clicked()),SLOT(removeList()));
	connect(ui_.pb_renameList,SIGNAL(clicked()),SLOT(renameList()));

	connect(ui_.pb_add,SIGNAL(clicked()),SLOT(addRule()));
	connect(ui_.pb_edit,SIGNAL(clicked()),SLOT(editCurrentRule()));
	connect(ui_.pb_remove,SIGNAL(clicked()),SLOT(removeCurrentRule()));
	connect(ui_.pb_up,SIGNAL(clicked()),SLOT(moveCurrentRuleUp()));
	connect(ui_.pb_down,SIGNAL(clicked()),SLOT(moveCurrentRuleDown()));
	connect(ui_.pb_apply,SIGNAL(clicked()),SLOT(applyList()));

	connect(ui_.buttonBox->button(QDialogButtonBox::Close),SIGNAL(clicked()),SLOT(close()));
	setWidgetsEnabled(false);

	// Disable all buttons
	ui_.pb_deleteList->setEnabled(false);
	setEditRuleEnabled(false);
	ui_.pb_add->setEnabled(false);
	ui_.pb_apply->setEnabled(false);

	// FIXME: Temporarily disabling auto-activate
	ui_.ck_autoActivate->hide();

	manager_->requestListNames();
}