Commit 2e264c52 authored by jpbl's avatar jpbl

we have default events

parent 466d7b11
......@@ -14,7 +14,7 @@ Event::Event(const QString &code,
void
Event::execute()
{
_debug("Received: %s\n", toString().toStdString().c_str());
_debug("Event: Received: %s\n", toString().toStdString().c_str());
}
QString
......@@ -24,6 +24,7 @@ Event::toString()
for(std::list< QString >::iterator pos = mArgs.begin();
pos != mArgs.end();
pos++) {
output += " ";
output += *pos;
}
......
......@@ -66,6 +66,8 @@ template< typename Base >
class EventFactoryImpl
{
public:
EventFactoryImpl();
/**
* Ask for a new object linked to the string.
*/
......@@ -76,10 +78,14 @@ public:
* Register the string to return a Actual type.
*/
template< typename Actual >
void registerEvent(const QString &code);
void registerEvent(const QString &code);
template< typename Actual >
void registerDefaultEvent();
private:
std::map< QString, EventCreatorBase< Base > * > mEventCreators;
EventCreatorBase< Base > *mDefaultCreator;
};
#include "EventFactory.inl"
......
......@@ -40,6 +40,11 @@ EventCreator< Base, Actual >::clone()
return new EventCreator< Base, Actual >();
}
template< typename Base >
EventFactoryImpl< Base >::EventFactoryImpl()
: mDefaultCreator(NULL)
{}
template< typename Base >
Base *
EventFactoryImpl< Base >::create(const QString &code,
......@@ -47,7 +52,14 @@ EventFactoryImpl< Base >::create(const QString &code,
{
typename std::map< QString, EventCreatorBase< Base > * >::iterator pos = mEventCreators.find(code);
if(pos == mEventCreators.end()) {
_debug("The code %s has no creator registered.", code.toStdString().c_str());
if(mDefaultCreator) {
return mDefaultCreator->create(code, args);
}
else{
throw std::logic_error(QString("The code %s has no creator registered "
"and there's no default creator"
).arg(code).toStdString().c_str());
}
}
return pos->second->create(code, args);
......@@ -65,6 +77,18 @@ EventFactoryImpl< Base >::registerEvent(const QString &code)
mEventCreators[code] = new EventCreator< Base, Actual >();
}
template< typename Base >
template< typename Actual >
void
EventFactoryImpl< Base >::registerDefaultEvent()
{
if(mDefaultCreator) {
delete mDefaultCreator;
}
mDefaultCreator = new EventCreator< Base, Actual >();
}
#endif
......@@ -17,6 +17,7 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
, mCurrentLine(NULL)
, mIsInitialized(false)
{
EventFactory::instance().registerDefaultEvent< DefaultEvent >();
// TODO: 000
EventFactory::instance().registerEvent< CallRelatedEvent >("000");
EventFactory::instance().registerEvent< IncommingEvent >("001");
......
......@@ -94,21 +94,18 @@ public slots:
void hangup();
/**
* This function will mute the current line if muting
* This function will mute the microphone if muting
* is true, it will unmute otherwise.
* If there's no current line, it will do nothing.
*/
void mute(bool);
/**
* This function will mute the current line
* If there's no current line, it will do nothing.
* This function will mute the microphone
*/
void mute();
/**
* This function will unmute the current line
* If there's no current line, it will do nothing.
* This function will unmute the microphone
*/
void unmute();
......
......@@ -133,7 +133,7 @@ RequesterImpl::receiveAnswer(const QString &code,
std::map< QString, Request * >::iterator pos;
pos = mRequests.find(sequence);
if(pos == mRequests.end()) {
std::cerr << "We received an answer with an unknown sequence" << std::endl;
_debug("Requester: We received an answer with an unknown sequence.\n");
return;
}
......@@ -189,7 +189,8 @@ RequesterImpl::inputIsDown(const QString &sessionId)
if(pos == mSessions.end()) {
// we will not thow an exception, but this is
// a logic error
_debug("SessionIO input for session %s is down, but we don't have that session.\n",
_debug("Requester: SessionIO input for session %s is down, "
"but we don't have that session.\n",
sessionId.toStdString().c_str());
}
}
......@@ -3,6 +3,19 @@
#include "PhoneLineManager.hpp"
#include "SFLEvents.hpp"
DefaultEvent::DefaultEvent(const QString &code,
const std::list< QString > &args)
: Event(code, args)
{
}
void
DefaultEvent::execute()
{
_debug("DefaultEvent: We don't handle: %s\n", toString().toStdString().c_str());
}
HangupEvent::HangupEvent(const QString &code,
const std::list< QString > &args)
: CallRelatedEvent(code, args)
......
......@@ -23,6 +23,15 @@
#include "Event.hpp"
class DefaultEvent : public Event
{
public:
DefaultEvent(const QString &code,
const std::list< QString > &args);
virtual void execute();
};
class HangupEvent : public CallRelatedEvent
{
public:
......
......@@ -127,7 +127,7 @@ void SFLPhoneWindow::initWindowButtons()
mMain);
QObject::connect(mMinimizeButton, SIGNAL(clicked()),
this, SLOT(lower()));
mMinimizeButton->move(354,5);
mMinimizeButton->move(353,5);
}
void
......
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
* 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
......
src/gui/official/images/close_off.png

778 Bytes | W: | H:

src/gui/official/images/close_off.png

785 Bytes | W: | H:

src/gui/official/images/close_off.png
src/gui/official/images/close_off.png
src/gui/official/images/close_off.png
src/gui/official/images/close_off.png
  • 2-up
  • Swipe
  • Onion skin
src/gui/official/images/close_on.png

806 Bytes | W: | H:

src/gui/official/images/close_on.png

812 Bytes | W: | H:

src/gui/official/images/close_on.png
src/gui/official/images/close_on.png
src/gui/official/images/close_on.png
src/gui/official/images/close_on.png
  • 2-up
  • Swipe
  • Onion skin
src/gui/official/images/main.png

34 KB | W: | H:

src/gui/official/images/main.png

32.7 KB | W: | H:

src/gui/official/images/main.png
src/gui/official/images/main.png
src/gui/official/images/main.png
src/gui/official/images/main.png
  • 2-up
  • Swipe
  • Onion skin
src/gui/official/images/minimize_off.png

765 Bytes | W: | H:

src/gui/official/images/minimize_off.png

768 Bytes | W: | H:

src/gui/official/images/minimize_off.png
src/gui/official/images/minimize_off.png
src/gui/official/images/minimize_off.png
src/gui/official/images/minimize_off.png
  • 2-up
  • Swipe
  • Onion skin
src/gui/official/images/minimize_on.png

749 Bytes | W: | H:

src/gui/official/images/minimize_on.png

761 Bytes | W: | H:

src/gui/official/images/minimize_on.png
src/gui/official/images/minimize_on.png
src/gui/official/images/minimize_on.png
src/gui/official/images/minimize_on.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
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