Commit 05e13ee8 authored by yanmorin's avatar yanmorin
Browse files

Adding account alias

Moving session in SFLPhoneApp to a global pointer
New implementation of hangup/accept for iax
parent 1ad79199
......@@ -102,16 +102,16 @@ for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PREFIX'.
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PREFIX', the package will
use PREFIX as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
......@@ -159,7 +159,7 @@ where SYSTEM can have one of these forms:
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
......
......@@ -29,7 +29,7 @@ typedef std::string AccountID;
#define CONFIG_ACCOUNT_TYPE "Account.type"
#define CONFIG_ACCOUNT_ENABLE "Account.enable"
#define CONFIG_ACCOUNT_AUTO_REGISTER "Account.autoregister"
#define CONFIG_ACCOUNT_ALIAS "Account.alias"
/**
* Class account is an interface to protocol account (sipaccount, aixaccount)
......
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
/*
* Copyright (C) 2004-2006 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
......
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
/*
* Copyright (C) 2004-2006 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
......@@ -49,6 +50,9 @@ class Account {
QString id() const
{return mId;}
const QString& getAlias() { return mAlias; }
void setAlias(const QString& alias) { mAlias = alias; }
private:
Account();
......@@ -61,6 +65,11 @@ private:
* This is the account id that we are related to.
*/
QString mId;
/**
* This is the alias of the account, a name choose by the user
*/
QString mAlias;
};
......
......@@ -26,12 +26,11 @@
#include "Request.hpp" // don't know if it's a good idea for this class to know request...
ConfigurationManagerImpl::ConfigurationManagerImpl()
: mSession(NULL)
: mSession(0)
{}
ConfigurationManagerImpl::~ConfigurationManagerImpl()
{
delete mSession;
}
void
......@@ -45,9 +44,9 @@ ConfigurationManagerImpl::setCurrentMicrophoneVolume(unsigned int )
}
void
ConfigurationManagerImpl::setSession(const Session &session)
ConfigurationManagerImpl::setSession(Session* session)
{
mSession = new Session(session);
mSession = session;
}
void
......
......@@ -103,7 +103,7 @@ public:
/**
* will set the session to use.
*/
void setSession(const Session &session);
void setSession(Session* session);
/**
* This function will set the current speaker volume
......
......@@ -143,11 +143,7 @@
<property name="margin">
<number>0</number>
</property>
<widget class="QComboBox">
<property name="name"><cstring>cboSIPAccount</cstring></property>
<property name="currentItem"><number>0</number></property>
</widget>
<widget class="QGroupBox">
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
</property>
......@@ -161,7 +157,16 @@
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="3">
<widget class="QComboBox" rows="0" column="0" rowspan="1" colspan="2">
<property name="name"><cstring>cboSIPAccount</cstring></property>
<property name="currentItem"><number>0</number></property>
</widget>
<widget class="QLineEdit" row="0" column="2" rowspan="1" colspan="1">
<property name="name">
<cstring>alias</cstring>
</property>
</widget>
<widget class="QLabel" row="1" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>lblFullName</cstring>
</property>
......@@ -169,7 +174,7 @@
<string>Full name</string>
</property>
</widget>
<widget class="QLineEdit" row="1" column="0" rowspan="1" colspan="3">
<widget class="QLineEdit" row="2" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>fullName</cstring>
</property>
......@@ -182,7 +187,7 @@
</sizepolicy>
</property>
</widget>
<widget class="QLabel" row="2" column="0" rowspan="1" colspan="3">
<widget class="QLabel" row="3" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>lblUserHostPart</cstring>
</property>
......@@ -190,12 +195,12 @@
<string>User address (ie: user@domain.com)</string>
</property>
</widget>
<widget class="QLineEdit" row="3" column="0">
<widget class="QLineEdit" row="4" column="0">
<property name="name">
<cstring>userPart</cstring>
</property>
</widget>
<widget class="QLabel" row="3" column="1">
<widget class="QLabel" row="4" column="1">
<property name="name">
<cstring>lblArobase</cstring>
</property>
......@@ -203,7 +208,7 @@
<string>@</string>
</property>
</widget>
<widget class="QLineEdit" row="3" column="2">
<widget class="QLineEdit" row="4" column="2">
<property name="name">
<cstring>hostPart</cstring>
</property>
......@@ -1504,6 +1509,7 @@ Montreal, Quebec H2T 1S6, Canada&lt;/p&gt;</string>
</connections>
<tabstops>
<tabstop>cboSIPAccount</tabstop>
<tabstop>alias</tabstop>
<tabstop>fullName</tabstop>
<tabstop>userPart</tabstop>
<tabstop>hostPart</tabstop>
......
......@@ -135,7 +135,17 @@ ConfigurationPanel::generate()
cbo->clear();
int nbItem = 4;
for (int iItem = 0; iItem < nbItem; iItem++) {
QString accountName = QObject::tr("SIP Account #%1").arg(iItem+1);
QString accountId = "SIP" + QString::number(iItem);
QString aliasName = ConfigurationManager::instance().get(accountId, ACCOUNT_ALIAS);
QString accountName;
if (aliasName.isEmpty()) {
accountName = QObject::tr("SIP Account #%1").arg(iItem+1);
} else {
if (aliasName.length() > 30) {
aliasName = aliasName.left(30) + "...";
}
accountName = aliasName + " (" + QObject::tr("SIP Account #%1").arg(iItem+1) + ")";
}
cbo->insertItem(accountName,iItem);
}
loadSIPAccount(0);
......@@ -425,6 +435,11 @@ ConfigurationPanel::loadSIPAccount(int number)
chkEnable->setChecked(ConfigurationManager::instance()
.get(account,ACCOUNT_ENABLE).toUInt());
QString aliasName = ConfigurationManager::instance().get(account, ACCOUNT_ALIAS);
alias->setText(aliasName);
// void QComboBox::changeItem ( const QString & t, int index);
//
fullName->setText(ConfigurationManager::instance()
.get(account,SIGNALISATION_FULL_NAME));
userPart->setText(ConfigurationManager::instance()
......@@ -448,6 +463,18 @@ void
ConfigurationPanel::saveSIPAccount(int number)
{
QString account = "SIP" + QString::number(number);
QString aliasName = alias->text();
ConfigurationManager::instance().set(account, ACCOUNT_ALIAS, aliasName);
QString accountName;
if (aliasName.isEmpty()) {
accountName = QObject::tr("SIP Account #%1").arg(number+1);
} else {
if (aliasName.length() > 30) {
aliasName = aliasName.left(30) + "...";
}
accountName = aliasName + " (" + QObject::tr("SIP Account #%1").arg(number+1) + ")";
}
cboSIPAccount->changeItem(accountName, number);
ConfigurationManager::instance().set(account,
SIGNALISATION_FULL_NAME,
fullName->text());
......
......@@ -28,11 +28,13 @@ AccountItemEvent::AccountItemEvent(const QString &code,
: Event(code, args)
{
std::list< QString > l = getUnusedArgs();
if(l.size() >= 2) {
if(l.size() >= 3) {
mAccountId = *l.begin();
l.pop_front();
mStatus = *l.begin();
l.pop_front();
mAlias = *l.begin();
l.pop_front();
setUnusedArgs(l);
}
}
......@@ -44,7 +46,7 @@ AccountItemEvent::execute()
if (getCode() == "130") {
isEnabled = true;
}
PhoneLineManager::instance().addAccount(mAccountId, isEnabled);
PhoneLineManager::instance().addAccount(mAccountId, isEnabled, mAlias);
}
......@@ -34,6 +34,7 @@ public:
protected:
QString mAccountId;
QString mStatus;
QString mAlias;
};
#endif
......
......@@ -294,13 +294,13 @@ PhoneLine::call()
void
PhoneLine::call(const QString &to)
{
DebugOutput::instance() << tr("PhoneLine %1: Calling %2.\n").arg(mLine).arg(to);
if(!mCall) {
setLineStatus(tr("Calling %1...").arg(to));
Call *call;
if(!mCall) {
Call *call;
const Account* account = mSession->getSelectedAccount();
if (account!=0) {
Request *r = account->createCall(call, to);
setLineStatus(tr("Calling %1...").arg(to));
DebugOutput::instance() << tr("PhoneLine %1: Calling %2 on Account %3.\n").arg(mLine).arg(to).arg(account->id());
Request *r = account->createCall(call, to);
// entry
connect(r, SIGNAL(entry(QString, QString)),
this, SLOT(setLineStatus(QString)));
......
......@@ -84,7 +84,7 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
PhoneLineManagerImpl::~PhoneLineManagerImpl()
{
delete mSession;
//delete mSession;
for(std::vector< PhoneLine * >::iterator pos = mPhoneLines.begin();
pos != mPhoneLines.end();
pos++) {
......@@ -105,11 +105,11 @@ PhoneLineManagerImpl::hasDisconnected()
}
void
PhoneLineManagerImpl::initialize(const Session &session)
PhoneLineManagerImpl::initialize(Session* session)
{
if(!mIsInitialized) {
mIsInitialized = true;
mSession = new Session(session);
mSession = session;
}
}
......@@ -826,10 +826,10 @@ PhoneLineManagerImpl::incomingMessageText(const QString& message)
}
void
PhoneLineManagerImpl::addAccount(const QString& name, bool isEnabled)
PhoneLineManagerImpl::addAccount(const QString& name, bool isEnabled, const QString& alias)
{
if (mSession!=0) {
mSession->addAccount(name, isEnabled);
mSession->addAccount(name, isEnabled, alias);
}
}
......@@ -66,7 +66,7 @@ public:
bool isConnected() { return mIsConnected; }
void emitReadyAccount() { emit readyToGetAccount(); }
void emitReadyToShow() { emit readyToShow(); }
void addAccount(const QString& name, bool isEnabled);
void addAccount(const QString& name, bool isEnabled, const QString& alias);
signals:
void unselected(unsigned int);
void selected(unsigned int);
......@@ -113,7 +113,7 @@ public slots:
* You need to call this function once. It must be
* call before doing anything in this class.
*/
void initialize(const Session &session);
void initialize(Session* session);
/**
* This function will make the process to start.
......
......@@ -46,11 +46,11 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv)
{
SessionIOFactory::instance().setCreator(new TCPSessionIOCreator(QString("localhost"), 3999));
Session session;
mSession = new Session();
ConfigurationManager::instance().setSession(session);
ConfigurationManager::instance().setSession(mSession);
PhoneLineManager::instance().initialize(session);
PhoneLineManager::instance().initialize(mSession);
PhoneLineManager::instance().setNbLines(NB_PHONELINES);
Requester::instance().registerDefaultObject< Request >();
Requester::instance().registerObject< Request >(QString("playtone"));
......@@ -83,7 +83,9 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv)
}
SFLPhoneApp::~SFLPhoneApp()
{}
{
delete mSession; mSession = 0;
}
void
SFLPhoneApp::handleArg()
......
......@@ -33,6 +33,7 @@
class SFLPhoneWindow;
class Launcher;
class NumericKeypad;
class Session;
class SFLPhoneApp : public QApplication
{
......@@ -67,6 +68,7 @@ private:
Launcher *mLauncher;
NumericKeypad *mKeypad;
Session *mSession;
};
#endif
......@@ -215,11 +215,13 @@ Session::getAccount(const QString& name)
}
void
Session::addAccount(const QString& name, bool isEnabled)
Session::addAccount(const QString& name, bool isEnabled, const QString& alias)
{
DebugOutput::instance() << "Adding account..." << name << "\n";
std::map<QString, Account* >::iterator iter = mAccountMap.find(name);
if (iter == mAccountMap.end()) {
mAccountMap[name] = new Account(mId, name);
mAccountMap[name]->setAlias(alias);
// select account is the first enabled
if (mSelectedAccountId.isEmpty() && isEnabled) {
DebugOutput::instance() << "Default account is " << name << "\n";
......
......@@ -44,7 +44,7 @@ class Session
* or 0 if not found
*/
Account* getSelectedAccount();
void addAccount(const QString& name, bool isEnabled);
void addAccount(const QString& name, bool isEnabled, const QString& alias);
/**
* Set Selected Account ID
......
......@@ -52,6 +52,7 @@
#define ACCOUNT_TYPE "Account.type"
#define ACCOUNT_ENABLE "Account.enable"
#define ACCOUNT_AUTO_REGISTER "Account.autoregister"
#define ACCOUNT_ALIAS "Account.alias"
#define PREFERENCES_SECTION "Preferences"
#define PREFERENCES_THEME "Themes.skinChoice"
......
......@@ -103,7 +103,8 @@ IAXAccount::initConfig(Conf::ConfigTree& config)
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_TYPE, "IAX", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ENABLE,"1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_AUTO_REGISTER, "1", type_int));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(CONFIG_ACCOUNT_ALIAS, _("My account"), type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(IAX_HOST, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(IAX_USER, "", type_str));
config.addConfigTreeItem(section, Conf::ConfigTreeItem(IAX_PASS, "", type_str));
......
......@@ -240,6 +240,22 @@ IAXVoIPLink::newOutgoingCall(const CallID& id, const std::string& toUrl)
return call;
}
bool
IAXVoIPLink::hangup(const CallID& id)
{
IAXCall* call = getIAXCall(id);
if (call==0) { _debug("Call doesn't exists\n"); return false; }
_mutexIAX.enterMutex();
iax_hangup(call->getSession(),"Dumped Call");
_mutexIAX.leaveMutex();
if (Manager::instance().isCurrentCall(id)) {
// stop audio
}
removeCall(id);
return true;
}
bool
IAXVoIPLink::iaxOutgoingInvite(IAXCall* call)
{
......@@ -256,15 +272,21 @@ IAXVoIPLink::iaxOutgoingInvite(IAXCall* call)
call->setSession(newsession);
/* reset activity and ping "timers" */
// iaxc_note_activity(callNo);
char num[call->getPeerNumber().length()+1];
strcpy(num, call->getPeerNumber().c_str());
std::string strNum = _host + ":" + _pass + "@" + _user + "/" + call->getPeerNumber();
char user[_user.length()+1];
strcpy(user, _user.c_str());
char num[strNum.length()+1];
strcpy(num, strNum.c_str());
char* lang = NULL;
int wait = 0;
int audio_format_preferred = IAX__FORMAT_SPEEX;
int audio_format_capability = IAX__FORMAT_ULAW | IAX__FORMAT_ALAW | IAX__FORMAT_GSM | IAX__FORMAT_SPEEX;
iax_call(newsession, num, num, num, lang, wait, audio_format_preferred, audio_format_capability);
iax_call(newsession, user, user, num, lang, wait, audio_format_preferred, audio_format_capability);
// unlock here
_mutexIAX.leaveMutex();
......@@ -296,20 +318,48 @@ IAXVoIPLink::iaxHandleCallEvent(iax_event* event, IAXCall* call)
// call should not be 0
// note activity?
//
CallID id = call->getCallId();
switch(event->etype) {
case IAX_EVENT_HANGUP:
Manager::instance().peerHungupCall(id);
if (Manager::instance().isCurrentCall(id)) {
// stop audio
}
removeCall(id);
break;
case IAX_EVENT_REJECT:
break;
Manager::instance().peerHungupCall(id);
if (Manager::instance().isCurrentCall(id)) {
// stop audio
}
removeCall(id);
break;
case IAX_EVENT_ACCEPT:
// accept
//
break;
case IAX_EVENT_ANSWER:
if (call->getConnectionState() != Call::Connected){
call->setConnectionState(Call::Connected);
call->setState(Call::Active);
Manager::instance().peerAnsweredCall(id);
// start audio here?
} else {
// deja connecté
// ?
}
break;
case IAX_EVENT_BUSY:
call->setConnectionState(Call::Connected);
call->setState(Call::Busy);
Manager::instance().displayErrorText(id, "Busy");
Manager::instance().callBusy(id);
removeCall(id);
break;
case IAX_EVENT_VOICE:
......@@ -356,3 +406,13 @@ IAXVoIPLink::iaxHandleRegReply(iax_event* event)
Manager::instance().registrationSucceed(getAccountID());
}
}
IAXCall*
IAXVoIPLink::getIAXCall(const CallID& id)
{
Call* call = getCall(id);
if (call) {
return dynamic_cast<IAXCall*>(call);
}
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment