Skip to content
Snippets Groups Projects
Commit 2e264c52 authored by jpbl's avatar jpbl
Browse files

we have default events

parent 466d7b11
Branches
Tags
No related merge requests found
Showing
with 66 additions and 13 deletions
...@@ -14,7 +14,7 @@ Event::Event(const QString &code, ...@@ -14,7 +14,7 @@ Event::Event(const QString &code,
void void
Event::execute() Event::execute()
{ {
_debug("Received: %s\n", toString().toStdString().c_str()); _debug("Event: Received: %s\n", toString().toStdString().c_str());
} }
QString QString
...@@ -24,6 +24,7 @@ Event::toString() ...@@ -24,6 +24,7 @@ Event::toString()
for(std::list< QString >::iterator pos = mArgs.begin(); for(std::list< QString >::iterator pos = mArgs.begin();
pos != mArgs.end(); pos != mArgs.end();
pos++) { pos++) {
output += " ";
output += *pos; output += *pos;
} }
......
...@@ -66,6 +66,8 @@ template< typename Base > ...@@ -66,6 +66,8 @@ template< typename Base >
class EventFactoryImpl class EventFactoryImpl
{ {
public: public:
EventFactoryImpl();
/** /**
* Ask for a new object linked to the string. * Ask for a new object linked to the string.
*/ */
...@@ -78,8 +80,12 @@ public: ...@@ -78,8 +80,12 @@ public:
template< typename Actual > template< typename Actual >
void registerEvent(const QString &code); void registerEvent(const QString &code);
template< typename Actual >
void registerDefaultEvent();
private: private:
std::map< QString, EventCreatorBase< Base > * > mEventCreators; std::map< QString, EventCreatorBase< Base > * > mEventCreators;
EventCreatorBase< Base > *mDefaultCreator;
}; };
#include "EventFactory.inl" #include "EventFactory.inl"
......
...@@ -40,6 +40,11 @@ EventCreator< Base, Actual >::clone() ...@@ -40,6 +40,11 @@ EventCreator< Base, Actual >::clone()
return new EventCreator< Base, Actual >(); return new EventCreator< Base, Actual >();
} }
template< typename Base >
EventFactoryImpl< Base >::EventFactoryImpl()
: mDefaultCreator(NULL)
{}
template< typename Base > template< typename Base >
Base * Base *
EventFactoryImpl< Base >::create(const QString &code, EventFactoryImpl< Base >::create(const QString &code,
...@@ -47,7 +52,14 @@ 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); typename std::map< QString, EventCreatorBase< Base > * >::iterator pos = mEventCreators.find(code);
if(pos == mEventCreators.end()) { 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); return pos->second->create(code, args);
...@@ -65,6 +77,18 @@ EventFactoryImpl< Base >::registerEvent(const QString &code) ...@@ -65,6 +77,18 @@ EventFactoryImpl< Base >::registerEvent(const QString &code)
mEventCreators[code] = new EventCreator< Base, Actual >(); 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 #endif
...@@ -17,6 +17,7 @@ PhoneLineManagerImpl::PhoneLineManagerImpl() ...@@ -17,6 +17,7 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
, mCurrentLine(NULL) , mCurrentLine(NULL)
, mIsInitialized(false) , mIsInitialized(false)
{ {
EventFactory::instance().registerDefaultEvent< DefaultEvent >();
// TODO: 000 // TODO: 000
EventFactory::instance().registerEvent< CallRelatedEvent >("000"); EventFactory::instance().registerEvent< CallRelatedEvent >("000");
EventFactory::instance().registerEvent< IncommingEvent >("001"); EventFactory::instance().registerEvent< IncommingEvent >("001");
......
...@@ -94,21 +94,18 @@ public slots: ...@@ -94,21 +94,18 @@ public slots:
void hangup(); 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. * is true, it will unmute otherwise.
* If there's no current line, it will do nothing.
*/ */
void mute(bool); void mute(bool);
/** /**
* This function will mute the current line * This function will mute the microphone
* If there's no current line, it will do nothing.
*/ */
void mute(); void mute();
/** /**
* This function will unmute the current line * This function will unmute the microphone
* If there's no current line, it will do nothing.
*/ */
void unmute(); void unmute();
......
...@@ -133,7 +133,7 @@ RequesterImpl::receiveAnswer(const QString &code, ...@@ -133,7 +133,7 @@ RequesterImpl::receiveAnswer(const QString &code,
std::map< QString, Request * >::iterator pos; std::map< QString, Request * >::iterator pos;
pos = mRequests.find(sequence); pos = mRequests.find(sequence);
if(pos == mRequests.end()) { 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; return;
} }
...@@ -189,7 +189,8 @@ RequesterImpl::inputIsDown(const QString &sessionId) ...@@ -189,7 +189,8 @@ RequesterImpl::inputIsDown(const QString &sessionId)
if(pos == mSessions.end()) { if(pos == mSessions.end()) {
// we will not thow an exception, but this is // we will not thow an exception, but this is
// a logic error // 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()); sessionId.toStdString().c_str());
} }
} }
...@@ -3,6 +3,19 @@ ...@@ -3,6 +3,19 @@
#include "PhoneLineManager.hpp" #include "PhoneLineManager.hpp"
#include "SFLEvents.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, HangupEvent::HangupEvent(const QString &code,
const std::list< QString > &args) const std::list< QString > &args)
: CallRelatedEvent(code, args) : CallRelatedEvent(code, args)
......
...@@ -23,6 +23,15 @@ ...@@ -23,6 +23,15 @@
#include "Event.hpp" #include "Event.hpp"
class DefaultEvent : public Event
{
public:
DefaultEvent(const QString &code,
const std::list< QString > &args);
virtual void execute();
};
class HangupEvent : public CallRelatedEvent class HangupEvent : public CallRelatedEvent
{ {
public: public:
......
...@@ -127,7 +127,7 @@ void SFLPhoneWindow::initWindowButtons() ...@@ -127,7 +127,7 @@ void SFLPhoneWindow::initWindowButtons()
mMain); mMain);
QObject::connect(mMinimizeButton, SIGNAL(clicked()), QObject::connect(mMinimizeButton, SIGNAL(clicked()),
this, SLOT(lower())); this, SLOT(lower()));
mMinimizeButton->move(354,5); mMinimizeButton->move(353,5);
} }
void void
......
/** /**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc. * 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 * 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 * it under the terms of the GNU General Public License as published by
......
src/gui/official/images/close_off.png

778 B | W: | H:

src/gui/official/images/close_off.png

785 B | 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 B | W: | H:

src/gui/official/images/close_on.png

812 B | 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 KiB | W: | H:

src/gui/official/images/main.png

32.7 KiB | 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 B | W: | H:

src/gui/official/images/minimize_off.png

768 B | 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 B | W: | H:

src/gui/official/images/minimize_on.png

761 B | 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment