Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from tswindell/commhistory
Commhistory implementation.
- Loading branch information
Showing
9 changed files
with
397 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
TEMPLATE = subdirs | ||
SUBDIRS = src | ||
|
||
OTHER_FILES += LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/* | ||
* This file is a part of the Voice Call Manager Plugin project. | ||
* | ||
* Copyright (C) 2011-2015 Jolla Ltd | ||
* Contact: Tom Swindell <tom.swindell@jollamobile.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
#include "common.h" | ||
#include "calleventhandler.h" | ||
|
||
#include <abstractvoicecallprovider.h> | ||
|
||
#include <CommHistory/Event> | ||
#include <notification.h> | ||
|
||
struct CallEventHandlerPrivate | ||
{ | ||
CallEventHandlerPrivate(AbstractVoiceCallHandler *pTarget, CommHistoryPlugin *pParent) | ||
: target(pTarget), | ||
parent(pParent), | ||
started(false), | ||
created(false) | ||
{/*...*/} | ||
|
||
AbstractVoiceCallHandler *target; | ||
CommHistoryPlugin *parent; | ||
CommHistory::Event event; | ||
|
||
bool started; | ||
bool created; | ||
}; | ||
|
||
CallEventHandler::CallEventHandler(AbstractVoiceCallHandler *target, CommHistoryPlugin *parent) | ||
: QObject(parent), d_ptr(new CallEventHandlerPrivate(target, parent)) | ||
{ | ||
TRACE | ||
Q_D(CallEventHandler); | ||
|
||
QObject::connect(parent->eventModel(), SIGNAL(eventsCommitted(QList<CommHistory::Event>, bool)), | ||
this, SLOT(onEventsCommitted(QList<CommHistory::Event>, bool))); | ||
|
||
d->event.setType(CommHistory::Event::CallEvent); | ||
d->event.setStartTime(QDateTime::currentDateTime()); | ||
d->event.setEndTime(d->event.startTime()); | ||
d->event.setLocalUid(target->provider()->providerId()); | ||
d->event.setRecipients(CommHistory::Recipient(d->event.localUid(), target->lineId().replace(QRegExp("^sip:"), ""))); | ||
d->event.setDirection(target->isIncoming() ? CommHistory::Event::Inbound : CommHistory::Event::Outbound); | ||
d->event.setIsVideoCall(false); | ||
d->event.setIsEmergencyCall(target->isEmergency()); | ||
|
||
pushEvent(); | ||
|
||
QObject::connect(target, &AbstractVoiceCallHandler::statusChanged, this, &CallEventHandler::onCallStatusChanged); | ||
QObject::connect(target, SIGNAL(destroyed()), this, SLOT(deleteLater())); | ||
} | ||
|
||
CallEventHandler::~CallEventHandler() | ||
{ | ||
TRACE | ||
} | ||
|
||
void CallEventHandler::pushEvent() | ||
{ | ||
TRACE | ||
Q_D(CallEventHandler); | ||
|
||
if(d->created) { | ||
d->parent->eventModel()->modifyEvent(d->event); | ||
} else { | ||
d->created = d->parent->eventModel()->addEvent(d->event); | ||
} | ||
|
||
if(!d->created) WARNING_T("Failed to push event!"); | ||
} | ||
|
||
void CallEventHandler::onEventsCommitted(const QList<CommHistory::Event> &events, bool success) | ||
{ | ||
TRACE | ||
Q_UNUSED(events) | ||
|
||
if(!success) | ||
{ | ||
DEBUG_T("Failed to commit events!"); | ||
} | ||
} | ||
|
||
void CallEventHandler::onCallStatusChanged(AbstractVoiceCallHandler::VoiceCallStatus status) | ||
{ | ||
TRACE | ||
Q_D(CallEventHandler); | ||
bool modified = false; | ||
|
||
switch(status) { | ||
case AbstractVoiceCallHandler::STATUS_ACTIVE: | ||
d->started = true; | ||
|
||
d->event.setStartTime(d->target->startedAt()); | ||
d->event.setEndTime(d->event.startTime()); | ||
|
||
modified = true; | ||
break; | ||
|
||
case AbstractVoiceCallHandler::STATUS_INCOMING: | ||
d->event.setDirection(CommHistory::Event::Inbound); | ||
modified = true; | ||
break; | ||
|
||
case AbstractVoiceCallHandler::STATUS_NULL: | ||
case AbstractVoiceCallHandler::STATUS_DISCONNECTED: | ||
d->event.setEndTime(d->target->startedAt().addSecs(d->target->duration())); | ||
|
||
//TODO: We really need a "rejected()" signal so we can not display notifications | ||
// for rejected calls? | ||
if(!d->started) d->event.setIsMissedCall(true); | ||
|
||
modified = true; | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
|
||
if(modified) pushEvent(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is a part of the Voice Call Manager Plugin project. | ||
* | ||
* Copyright (C) 2011-2015 Jolla Ltd | ||
* Contact: Tom Swindell <tom.swindell@jollamobile.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
#ifndef CALLEVENTHANDLER_H | ||
#define CALLEVENTHANDLER_H | ||
|
||
#include <QObject> | ||
|
||
#include <abstractvoicecallhandler.h> | ||
#include "commhistoryplugin.h" | ||
|
||
namespace CommHistory { | ||
class Event; | ||
} | ||
|
||
class CallEventHandler : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit CallEventHandler(AbstractVoiceCallHandler *target, CommHistoryPlugin *parent); | ||
~CallEventHandler(); | ||
|
||
protected Q_SLOTS: | ||
void onCallStatusChanged(AbstractVoiceCallHandler::VoiceCallStatus status); | ||
void onEventsCommitted(const QList<CommHistory::Event> &events, bool success); | ||
|
||
protected: | ||
void pushEvent(); | ||
|
||
private: | ||
class CallEventHandlerPrivate *d_ptr; | ||
|
||
Q_DECLARE_PRIVATE(CallEventHandler) | ||
}; | ||
|
||
#endif // CALLEVENTHANDLER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
/* | ||
* This file is a part of the Voice Call Manager Plugin project. | ||
* | ||
* Copyright (C) 2011-2015 Jolla Ltd | ||
* Contact: Tom Swindell <tom.swindell@jollamobile.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
#include "common.h" | ||
#include "commhistoryplugin.h" | ||
|
||
#include "calleventhandler.h" | ||
|
||
#include <voicecallmanagerinterface.h> | ||
|
||
class CommHistoryPluginPrivate | ||
{ | ||
Q_DECLARE_PUBLIC(CommHistoryPlugin) | ||
|
||
public: | ||
CommHistoryPluginPrivate(CommHistoryPlugin *q) | ||
: q_ptr(q), manager(NULL), model(NULL) | ||
{ /* ... */ } | ||
|
||
CommHistoryPlugin *q_ptr; | ||
VoiceCallManagerInterface *manager; | ||
|
||
CommHistory::EventModel *model; | ||
}; | ||
|
||
CommHistoryPlugin::CommHistoryPlugin(QObject *parent) | ||
: AbstractVoiceCallManagerPlugin(parent), d_ptr(new CommHistoryPluginPrivate(this)) | ||
{ | ||
TRACE | ||
Q_D(CommHistoryPlugin); | ||
d->model = new CommHistory::EventModel(this); | ||
} | ||
|
||
CommHistoryPlugin::~CommHistoryPlugin() | ||
{ | ||
TRACE | ||
delete this->d_ptr; | ||
} | ||
|
||
QString CommHistoryPlugin::pluginId() const | ||
{ | ||
TRACE | ||
return PLUGIN_NAME; | ||
} | ||
|
||
bool CommHistoryPlugin::initialize() | ||
{ | ||
TRACE | ||
return true; | ||
} | ||
|
||
bool CommHistoryPlugin::configure(VoiceCallManagerInterface *manager) | ||
{ | ||
TRACE | ||
Q_D(CommHistoryPlugin); | ||
d->manager = manager; | ||
return true; | ||
} | ||
|
||
bool CommHistoryPlugin::start() | ||
{ | ||
TRACE | ||
Q_D(const CommHistoryPlugin); | ||
return QObject::connect(d->manager, | ||
SIGNAL(voiceCallAdded(AbstractVoiceCallHandler*)), | ||
this, | ||
SLOT(onVoiceCallAdded(AbstractVoiceCallHandler*))); | ||
} | ||
|
||
bool CommHistoryPlugin::suspend() | ||
{ | ||
TRACE | ||
return true; | ||
} | ||
|
||
bool CommHistoryPlugin::resume() | ||
{ | ||
TRACE | ||
return true; | ||
} | ||
|
||
void CommHistoryPlugin::finalize() | ||
{ | ||
TRACE | ||
} | ||
|
||
CommHistory::EventModel* CommHistoryPlugin::eventModel() | ||
{ | ||
TRACE | ||
Q_D(CommHistoryPlugin); | ||
return d->model; | ||
} | ||
|
||
void CommHistoryPlugin::onVoiceCallAdded(AbstractVoiceCallHandler *handler) | ||
{ | ||
TRACE | ||
new CallEventHandler(handler, this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is a part of the Voice Call Manager Plugin project. | ||
* | ||
* Copyright (C) 2011-2015 Jolla Ltd | ||
* Contact: Tom Swindell <tom.swindell@jollamobile.com> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library 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 | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
*/ | ||
#ifndef COMMHISTORYPLUGIN_H | ||
#define COMMHISTORYPLUGIN_H | ||
|
||
#include <CommHistory/EventModel> | ||
|
||
#include <abstractvoicecallmanagerplugin.h> | ||
#include <abstractvoicecallhandler.h> | ||
|
||
class CommHistoryPlugin : public AbstractVoiceCallManagerPlugin | ||
{ | ||
Q_OBJECT | ||
|
||
Q_PLUGIN_METADATA(IID "org.nemomobile.voicecall.commhistory") | ||
Q_INTERFACES(AbstractVoiceCallManagerPlugin) | ||
|
||
public: | ||
explicit CommHistoryPlugin(QObject *parent = 0); | ||
~CommHistoryPlugin(); | ||
|
||
QString pluginId() const; | ||
|
||
CommHistory::EventModel* eventModel(); | ||
|
||
public Q_SLOTS: | ||
bool initialize(); | ||
bool configure(VoiceCallManagerInterface *manager); | ||
bool start(); | ||
bool suspend(); | ||
bool resume(); | ||
void finalize(); | ||
|
||
protected Q_SLOTS: | ||
void onVoiceCallAdded(AbstractVoiceCallHandler *handler); | ||
|
||
private: | ||
class CommHistoryPluginPrivate *d_ptr; | ||
|
||
Q_DECLARE_PRIVATE(CommHistoryPlugin) | ||
}; | ||
|
||
#endif // COMMHISTORYPLUGIN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
include(../../plugin.pri) | ||
QT += contacts dbus | ||
TARGET = voicecall-commhistory-plugin | ||
|
||
PKGCONFIG += qtcontacts-sqlite-qt5-extensions contactcache-qt5 commhistory-qt5 nemonotifications-qt5 | ||
|
||
DEFINES += PLUGIN_NAME=\\\"commhistory-plugin\\\" | ||
|
||
#DEFINES += WANT_TRACE | ||
|
||
HEADERS += \ | ||
commhistoryplugin.h \ | ||
calleventhandler.h | ||
|
||
SOURCES += \ | ||
commhistoryplugin.cpp \ | ||
calleventhandler.cpp |
Oops, something went wrong.