Skip to content
Snippets Groups Projects
Commit 0e2d71f7 authored by jpbl's avatar jpbl
Browse files

reversed the deps incorporation

parent 4576d10f
No related branches found
No related tags found
No related merge requests found
Showing
with 6 additions and 3089 deletions
......@@ -93,7 +93,7 @@ dnl AC_SUBST(LIBQT)
if test $ac_cv_header_portaudio_h = no; then
AC_MSG_ERROR([*** missing portaudio.h. You need a working PortAudio installation. See http://www.portaudio.com])
else
portaudio_LIBS="-lportaudio "
portaudio_LIBS="-lportaudio -lasound "
portaudio_CFLAGS="-DAUDIO_PORTAUDIO "
fi
......@@ -142,6 +142,8 @@ fi
AC_SUBST(LIB_DNSSD)
AM_CONDITIONAL(USE_ZEROCONF, test "$have_libdns_sd" = "yes")
AC_CONFIG_SUBDIRS(src/gui/qt)
dnl AC_CONFIG_FILES(
AC_OUTPUT(
sflphone.spec \
......
serverdir = server
serverlib = server/libsflphoneguiserver.la
libexec_PROGRAMS = qt/sflphone-qt
#libexec_PROGRAMS = qt/sflphone-qt
qt/sflphone-qt:
cd qt && make
#qt/sflphone-qt:
# cd qt && make
SUBDIRS = $(serverdir)
......
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Account.hpp"
#include "Requester.hpp"
#include "Call.hpp"
Account::Account(const QString &sessionId,
const QString &name)
: mSessionId(sessionId)
, mId(name)
{}
Request *
Account::registerAccount() const
{
std::list< QString > args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "register", args);
}
Request *
Account::unregisterAccount() const
{
std::list< QString > args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "unregister", args);
}
Request *
Account::createCall(Call * &call, const QString &to) const
{
QString callId = Requester::instance().generateCallId();
call = new Call(mSessionId, mId, callId, to);
std::list< QString> args;
args.push_back(mId);
args.push_back(callId);
args.push_back(to);
return Requester::instance().send(mSessionId, "call", args);
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef SFLPHONEGUI_ACCOUNT_H
#define SFLPHONEGUI_ACCOUNT_H
#include <qstring.h>
#include "Call.hpp"
class Request;
class Account {
public:
Account(const QString &sessionId,
const QString &name);
/**
* This will generate a call ready to be used.
*/
Request *registerAccount() const;
Request *unregisterAccount() const;
/**
* This function will create a call. The call pointer will
* point to a newly allocated memory. You're responsible for
* deleting this memory.
*/
Request *createCall(Call * &call, const QString &to) const;
QString id() const
{return mId;}
private:
Account();
/**
* This is the session id that we are related to.
*/
QString mSessionId;
/**
* This is the account id that we are related to.
*/
QString mId;
};
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qstring.h>
#include <list>
#include "Account.hpp"
#include "Call.hpp"
#include "CallManager.hpp"
#include "Session.hpp"
#include "Requester.hpp"
Call::Call(const QString &sessionId,
const QString &accountId,
const QString &callId,
const QString &peer,
bool incomming)
: mSessionId(sessionId)
, mAccountId(accountId)
, mId(callId)
, mPeer(peer)
, mIsIncomming(incomming)
{
CallManager::instance().registerCall(*this);
}
Call::Call(const Session &session,
const Account &account,
const QString &callId,
const QString &peer,
bool incomming)
: mSessionId(session.id())
, mAccountId(account.id())
, mId(callId)
, mPeer(peer)
, mIsIncomming(incomming)
{
CallManager::instance().registerCall(*this);
}
bool
Call::isIncomming()
{return mIsIncomming;}
Request *
Call::answer()
{
mIsIncomming = false;
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "answer", args);
}
Request *
Call::hangup()
{
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "hangup", args);
}
Request *
Call::cancel()
{
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "cancel", args);
}
Request *
Call::hold()
{
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "hold", args);
}
Request *
Call::unhold()
{
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "unhold", args);
}
Request *
Call::refuse()
{
mIsIncomming = false;
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "refuse", args);
}
Request *
Call::notAvailable()
{
mIsIncomming = false;
std::list< QString> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "notavailable", args);
}
Request *
Call::transfer(const QString &to)
{
std::list< QString> args;
args.push_back(mId);
args.push_back(to);
return Requester::instance().send(mSessionId, "transfer", args);
}
Request *
Call::sendDtmf(char c)
{
std::list< QString> args;
args.push_back(mId);
QString s;
s += c;
args.push_back(s);
return Requester::instance().send(mSessionId, "senddtmf", args);
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef SFLPHONEGUI_CALL_H
#define SFLPHONEGUI_CALL_H
#include <qstring.h>
class Account;
class Request;
class Session;
class Call
{
public:
/**
* A call is automaticaly registered in
* the CallManager. However, a call isn't
* registered when you have a copy constructor.
*/
Call(const QString &sessionId,
const QString &accountId,
const QString &callId,
const QString &destination,
bool incomming = false);
Call(const Session &session,
const Account &account,
const QString &callId,
const QString &destination,
bool incomming = false);
/**
* This function returns true if the
* call is waiting to be picked up.
*/
bool isIncomming();
QString id() const
{return mId;}
QString peer() const
{return mPeer;}
/**
* This function will answer the call.
*/
Request *answer();
/**
* This function will try to transfer the
* call to the peer.
*/
Request *transfer(const QString &to);
/**
* This function will hangup on a call.
*/
Request *hangup();
/**
* ///TODO need to clarify this function.
*/
Request *cancel();
/**
* This function will put the call on hold.
* This *should* stop temporarly the streaming.
*/
Request *hold();
/**
* This function will unhold a holding call.
* This *should* restart a stopped streaming.
*/
Request *unhold();
/**
* This function refuse and incomming call.
* It means that the phone is ringing but we
* don't want to answer.
*/
Request *refuse();
/**
* This function will set this client to be
* not able to receive the call. It means that
* the phone can still ring. But if every client
* sent notavailable, then it will be refused.
*/
Request *notAvailable();
/**
* This function will send a tone to the line.
* This is used if you make a choice when you
* have a voice menu.
*/
Request *sendDtmf(char c);
private:
/**
* This is the session id that we belong to.
*/
QString mSessionId;
/**
* This is the account id that we belong to.
*/
QString mAccountId;
/**
* This is the unique identifier of the call.
*/
QString mId;
/**
* This is the destination of the call.
*/
QString mPeer;
bool mIsIncomming;
};
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author : Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CALL_MANAGER_HPP__
#define __CALL_MANAGER_HPP__
#include "utilspp/Singleton.hpp"
#include "CallManagerImpl.hpp"
typedef utilspp::SingletonHolder< CallManagerImpl > CallManager;
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qobject.h>
#include <stdexcept>
#include "CallManagerImpl.hpp"
#include "DebugOutput.hpp"
void
CallManagerImpl::registerCall(const Call &call)
{
mCalls.insert(std::make_pair(call.id(), call));
}
void
CallManagerImpl::unregisterCall(const Call &call)
{
unregisterCall(call.id());
}
void
CallManagerImpl::unregisterCall(const QString &id)
{
std::map< QString, Call >::iterator pos = mCalls.find(id);
if(pos != mCalls.end()) {
mCalls.erase(pos);
}
}
bool
CallManagerImpl::exist(const QString &id)
{
std::map< QString, Call >::iterator pos = mCalls.find(id);
if(pos == mCalls.end()) {
return false;
}
return true;
}
Call
CallManagerImpl::getCall(const QString &id)
{
std::map< QString, Call >::iterator pos = mCalls.find(id);
if(pos == mCalls.end()) {
throw std::runtime_error("Trying to retreive an unregistred call\n");
}
return pos->second;
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CALL_MANAGER_IMPL_HPP__
#define __CALL_MANAGER_IMPL_HPP__
#include <qmutex.h>
#include <qstring.h>
#include <map>
#include "Call.hpp"
class CallManagerImpl
{
public:
void registerCall(const Call &call);
void unregisterCall(const Call &call);
void unregisterCall(const QString &id);
/**
* Return true if the call is registered.
*/
bool exist(const QString &id);
/**
* Return the call with the given id. If
* there's no such call it will throw a
* std::runtime_error.
*/
Call getCall(const QString &id);
private:
std::map< QString, Call > mCalls;
};
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "globals.h"
#include "CallStatus.hpp"
#include "PhoneLineManager.hpp"
CallStatus::CallStatus(const QString &code,
const std::list< QString > &args)
: CallRelatedEvent(code, args)
{
std::list< QString > l = getUnusedArgs();
if(l.size() >= 3) {
mAccountId = *l.begin();
l.pop_front();
mDestination = *l.begin();
l.pop_front();
mStatus = *l.begin();
l.pop_front();
setUnusedArgs(l);
}
}
void
CallStatus::execute()
{
QString id = getCallId();
if(id.length() > 0) {
DebugOutput::instance() << QObject::tr("%1 status received for call ID: %2.\n")
.arg(mStatus)
.arg(id);
PhoneLineManager::instance().addCall(mAccountId, getCallId(), mDestination, mStatus);
}
else {
DebugOutput::instance() << QObject::tr("Status invalid: %1\n").arg(toString());
}
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CALLSTATUS_HPP__
#define __CALLSTATUS_HPP__
#include "Event.hpp"
class CallStatus : public CallRelatedEvent
{
public:
CallStatus(const QString &code,
const std::list< QString > &args);
void execute();
protected:
QString mAccountId;
QString mDestination;
QString mStatus;
};
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CALLSTATUSFACTORY_HPP__
#define __CALLSTATUSFACTORY_HPP__
#include "EventFactory.hpp"
typedef utilspp::SingletonHolder< EventFactoryImpl< Event > > CallStatusFactory;
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author : Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CONFIGURATION_MANAGER_HPP__
#define __CONFIGURATION_MANAGER_HPP__
#include "utilspp/Singleton.hpp"
#include "ConfigurationManagerImpl.hpp"
typedef utilspp::SingletonHolder< ConfigurationManagerImpl > ConfigurationManager;
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
<jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ConfigurationManagerImpl.hpp"
#include "DebugOutput.hpp"
#include "Session.hpp"
ConfigurationManagerImpl::ConfigurationManagerImpl()
: mSession(NULL)
{}
ConfigurationManagerImpl::~ConfigurationManagerImpl()
{
delete mSession;
}
void
ConfigurationManagerImpl::setCurrentSpeakerVolume(unsigned int )
{
}
void
ConfigurationManagerImpl::setCurrentMicrophoneVolume(unsigned int )
{
}
void
ConfigurationManagerImpl::setSession(const Session &session)
{
mSession = new Session(session);
}
void
ConfigurationManagerImpl::save()
{
if(mSession) {
SectionMap::iterator pos = mEntries.begin();
while(pos != mEntries.end()) {
VariableMap::iterator vpos = pos->second.begin();
while(vpos != pos->second.end()) {
ConfigEntry entry(vpos->second);
mSession->configSet(entry.section, entry.name, entry.value);
vpos++;
}
pos++;
}
mSession->configSave();
}
else {
DebugOutput::instance() << QObject::tr("ConfigurationManagerImpl::save(): "
"We don't have a valid session.\n");
}
}
void
ConfigurationManagerImpl::finishSave()
{
emit saved();
}
void
ConfigurationManagerImpl::add(const ConfigEntry &entry)
{
mEntries[entry.section][entry.name] = entry;
}
void
ConfigurationManagerImpl::addAudioDevice(QString index,
QString hostApiName,
QString deviceName)
{
AudioDevice device;
device.index = index;
device.hostApiName = hostApiName;
device.deviceName = deviceName;
add(device);
}
void
ConfigurationManagerImpl::add(const AudioDevice &entry)
{
mAudioDevices.push_back(entry);
emit audioDevicesUpdated();
}
void
ConfigurationManagerImpl::addRingtone(QString index, QString filename)
{
Ringtone tone;
tone.index = index;
tone.filename = filename;
add(tone);
}
void
ConfigurationManagerImpl::add(const Ringtone &entry)
{
mRingtones.push_back(entry);
emit ringtonesUpdated();
}
void
ConfigurationManagerImpl::set(const QString &section,
const QString &name,
const QString &value)
{
SectionMap::iterator pos = mEntries.find(section);
if(pos != mEntries.end()) {
VariableMap::iterator vpos = pos->second.find(name);
if(vpos != pos->second.end()) {
vpos->second.value = value;
}
}
}
QString
ConfigurationManagerImpl::get(const QString &section,
const QString &name)
{
QString value;
SectionMap::iterator pos = mEntries.find(section);
if(pos != mEntries.end()) {
VariableMap::iterator vpos = pos->second.find(name);
if(vpos != pos->second.end()) {
value = vpos->second.value;
}
}
return value;
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
<jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CONFIGURATION_MANAGER_IMPL_HPP__
#define __CONFIGURATION_MANAGER_IMPL_HPP__
#include <list>
#include <map>
#include <qobject.h>
#include <vector>
struct AudioDevice
{
public:
QString index;
QString hostApiName;
QString deviceName;
};
struct Ringtone
{
public:
QString index;
QString filename;
};
/**
* This is the representation of a configuration
* entry.
*/
struct ConfigEntry
{
public:
ConfigEntry(){}
ConfigEntry(QString s,
QString n,
QString t,
QString d,
QString v)
{
section = s;
name = n;
type = t;
def = d;
value = v;
}
QString section;
QString name;
QString type;
QString def;
QString value;
};
class Session;
class ConfigurationManagerImpl : public QObject
{
Q_OBJECT
signals:
void audioDevicesUpdated();
void ringtonesUpdated();
void updated();
void saved();
public:
ConfigurationManagerImpl();
~ConfigurationManagerImpl();
/**
* will set the session to use.
*/
void setSession(const Session &session);
/**
* This function will set the current speaker volume
* to the given percentage. If it's greater than 100
* it will be set to 100.
*/
void setCurrentSpeakerVolume(unsigned int percentage);
/**
* This function will set the current microphone volume
* to the given percentage. If it's greater than 100
* it will be set to 100.
*/
void setCurrentMicrophoneVolume(unsigned int percentage);
void set(const QString &section,
const QString &name,
const QString &value);
QString get(const QString &section,
const QString &name);
void clearAudioDevices()
{mAudioDevices.clear();}
std::list< AudioDevice > getAudioDevices()
{return mAudioDevices;}
std::list< Ringtone > getRingtones()
{return mRingtones;}
void complete()
{emit updated();}
void save();
void finishSave();
public slots:
void add(const ConfigEntry &entry);
void addAudioDevice(QString index, QString hostApiName, QString deviceName);
void add(const AudioDevice &entry);
void addRingtone(QString index, QString filename);
void add(const Ringtone &entry);
private:
typedef std::map< QString, ConfigEntry > VariableMap;
typedef std::map< QString, VariableMap > SectionMap;
SectionMap mEntries;
std::list< AudioDevice > mAudioDevices;
std::list< Ringtone > mRingtones;
Session *mSession;
};
#endif
This diff is collapsed.
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <qdir.h>
#include <qmessagebox.h>
#include <qstringlist.h>
#include "globals.h"
#include "ConfigurationManager.hpp"
#include "DebugOutput.hpp"
#include "QjListBoxPixmap.hpp"
#include "TransparentWidget.hpp"
#define SIGNALISATIONS_IMAGE "signalisations.png"
#define AUDIO_IMAGE "audio.png"
#define PREFERENCES_IMAGE "preferences.png"
#define ABOUT_IMAGE "about.png"
void ConfigurationPanel::init()
{
DebugOutput::instance() << "ConfigurationPanel::init()\n";
Tab_Signalisations->show();
Tab_Audio->hide();
Tab_Preferences->hide();
Tab_About->hide();
/*
// For reading settings at application startup
// List skin choice from "skins" directory
QDir dir(Skin::getPath(QString(SKINDIR)));
if ( !dir.exists() ) {
_debug("\nCannot find 'skins' directory\n");
return;
} else {
dir.setFilter( QDir::Dirs | QDir::NoSymLinks);
dir.setSorting( QDir::Name );
QStringList list;
list = dir.entryList();
for (unsigned int i = 0; i < dir.count(); i++) {
if (list[i] != "." && list[i] != ".." && list[i] != "CVS") {
SkinChoice->insertItem(list[i]);
}
}
}
*/
/*
// For preferences tab
SkinChoice->setCurrentText(QString(manager.getConfigString(
PREFERENCES, SKIN_CHOICE)));
confirmationToQuit->setChecked(manager.getConfigInt(
PREFERENCES, CONFIRM_QUIT));
zoneToneChoice->setCurrentText(QString(manager.getConfigString(
PREFERENCES, ZONE_TONE)));
checkedTray->setChecked(manager.getConfigInt(
PREFERENCES, CHECKED_TRAY));
voicemailNumber->setText(QString(manager.getConfigString(
PREFERENCES, VOICEMAIL_NUM)));
*/
// Init tab view order
// Set items for QListBox
new QjListBoxPixmap (QjListBoxPixmap::Above,
TransparentWidget::retreive(SIGNALISATIONS_IMAGE),
"Signalisation",
Menu);
new QjListBoxPixmap (QjListBoxPixmap::Above,
TransparentWidget::retreive(AUDIO_IMAGE),
"Audio", Menu );
//new QjListBoxPixmap (QjListBoxPixmap::Above,
// TransparentWidget::retreive(PREFERENCES_IMAGE),
// "Preferences",
// Menu);
new QjListBoxPixmap (QjListBoxPixmap::Above,
TransparentWidget::retreive(ABOUT_IMAGE),
"About",
Menu);
QObject::connect(Register, SIGNAL(clicked()),
this, SIGNAL(needRegister()));
}
void
ConfigurationPanel::generate()
{
// For audio tab
codec1->setCurrentText(ConfigurationManager::instance()
.get(AUDIO_SECTION, AUDIO_CODEC1));
codec2->setCurrentText(ConfigurationManager::instance()
.get(AUDIO_SECTION, AUDIO_CODEC2));
codec3->setCurrentText(ConfigurationManager::instance()
.get(AUDIO_SECTION, AUDIO_CODEC3));
ringsChoice->setCurrentText(ConfigurationManager::instance()
.get(AUDIO_SECTION,
AUDIO_RINGTONE));
// For signalisations tab
fullName->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_FULL_NAME));
userPart->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_USER_PART));
username->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_AUTH_USER_NAME));
password->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_PASSWORD));
hostPart->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_HOST_PART));
sipproxy->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_PROXY));
autoregister->setChecked(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_AUTO_REGISTER).toUInt());
playTones->setChecked(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_PLAY_TONES).toUInt());
pulseLength->setValue(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_PULSE_LENGTH).toUInt());
sendDTMFas->setCurrentItem(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_SEND_DTMF_AS).toUInt());
STUNserver->setText(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_STUN_SERVER));
((QRadioButton*)stunButtonGroup->find(ConfigurationManager::instance()
.get(SIGNALISATION_SECTION,
SIGNALISATION_USE_STUN).toUInt()))->setChecked(true);
QRadioButton* device =
static_cast< QRadioButton * >(DriverChoice->find(ConfigurationManager::instance()
.get(AUDIO_SECTION,
AUDIO_DEFAULT_DEVICE).toUInt()));
if(device) {
device->setChecked(true);
}
}
// For saving settings at application 'save'
void ConfigurationPanel::saveSlot()
{
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_FULL_NAME,
fullName->text());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_USER_PART,
userPart->text());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_AUTH_USER_NAME,
username->text());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_PASSWORD,
password->text());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_HOST_PART,
hostPart->text());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_PROXY,
sipproxy->text());
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_AUTO_REGISTER,
QString::number(autoregister->isChecked()));
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_PULSE_LENGTH,
QString::number(pulseLength->value()));
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_PLAY_TONES,
QString::number(playTones->isChecked()));
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_SEND_DTMF_AS,
QString::number(sendDTMFas->currentItem()));
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_STUN_SERVER,
STUNserver->text());
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_CODEC1,
codec1->currentText());
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_CODEC2,
codec2->currentText());
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_CODEC3,
codec3->currentText());
if (ringsChoice->currentText() != NULL) {
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_RINGTONE,
ringsChoice->currentText());
}
ConfigurationManager::instance().set("Preferences", "Themes.skinChoice",
SkinChoice->currentText());
ConfigurationManager::instance().set("Preferences", "Options.zoneToneChoice",
zoneToneChoice->currentText());
#if 0
QMessageBox::information(this, "Save settings",
"You must restart SFLPhone",
QMessageBox::Yes);
#endif
ConfigurationManager::instance().save();
}
// Handle tab view according to current item of listbox
void ConfigurationPanel::changeTabSlot()
{
switch (Menu->currentItem()) {
case 0:
TitleTab->setText("Setup signalisation");
Tab_Signalisations->show();
Tab_Audio->hide();
Tab_Preferences->hide();
Tab_About->hide();
break;
case 1:
TitleTab->setText("Setup audio");
Tab_Signalisations->hide();
Tab_Audio->show();
Tab_Preferences->hide();
Tab_About->hide();
break;
case 2:
/* TitleTab->setText("Setup preferences"); */
/* Tab_Signalisations->hide(); */
/* Tab_Audio->hide(); */
/* Tab_Preferences->show(); */
/* Tab_About->hide(); */
/* break; */
case 3:
TitleTab->setText("About");
Tab_Signalisations->hide();
Tab_Audio->hide();
Tab_Preferences->hide();
Tab_About->show();
break;
}
}
void ConfigurationPanel::useStunSlot(int id)
{
ConfigurationManager::instance().set(SIGNALISATION_SECTION,
SIGNALISATION_USE_STUN,
QString::number(id));
}
void ConfigurationPanel::applySkinSlot()
{
//Manager::instance().setConfig("Preferences", "Themes.skinChoice",
//string(SkinChoice->currentText().ascii()));
}
void ConfigurationPanel::driverSlot(int id)
{
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_DEFAULT_DEVICE,
QString::number(id));
}
void ConfigurationPanel::updateRingtones()
{
std::list< Ringtone > rings = ConfigurationManager::instance().getRingtones();
std::list< Ringtone >::iterator pos;
ringsChoice->clear();
for (pos = rings.begin(); pos != rings.end(); pos++) {
ringsChoice->insertItem(pos->filename);
}
}
void ConfigurationPanel::updateAudioDevices()
{
static std::list< QRadioButton * > buttons;
while(buttons.begin() != buttons.end()) {
DriverChoice->remove(*buttons.begin());
buttons.pop_front();
}
int top = 0;
std::list< AudioDevice > audio = ConfigurationManager::instance().getAudioDevices();
std::list< AudioDevice >::iterator pos;
for (pos = audio.begin(); pos != audio.end(); pos++) {
QString hostApiName = pos->hostApiName;
QString deviceName = pos->deviceName;
QString name = hostApiName +
QObject::tr(" (device #%1)").arg(pos->index);
// New radio button with found device name
QRadioButton* device = new QRadioButton(DriverChoice);
buttons.push_back(device);
DriverChoice->insert(device, pos->index.toUInt());
device->setGeometry( QRect( 10, 30 + top, 390, 21 ) );
// Set label of radio button
//device->setText(deviceName);
// Add tooltip for each one
QString text = deviceName + " " + name;
if(text.length() > 50) {
device->setText(text.left(50) + "...");
}
else {
device->setText(text);
}
QToolTip::add(device, text);
top += 30;
}
// Set position of the button group, with appropriate length
DriverChoice->setGeometry( QRect( 10, 10, 410, top + 30 ) );
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <qbutton.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qsizepolicy.h>
#include "ConfigurationPanelImpl.hpp"
ConfigurationPanelImpl::ConfigurationPanelImpl(QWidget *parent)
: QDialog(parent)
{
mLayout = new QVBoxLayout(this);
}
void
ConfigurationPanelImpl::add(const ConfigEntry &entry)
{
mEntries[entry.section].push_back(entry);
}
void
ConfigurationPanelImpl::generate()
{
std::map< QString, std::list< ConfigEntry > >::iterator pos = mEntries.begin();
while(pos != mEntries.end()) {
QVBoxLayout *l = new QVBoxLayout(this);
std::list< ConfigEntry > entries = pos->second;
std::list< ConfigEntry >::iterator entrypos = entries.begin();
while(entrypos != entries.end()) {
QHBox *hbox = new QHBox(this);
mLayout->addWidget(hbox);
QLabel *label = new QLabel(hbox);
label->setText((*entrypos).name);
QLineEdit *edit = new QLineEdit(hbox);
edit->setText((*entrypos).value);
entrypos++;
}
pos++;
}
QButton *ok = new QButton(this);
ok->setText(QObject::tr("Ok"));
mLayout->addWidget(ok);
show();
}
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CONFIGURATION_PANEL_IMPL_HPP__
#define __CONFIGURATION_PANEL_IMPL_HPP__
#include <list>
#include <map>
#include <qlayout.h>
#include <qdialog.h>
struct ConfigEntry
{
public:
ConfigEntry(QString s,
QString n,
QString t,
QString d,
QString v)
{
section = s;
name = n;
type = t;
def = d;
value = v;
}
QString section;
QString name;
QString type;
QString def;
QString value;
};
class ConfigurationPanelImpl : public QDialog
{
Q_OBJECT
public:
ConfigurationPanelImpl(QWidget *parent = NULL);
public slots:
void add(const ConfigEntry &entry);
void generate();
private:
std::map< QString, std::list< ConfigEntry > > mEntries;
QVBoxLayout *mLayout;
};
#endif
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author : Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __DEBUGOUTPUT_HPP__
#define __DEBUGOUTPUT_HPP__
#include "utilspp/Singleton.hpp"
#include "DebugOutputImpl.hpp"
typedef utilspp::SingletonHolder< DebugOutputImpl > DebugOutput;
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment