Commit 88381436 authored by jpbl's avatar jpbl

added the newgui option for configure

parent e7a1ac34
......@@ -111,6 +111,22 @@ maintener="no"
AM_CONDITIONAL(MAINTENER_CODE, test x$maintener = xyes)
AC_MSG_CHECKING([whether to enable the new gui])
AC_ARG_ENABLE(newgui,
[ --enable-newgui Enable new gui code [default=no]],
[
AC_MSG_RESULT(yes)
newgui="yes"
],
[
AC_MSG_RESULT(no)
newgui="no"
]
)
AM_CONDITIONAL(NEWGUI_CODE, test x$newgui = xyes)
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])
......@@ -179,6 +195,7 @@ src/audio/pacpp/source/Makefile \
src/audio/pacpp/source/portaudiocpp/Makefile \
src/gui/Makefile \
src/gui/qt/Makefile \
src/gui/official/Makefile \
src/gui/server/Makefile \
src/zeroconf/Makefile \
utilspp/Makefile \
......
This diff is collapsed.
SUBDIRS = qt server
if NEWGUI_CODE
officialdir = official
endif
SUBDIRS = $(officialdir) qt server
noinst_LTLIBRARIES = libguiframework.la
......
......@@ -20,27 +20,38 @@
#include "account.h"
#include "requester.h"
#include "call.h"
Account::Account(const std::string &id)
: mId(id)
Account::Account(const std::string &sessionId,
const std::string &name)
: mSessionId(sessionId)
, mId(name)
{}
Call
Account::createCall()
Account::call(const std::string &to)
{
std::string callId = Requester::instance().generateCallId();
return Call(mSessionId, mAccountId, callId);
std::list< std::string > args;
args.push_back(mId);
args.push_back(to);
Requester::instance().send(mSessionId, "register", args);
return Call(mSessionId, callId);
}
std::string
Account::register()
Account::registerAccount()
{
return Requester::instance().sendAccountRequest(mSessionId, mId, "register");
std::list< std::string > args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "register", args);
}
std::string
Account::unregister()
Account::unregisterAccount()
{
return Requester::instance().sendAccountRequest(mSessionId, mId, "unregister");
std::list< std::string > args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "unregister", args);
}
......@@ -27,14 +27,19 @@ class Call;
class Account {
public:
Account(const std::string &sessionId,
const std::string &name);
/**
* This will generate a call ready to be used.
*/
Call call(const std::string &to);
std::string register();
std::string unregister();
std::string registerAccount();
std::string unregisterAccount();
private:
Account();
/**
* This is the session id that we are related to.
*/
......
......@@ -18,59 +18,75 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <string>
#include <list>
#include "call.h"
#include "requester.h"
std::string
Call::call(const std::string &destination)
{
std::list< std::string> args;
args.push_back(mAccountId);
args.push_back(to);
return Requester::instance().sendCallCommand(mSession, mId, "answer", args)
}
Call::Call(const std::string &sessionId,
const std::string &callId)
: mSessionId(sessionId)
, mId(callId)
{}
std::string
Call::answer()
{
return Requester::instance().sendCallCommand(mSession, mId, "answer")
std::list< std::string> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "answer", args);
}
std::string
Call::hangup()
{
return Requester::instance().sendCallCommand(mSession, mId, "hangup")
std::list< std::string> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "hangup", args);
}
std::string
Call::cancel()
{
return Requester::instance().sendCallCommand(mSession, mId, "cancel")
std::list< std::string> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "cancel", args);
}
std::string
Call::hold()
{
return Requester::instance().sendCallCommand(mSession, mId, "hold")
std::list< std::string> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "hold", args);
}
std::string
Call::unhold()
{
return Requester::instance().sendCallCommand(mSession, mId, "unhold")
std::list< std::string> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "unhold", args);
}
std::string
Call::refuse()
{
return Requester::instance().sendCallCommand(mSession, mId, "refuse")
std::list< std::string> args;
args.push_back(mId);
return Requester::instance().send(mSessionId, "refuse", args);
}
std::string
Call::sendDtmf(char c)
{
std::list< std::string > args;
args.push_back(std::string(c));
return Requester::instance().sendCallCommand(mSession, mId, "senddtmf", args)
std::list< std::string> args;
args.push_back(mId);
std::string s;
s += c;
args.push_back(s);
return Requester::instance().send(mSessionId, "senddtmf", args);
}
......@@ -27,15 +27,8 @@ class Call
{
public:
Call(const std::string &sessionId,
const std::string &accountId,
const std::string &callId);
/**
* This function will try to call the destination.
*
*/
std::string call(const std::string &destination);
/**
* This function will answer the call.
*/
......@@ -80,20 +73,15 @@ class Call
private:
/**
* This is the unique identifier of the call.
*/
std::string mId;
/**
* This is the session id that we belong to.
*/
std::string mSessionId;
/**
* This is the account id that we belong to.
* This is the unique identifier of the call.
*/
std::string mAccountId;
std::string mId;
};
#endif
......@@ -22,10 +22,10 @@
#define SFLPHONEGUI_OBJECTPOOL_H
#include <string>
#include <QMutex>
#include <QWaitCondition>
#include <qmutex.h>
#include <qwaitcondition.h>
template< T >
template< typename T >
class ObjectPool
{
public:
......
......@@ -18,7 +18,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sstream>
#include "request.h"
#include "requester.h"
Request::Request(const std::string &sequenceId,
const std::string &command,
......@@ -29,19 +32,19 @@ Request::Request(const std::string &sequenceId,
{}
void
Request::onError(int code, const std::string &message)
Request::onError(const std::string &, const std::string &)
{}
void
Request::onSuccess(int code, const std::string &message)
Request::onSuccess(const std::string &, const std::string &)
{}
std::string
Request::toString()
{
std::ostream id;
std::ostringstream id;
id << mCommand << mSequenceId;
for(std::list< std::string >::iterator pos = mArgs.begin();
for(std::list< std::string >::const_iterator pos = mArgs.begin();
pos != mArgs.end();
pos++) {
id << " " << (*pos);
......@@ -52,30 +55,35 @@ Request::toString()
CallRequest::CallRequest(const std::string &sequenceId,
const std::string &callId,
const std::string &command,
const std::list< std::string > &args)
: Request(sequenceId, command, args)
, mCallId(callId)
, mCallId(*args.begin())
{}
void
CallRequest::onError(int code, const std::string &message)
CallRequest::onError(const std::string &code, const std::string &message)
{
onError(Call(mCallId), code, message);
onError(Call(Requester::instance().getSessionIdFromSequenceId(getSequenceId()),
mCallId),
code,
message);
}
void
CallRequest::onError(Call call, int code, const std::string &message)
CallRequest::onError(Call , const std::string &, const std::string &)
{}
void
CallRequest::onSuccess(int code, const std::string &message)
CallRequest::onSuccess(const std::string &code, const std::string &message)
{
onSuccess(Call(mCallId), code, message);
onSuccess(Call(Requester::instance().getSessionIdFromSequenceId(getSequenceId()),
mCallId),
code,
message);
}
void
CallRequest::onSuccess(Call call, int code, const std::string &message)
CallRequest::onSuccess(Call, const std::string &, const std::string &)
{}
......@@ -21,6 +21,11 @@
#ifndef SFLPHONEGUI_REQUEST_H
#define SFLPHONEGUI_REQUEST_H
#include <list>
#include <string>
#include "call.h"
class Request
{
public:
......@@ -33,14 +38,20 @@ class Request
* receive its answer, if the request didn't successfully
* ended.
*/
virtual void onError(int code, const std::string &message);
virtual void onError(const std::string &code, const std::string &message);
/**
* This function will be called when the request
* receive an answer, but there's other answers to come.
*/
virtual void onEntry(const std::string &code, const std::string &message);
/**
* This function will be called when the request
* receive its answer, if the request successfully
* ended.
*/
virtual void onSuccess(int code, const std::string &message);
virtual void onSuccess(const std::string &code, const std::string &message);
/**
* This function will translate the function into a string.
......@@ -51,7 +62,7 @@ class Request
/**
* Return the sequence ID.
*/
std::string getSequenceID()
std::string getSequenceId()
{return mSequenceId;}
/**
......@@ -63,21 +74,21 @@ class Request
/**
* Return the args.
*/
std::string getArgs()
std::list< std::string > getArgs()
{return mArgs;}
private:
const std::string mSequenceId;
const std::string mSessionId;
const std::string mCommand;
const std::list< std::string > mArgs;
}
};
class CallRequest : public Request
{
public:
CallRequest(const std::string &sequenceId,
const std::string &callId,
const std::string &command,
const std::list< std::string > &args);
......@@ -87,14 +98,26 @@ class CallRequest : public Request
* receive its answer, if the request didn't successfully
* ended.
*/
virtual void onError(Call call, int code, const std::string &message);
virtual void onError(Call call,
const std::string &code,
const std::string &message);
/**
* This function will be called when the request
* receive an answer, but there's other answers to come.
*/
virtual void onEntry(Call call,
const std::string &code,
const std::string &message);
/**
* This function will be called when the request
* receive its answer, if the request successfully
* ended.
*/
virtual void onSuccess(Call call, const std::string &message);
virtual void onSuccess(Call call,
const std::string &code,
const std::string &message);
private:
/**
......@@ -103,7 +126,8 @@ class CallRequest : public Request
* ended. This function will call the onError, but with
* the call linked to this request.
*/
virtual void onError(int code, const std::string &message);
virtual void onError(const std::string &code,
const std::string &message);
/**
* This function will be called when the request
......@@ -111,11 +135,12 @@ class CallRequest : public Request
* ended. This function will call the onSuccess function,
* but with the call linked to this request.
*/
virtual void onSuccess(int code, const std::string &message);
virtual void onSuccess(const std::string &code,
const std::string &message);
private:
const std::string mCallId;
}
};
#endif
......@@ -29,10 +29,10 @@ RequesterImpl::RequesterImpl()
, mSequenceIdCount(0)
{}
SessionImpl *
getSessionImpl(const std::string &sessionId)
SessionIO *
RequesterImpl::getSessionIO(const std::string &sessionId)
{
std::map< std::string, SessionImpl * >::iterator pos = mSessions.find(sessionId);
std::map< std::string, SessionIO * >::iterator pos = mSessions.find(sessionId);
if(pos == mSessions.end()) {
throw std::runtime_error("The session is not valid.");
}
......@@ -41,17 +41,17 @@ getSessionImpl(const std::string &sessionId)
}
std::string
RequesterImpl::sendCallCommand(const std::string &sessionId,
const std::string &callId,
const std::string &command)
RequesterImpl::send(const std::string &sessionId,
const std::string &command,
const std::list< std::string > &args)
{
// We retreive the internal of a session.
SessionIO *session = getSessionIO(sessionId);
// We ask the factory to create the request.
Request *request = mCallRequestFactory.create(command, sequenceId, callId)
std::string sequenceId = generateSequenceId();
Request *request = mRequestFactory.create(command, sequenceId, args);
registerRequest(sessionId, sequenceId, request);
s->send(request.toString());
......@@ -68,6 +68,20 @@ RequesterImpl::registerRequest(const std::string &sessionId,
}
mRequests.insert(std::make_pair(sequenceId, request));
mSequenceToSession.insert(std::make_pair(sequenceId, sessionId));
}
void
RequesterImpl::registerSession(const std::string &id,
SessionIO *s)
{
if(mSessions.find(id) != mSessions.end()) {
throw std::logic_error("Registering an already know Session ID");
}
mSessions.insert(std::make_pair(id, s));
s->start();
}
void
......
......@@ -21,6 +21,9 @@
#ifndef SFLPHONEGUI_REQUESTERIMPL_H
#define SFLPHONEGUI_REQUESTERIMPL_H
#include "request.h"
#include "objectfactory.h"
class Call;
class SessionIO;
......@@ -34,26 +37,17 @@ class RequesterImpl
* This command is non-blocking. The command linked
* to this command will be executed.
*/
void sendCallCommand(const std::string &sessionId,
const std::string &callId,
const std::string &command);
void sendCallCommand(const std::string &sessionId,
const std::string &callId,
char *command);
std::string send(const std::string &sessionId,
const std::string &command,
const std::list< std::string > &args);
static int getCodeCategory(const std::string &code);
private:
/**
* Generate a unique call ID.
*/
std::string generateCallId();
/**
* Generate a unique account ID.
*/
std::string generateAccountId();
/**
* Generate a unique session ID.
*/
......@@ -65,49 +59,50 @@ class RequesterImpl
std::string generateSequenceId();
/**
* Return the SessionIO instance related to
* the session ID.
* Register the string to return a Actual type.
*/
SessionIO *getSessionIO(const std::string &sessionId);
private:
std::map< std::string, SessionIO * > mSessions;
std::map< std::string, Request * > mRequests;
template< typename Actual >
void registerObject(const std::string &name);
std::string getSessionIdFromSequenceId(const std::string &sequence)
{return mSequenceToSession[sequence];}
/**
* This map is used to map accounts ids to session ids.
*/
std::map< std::string, std::string > mAccountToSessionMap;
private:
/**
* This map is used to map call ids to session ids.
* Return the SessionIO instance related to
* the session ID.
*/
std::map< std::string, std::string > mCallToSessionMap;
SessionIO *getSessionIO(const std::string &sessionId);
/**
* This is the list of all accounts in each session.
* Register the session.
*/
std::map< std::string, std::list< std::string > > mSessionAccounts;
void registerSession(const std::string &id, SessionIO *io);
/**
* This is the list of all calls ids in each accounts.
* Register the string to return a Actual type.
*/
std::map< std::string, std::list< std::string > > mAccountCalls;
void registerRequest(const std::string &sessionId,
const std::string &sequenceId,
Request *request);
/**
* Those maps are used to create a request from a request
* string.
*/
std::map< std::string, * CallRequestCreator > mCallCommandCreators;
std::map< std::string, * AccountRequestCreator > mAccountRequestCreators;
std::map< std::string, * SessionRequestCreator > mSessionRequestCreators;
std::map< std::string, * SessionListRequestCreator > mSessionListRequestCreators;
private:
ObjectFactory< Request > mRequestFactory;
std::map< std::string, SessionIO * > mSessions;
std::map< std::string, Request * > mRequests;
std::map< std::string, std::string > mSequenceToSession;
/**
* This is the integer used to generate the call IDs.
*/
unsigned long mCallIdCount;
}
unsigned long mSessionIdCount;
unsigned long mSequenceIdCount;
};
#include "requesterimpl.inl"
#endif
......@@ -57,7 +57,7 @@ SessionIO::~SessionIO()
}
void
SessionIO::run()
SessionIO::start()
{