From 6e4d4cad3f64258286924f062b11d964248784c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Quentin?=
 <jquentin@jquentin-laptop-kub2.(none)>
Date: Tue, 26 May 2009 15:34:58 -0400
Subject: [PATCH] [#1526] Set accounts order + doc

---
 sflphone-client-kde/AccountList.cpp       | 46 ++++++++++++++++++++++-
 sflphone-client-kde/AccountList.h         |  5 +++
 sflphone-client-kde/ConfigDialog.cpp      |  4 ++
 sflphone-client-kde/doc/basic-use.docbook | 12 +++++-
 sflphone-client-kde/main.cpp              |  2 +
 sflphone-common/src/managerimpl.cpp       |  1 +
 sflphone-common/src/sipvoiplink.h         |  2 +-
 7 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/sflphone-client-kde/AccountList.cpp b/sflphone-client-kde/AccountList.cpp
index e9153cd914..5b0996e5aa 100644
--- a/sflphone-client-kde/AccountList.cpp
+++ b/sflphone-client-kde/AccountList.cpp
@@ -44,6 +44,41 @@ void AccountList::update()
 	}
 }
 
+void AccountList::upAccount(int index)
+{
+	if(index <= 0 || index >= size())
+	{
+		qDebug() << "Error : index or future index out of range in upAccount.";
+		return;
+	}
+	Account & account = getAccount(index);
+	accounts->remove(index);
+	accounts->insert(index - 1, & account);
+}
+
+void AccountList::downAccount(int index)
+{
+	if(index < 0 || index >= size() - 1)
+	{
+		qDebug() << "Error : index or future index out of range in upAccount.";
+		return;
+	}
+	Account & account = getAccount(index);
+	accounts->remove(index);
+	accounts->insert(index + 1, & account);
+}
+
+
+QString AccountList::getOrderedList()
+{
+	QString order;
+	for( int i = 0 ; i < size() ; i++)
+	{
+		order += getAccount(i).getAccountId() + "/";
+	}
+	return order;
+}
+
 QVector<Account *> AccountList::registeredAccounts() const
 {
 	qDebug() << "registeredAccounts";
@@ -94,6 +129,16 @@ QVector<Account *> & AccountList::getAccounts()
 	return *accounts;
 }
 
+const Account & AccountList::getAccount (int i) const
+{
+	return *((*accounts)[i]);
+}
+
+Account & AccountList::getAccount (int i)
+{
+	return *((*accounts)[i]);
+}
+
 Account * AccountList::getAccountById(const QString & id) const
 {
 	for (int i = 0; i < accounts->size(); ++i)
@@ -114,7 +159,6 @@ QVector<Account *> AccountList::getAccountByState(QString & state)
 			v += (*accounts)[i];
 	}
 	return v;
-
 }
 /*
 Account AccountList::getAccountByRow(int row)
diff --git a/sflphone-client-kde/AccountList.h b/sflphone-client-kde/AccountList.h
index 846ce3be69..3e3cee3586 100644
--- a/sflphone-client-kde/AccountList.h
+++ b/sflphone-client-kde/AccountList.h
@@ -22,17 +22,22 @@ public:
 	
 	//Getters
 	QVector<Account *> & getAccounts();
+	Account & getAccount (int i);
+	const Account & getAccount (int i) const;
 	Account * getAccountById(const QString & id) const;
 	QVector<Account *>  getAccountByState(QString & state);
 	Account * getAccountByItem(QListWidgetItem * item);
 	int size();
 	Account * firstRegisteredAccount() const;
+	QString getOrderedList();
 	
 	//Setters
 	Account * addAccount(QString & alias);
 	void removeAccount(Account * account);
 	void removeAccount(QListWidgetItem * item);
 	void setAccountFirst(Account * account);
+	void upAccount(int index);
+	void downAccount(int index);
 
 	//Operators
 	Account & operator[] (int i);
diff --git a/sflphone-client-kde/ConfigDialog.cpp b/sflphone-client-kde/ConfigDialog.cpp
index a6f6677ef0..d939033996 100644
--- a/sflphone-client-kde/ConfigDialog.cpp
+++ b/sflphone-client-kde/ConfigDialog.cpp
@@ -363,6 +363,7 @@ void ConfigurationDialog::loadAccountList()
 		frame2_editAccounts->setEnabled(false);
 }
 
+
 void ConfigurationDialog::saveAccountList()
 {
 	//get the configurationManager instance
@@ -408,6 +409,7 @@ void ConfigurationDialog::saveAccountList()
 			configurationManager.removeAccount(accountIds[i]);
 		}
 	}
+	configurationManager.setAccountsOrder(accountList->getOrderedList());
 }
 
 void ConfigurationDialog::loadAccount(QListWidgetItem * item)
@@ -649,6 +651,7 @@ void ConfigurationDialog::on_button_accountUp_clicked()
 	Account * account = accountList->getAccountByItem(prevItem);
 	//we need to build a new item to set the itemWidget back
 	QListWidgetItem * item = account->renewItem();
+	accountList->upAccount(currentRow);
 	delete prevItem;
 	listWidget_accountList->insertItem(currentRow - 1 , item);
 	listWidget_accountList->setItemWidget(item, account->getItemWidget());
@@ -661,6 +664,7 @@ void ConfigurationDialog::on_button_accountDown_clicked()
 	QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow);
 	Account * account = accountList->getAccountByItem(prevItem);
 	QListWidgetItem * item = account->renewItem();
+	accountList->downAccount(currentRow);
 	delete prevItem;
 	listWidget_accountList->insertItem(currentRow + 1 , item);
 	listWidget_accountList->setItemWidget(item, account->getItemWidget());
diff --git a/sflphone-client-kde/doc/basic-use.docbook b/sflphone-client-kde/doc/basic-use.docbook
index cb642573e7..d089a2c123 100644
--- a/sflphone-client-kde/doc/basic-use.docbook
+++ b/sflphone-client-kde/doc/basic-use.docbook
@@ -27,7 +27,7 @@ To switch between those windows, click on the history and address book buttons.
 
 
 <sect1 id="basic-use-call">
-<title>Calling somebody</title>
+<title>Making a call</title>
 
 <sect2 id="basic-use-call-current">
 <title>Dialing one's number</title>
@@ -103,4 +103,14 @@ To switch between those windows, click on the history and address book buttons.
 
 
 
+<sect1 id="basic-use-config">
+<title>Configuration panel</title>
+
+<para>The configuration panel is built in accordance with KDE specifications. It is divided by options type. The panel at left shows the different option pages you can reach. Click on one of them to acceed to the corresponding page. The changes you make are not applied until you click OK or Apply. Clicking Cancel will cancel and forget every change you made since the last Apply or OK command. Be careful not to forget some changes you made in some other pages if you wanted to Cancel it. </para>
+
+<para>There is also a specific Apply button just for the account list which is useful to manage these accounts and valid your changes to see if the accounts are well registered. </para>
+
+</sect1>
+
+
 </chapter>
diff --git a/sflphone-client-kde/main.cpp b/sflphone-client-kde/main.cpp
index d80209283c..6dadd47f33 100644
--- a/sflphone-client-kde/main.cpp
+++ b/sflphone-client-kde/main.cpp
@@ -16,6 +16,8 @@
 #include "instance_interface_singleton.h"
 #include "sflphone_const.h"
 
+
+
 static const char description[] = I18N_NOOP("A KDE 4 Client for SFLPhone");
 
 static const char version[] = "0.9.5";
diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp
index 1dce0670c7..9aa4d0cf44 100644
--- a/sflphone-common/src/managerimpl.cpp
+++ b/sflphone-common/src/managerimpl.cpp
@@ -2176,6 +2176,7 @@ ManagerImpl::setConfig(const std::string& section, const std::string& name, int
 
 void ManagerImpl::setAccountsOrder (const std::string& order) 
 {
+    _debug("Set accounts order : %s\n", order.c_str() );
     // Set the new config
     setConfig (PREFERENCES, CONFIG_ACCOUNTS_ORDER, order);
 }
diff --git a/sflphone-common/src/sipvoiplink.h b/sflphone-common/src/sipvoiplink.h
index 56d17b4b97..028fcd8a2f 100644
--- a/sflphone-common/src/sipvoiplink.h
+++ b/sflphone-common/src/sipvoiplink.h
@@ -42,7 +42,7 @@ class AudioRtp;
 #define RANDOM_SIP_PORT   rand() % 64000 + 1024
 
 // To set the verbosity. From 0 (min) to 6 (max)
-#define PJ_LOG_LEVEL 6
+#define PJ_LOG_LEVEL 0
 
 /**
  * @file sipvoiplink.h
-- 
GitLab