Commit 0c57c0f6 authored by Emmanuel Lepage's avatar Emmanuel Lepage

Merge branch 'sflphone-client-0.9.14_refactoring'

parents 416fee0b e98d90ad
......@@ -1108,6 +1108,7 @@ void ManagerImpl::removeParticipant (const std::string& call_id)
removeStream(call_id);
getMainBuffer()->stateInfo();
_dbus.getCallManager()->conferenceChanged (conf->getConfID(), conf->getStateStr());
}
void ManagerImpl::processRemainingParticipant (const std::string &current_call_id, Conference *conf)
......
......@@ -30,6 +30,7 @@
<Action name="action_displayVolumeControls" />
<Action name="action_displayDialpad" />
<Separator />
<Action name="action_configureShortcut" />
<Action name="action_configureSflPhone" />
<Separator />
<Action name="action_accountCreationWizard" />
......
......@@ -10,49 +10,34 @@
#include "../../src/lib/sflphone_const.h"
SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args)
: Plasma::DataEngine(parent, args), CallModelConvenience(ActiveCall)
: Plasma::DataEngine(parent, args)
{
Q_UNUSED(args)
initCall();
initHistory();
m_pModel = new CallModelConvenience(CallModelConvenience::ActiveCall);
m_pModel->initCall();
m_pModel->initHistory();
ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
connect(&callManager, SIGNAL(callStateChanged(const QString&, const QString&)),
this, SLOT(callStateChangedSignal(const QString&, const QString&)));
connect(&callManager, SIGNAL(incomingCall(const QString&, const QString&, const QString&)),
this, SLOT(incomingCallSignal(const QString&, const QString&)));
connect(&callManager, SIGNAL(conferenceCreated(const QString&)),
this, SLOT(conferenceCreatedSignal(const QString&)));
connect(&callManager, SIGNAL(conferenceChanged(const QString&, const QString&)),
this, SLOT(conferenceChangedSignal(const QString&, const QString&)));
connect(&callManager, SIGNAL(conferenceRemoved(const QString&)),
this, SLOT(conferenceRemovedSignal(const QString&)));
connect(&callManager, SIGNAL(incomingMessage(const QString&, const QString&)),
this, SLOT(incomingMessageSignal(const QString&, const QString&)));
connect(&callManager, SIGNAL(voiceMailNotify(const QString&, int)),
this, SLOT(voiceMailNotifySignal(const QString&, int)));
connect(&configurationManager, SIGNAL(accountsChanged()),
this, SLOT(accountChanged()));
connect(&configurationManager, SIGNAL(accountsChanged()),
getAccountList(), SLOT(updateAccounts()));
//setMinimumPollingInterval(1000);
connect(m_pModel , SIGNAL( callStateChanged(Call*)) , this , SLOT(callStateChangedSignal(Call*) ));
connect(&callManager , SIGNAL( incomingCall(Call*)) , this , SLOT(incomingCallSignal(Call*) ));
connect(&callManager , SIGNAL( conferenceCreated(Call*)) , this , SLOT(conferenceCreatedSignal(Call*) ));
connect(&callManager , SIGNAL( conferenceChanged(Call*)) , this , SLOT(conferenceChangedSignal(Call*) ));
}
bool SFLPhoneEngine::sourceRequestEvent(const QString &name)
{
if (name == "history") {
if ( name == "history" ) {
updateHistory();
}
else if (name == "calls") {
else if ( name == "calls" ) {
updateCallList();
}
else if (name == "conferences") {
else if ( name == "conferences" ) {
updateConferenceList();
}
else if (name == "info") {
else if ( name == "info" ) {
updateInfo();
}
return true;//updateSourceEvent(name);
......@@ -100,22 +85,22 @@ QString SFLPhoneEngine::getCallStateName(call_state state)
void SFLPhoneEngine::updateHistory()
{
foreach (Call* oldCall, getHistory()) {
historyCall[oldCall->getCallId()]["Name"] = oldCall->getPeerName();
historyCall[oldCall->getCallId()]["Number"] = oldCall->getPeerPhoneNumber();
historyCall[oldCall->getCallId()]["Date"] = oldCall->getStopTimeStamp();
foreach (Call* oldCall, m_pModel->getHistory()) {
historyCall[oldCall->getCallId()][ "Name" ] = oldCall->getPeerName();
historyCall[oldCall->getCallId()][ "Number" ] = oldCall->getPeerPhoneNumber();
historyCall[oldCall->getCallId()][ "Date" ] = oldCall->getStopTimeStamp();
setData("history", I18N_NOOP(oldCall->getCallId()), historyCall[oldCall->getCallId()]);
}
}
void SFLPhoneEngine::updateCallList()
{
foreach (Call* call, getCalls()) {
if ((!isConference(call)) && (call->getState() != CALL_STATE_OVER)) {
currentCall[call->getCallId()]["Name"] = call->getPeerName();
currentCall[call->getCallId()]["Number"] = call->getPeerPhoneNumber();
currentCall[call->getCallId()]["StateName"] = getCallStateName(call->getState());
currentCall[call->getCallId()]["State"] = call->getState();
foreach (Call* call, m_pModel->getCalls()) {
if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) {
currentCall[call->getCallId()][ "Name" ] = call->getPeerName();
currentCall[call->getCallId()][ "Number" ] = call->getPeerPhoneNumber();
currentCall[call->getCallId()][ "StateName" ] = getCallStateName(call->getState());
currentCall[call->getCallId()][ "State" ] = call->getState();
setData("calls", call->getCallId(), currentCall[call->getCallId()]);
}
}
......@@ -123,8 +108,8 @@ void SFLPhoneEngine::updateCallList()
void SFLPhoneEngine::updateConferenceList()
{
foreach (Call* call, getCalls()) {
if (isConference(call)) {
foreach (Call* call, m_pModel->getCalls()) {
if (m_pModel->isConference(call)) {
CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
currentConferences[call->getConfId()] = callManager.getParticipantList(call->getConfId());
setData("conferences", call->getConfId(), currentConferences[call->getConfId()]);
......@@ -139,54 +124,34 @@ void SFLPhoneEngine::updateContacts()
void SFLPhoneEngine::updateInfo()
{
qDebug() << "Currentaccount: " << getCurrentAccountId();
setData("info", I18N_NOOP("Account"), getCurrentAccountId());
qDebug() << "Currentaccount: " << m_pModel->getCurrentAccountId();
setData("info", I18N_NOOP("Account"), m_pModel->getCurrentAccountId());
}
void SFLPhoneEngine::callStateChangedSignal(const QString& callId, const QString& state)
void SFLPhoneEngine::callStateChangedSignal(Call* call)
{
qDebug() << "Signal : Call State Changed for call " << callId << " . New state : " << state;
Call* call = findCallByCallId(callId);
if(!call) {
if(state == CALL_STATE_CHANGE_RINGING) {
call = addRingingCall(callId);
//addCallToCallList(call);
}
else {
qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started.";
return;
}
}
else {
call->stateChanged(state);
}
Q_UNUSED(call)
updateCallList();
}
void SFLPhoneEngine::incomingCallSignal(const QString& accountId, const QString& callId)
void SFLPhoneEngine::incomingCallSignal(Call* call)
{
Q_UNUSED(accountId)
addIncomingCall(callId);
Q_UNUSED(call)
updateCallList();
}
void SFLPhoneEngine::conferenceCreatedSignal(const QString& confId)
void SFLPhoneEngine::conferenceCreatedSignal(Call* conf)
{
addConference(confId);
Q_UNUSED(conf)
updateConferenceList();
}
void SFLPhoneEngine::conferenceChangedSignal(const QString& confId, const QString& state)
void SFLPhoneEngine::conferenceChangedSignal(Call* conf)
{
conferenceChanged(confId, state);
Q_UNUSED(conf)
updateConferenceList();
}
void SFLPhoneEngine::conferenceRemovedSignal(const QString& confId)
{
conferenceRemoved(confId);
}
void SFLPhoneEngine::incomingMessageSignal(const QString& accountId, const QString& message)
{
Q_UNUSED(accountId)
......
......@@ -16,7 +16,7 @@
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
**************************************************************************/
#ifndef SFLPHONEENGINE_H
#define SFLPHONEENGINE_H
......@@ -27,8 +27,9 @@
#include "../../src/lib/CallModel.h"
typedef QHash<QString,QVariant> HashStringString;
class SFLPhoneEngine : public Plasma::DataEngine, public CallModelConvenience
class Call;
class SFLPhoneEngine : public Plasma::DataEngine
{
Q_OBJECT
......@@ -41,23 +42,24 @@ class SFLPhoneEngine : public Plasma::DataEngine, public CallModelConvenience
bool updateSourceEvent(const QString& source);
private:
QHash<QString, HashStringString > historyCall;
QHash<QString, HashStringString > currentCall;
QHash<QString, QStringList> currentConferences;
QHash<QString, HashStringString > historyCall ;
QHash<QString, HashStringString > currentCall ;
QHash<QString, QStringList> currentConferences ;
CallModelConvenience* m_pModel;
QString getCallStateName(call_state state);
void updateHistory();
void updateCallList();
void updateContacts();
void updateConferenceList();
void updateHistory ();
void updateCallList ();
void updateContacts ();
void updateConferenceList ();
void updateInfo();
private slots:
void callStateChangedSignal(const QString& callId, const QString& state);
void incomingCallSignal(const QString& accountId, const QString& callId);
void conferenceCreatedSignal(const QString& confId);
void conferenceChangedSignal(const QString& confId, const QString& state);
void conferenceRemovedSignal(const QString& confId);
void incomingMessageSignal(const QString& accountId, const QString& message);
void voiceMailNotifySignal(const QString& accountId, int count);
void callStateChangedSignal (Call* call);
void incomingCallSignal (Call* conf);
void conferenceCreatedSignal (Call* conf);
void conferenceChangedSignal (Call* conf);
//void conferenceRemovedSignal(const QString& confId);
void incomingMessageSignal( const QString& accountId, const QString& message );
void voiceMailNotifySignal( const QString& accountId, int count );
void accountChanged();
};
......
......@@ -6,50 +6,51 @@
MainWidget::MainWidget() : Plasma::Frame(), m_mainLayout(0), frmCalls(0), frmContact(0), frmHistory(0),currentMode(CALL)
{
mainTabs = new Plasma::TabBar(this);
mainTabs = new Plasma::TabBar ( this );
frmCalls = new Plasma::Frame ( this );
callLayout = new QGraphicsLinearLayout ( Qt::Vertical );
callScrollArea = new Plasma::ScrollWidget ( this );
frmContact = new Plasma::Frame ( this );
contactScrollArea = new Plasma::ScrollWidget ( this );
frmHistory = new Plasma::Frame ( this );
historyLayout = new QGraphicsLinearLayout ( Qt::Vertical );
historyScrollArea = new Plasma::ScrollWidget ( this );
mainLayout()->addItem(mainTabs);
//connect(mainTabs, SIGNAL(currentChanged(int)), this, SLOT(modeChanged(int)));
frmCalls = new Plasma::Frame(this);
frmCalls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
callLayout = new QGraphicsLinearLayout(Qt::Vertical);
frmCalls->setLayout(callLayout);
callScrollArea = new Plasma::ScrollWidget(this);
callScrollArea->setWidget(frmCalls);
frmContact = new Plasma::Frame(this);
frmContact->setText("Contact");
frmContact->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
contactScrollArea = new Plasma::ScrollWidget(this);
contactScrollArea->setWidget(frmContact);
frmHistory = new Plasma::Frame(this);
frmHistory->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
historyLayout = new QGraphicsLinearLayout(Qt::Vertical);
frmHistory->setLayout(historyLayout);
historyScrollArea = new Plasma::ScrollWidget(this);
historyScrollArea->setWidget(frmHistory);
dialPage = new DialPage();
connect(dialPage, SIGNAL(call(QString)), this, SLOT(call(QString)));
QGraphicsLinearLayout* callTabLayout = new QGraphicsLinearLayout(Qt::Vertical);
QGraphicsLinearLayout* historyTabLayout = new QGraphicsLinearLayout(Qt::Vertical);
QGraphicsLinearLayout* contactTabLayout = new QGraphicsLinearLayout(Qt::Vertical);
QGraphicsLinearLayout* addTabLayout = new QGraphicsLinearLayout(Qt::Vertical);
callTabLayout->addItem(callScrollArea);
historyTabLayout->addItem(historyScrollArea);
contactTabLayout->addItem(contactScrollArea);
QGraphicsLinearLayout* callTabLayout = new QGraphicsLinearLayout( Qt::Vertical );
QGraphicsLinearLayout* historyTabLayout = new QGraphicsLinearLayout( Qt::Vertical );
QGraphicsLinearLayout* contactTabLayout = new QGraphicsLinearLayout( Qt::Vertical );
QGraphicsLinearLayout* addTabLayout = new QGraphicsLinearLayout( Qt::Vertical );
callTabLayout->addItem ( callScrollArea );
historyTabLayout->addItem ( historyScrollArea );
contactTabLayout->addItem ( contactScrollArea );
addTabLayout->addItem(dialPage);
mainTabs->addTab("Call", callTabLayout);
mainTabs->addTab("History", historyTabLayout);
mainTabs->addTab("Contact", contactTabLayout);
mainTabs->addTab(KIcon("list-add"),"", addTabLayout);
mainTabs->addTab( "Call" , callTabLayout );
mainTabs->addTab( "History" , historyTabLayout );
mainTabs->addTab( "Contact" , contactTabLayout );
mainTabs->addTab( KIcon("list-add") , "", addTabLayout );
//mainLayout()->addItem(callTabLayout);
......@@ -58,9 +59,10 @@ MainWidget::MainWidget() : Plasma::Frame(), m_mainLayout(0), frmCalls(0), frmCon
//mainLayout()->addItem(contactScrollArea);
initPos = frmCalls->pos();
frmCalls->setPos(initPos);
frmHistory->setPos(initPos);
frmContact->setPos(initPos);
frmCalls->setPos ( initPos );
frmHistory->setPos( initPos );
frmContact->setPos( initPos );
setMinimumSize(285,390);
}
......@@ -72,15 +74,15 @@ void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Da
bool modified = false;
foreach(QVariant call, value) {
if (!callWidgetList[value.key(call)]) {
callWidgetList[value.key(call)] = new CallItem();
callWidgetList[value.key(call)]->setCallId(value.key(call));
callWidgetList[ value.key(call) ] = new CallItem();
callWidgetList[ value.key(call) ]->setCallId(value.key(call));
callLayout->insertItem(0,callWidgetList[value.key(call)]);
mainTabs->setCurrentIndex(CALL);
modified = true;
}
callWidgetList[value.key(call)]->setCallerName(call.toHash()["Name"].toString());
callWidgetList[value.key(call)]->setCallerNumber(call.toHash()["Number"].toString());
callWidgetList[value.key(call)]->setState(call.toHash()["State"].toInt());
callWidgetList[value.key(call)]->setCallerName(call.toHash() [ "Name" ].toString());
callWidgetList[value.key(call)]->setCallerNumber(call.toHash()[ "Number" ].toString());
callWidgetList[value.key(call)]->setState(call.toHash() [ "State" ].toInt());
if (call.toHash()["State"].toInt() == CALL_STATE_INCOMING) {
emit requierAttention();
......@@ -93,7 +95,8 @@ void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Da
//sflphoneEngine->connectSource("conferences", this,0/*Update only if something happen*/);
}
else if (source == "info") {
currentAccountId = data["Account"].toString();
if (!data["Account"].isNull() || data["Account"].isValid())
currentAccountId = data["Account"].toString();
}
else if (source == "conferences") {
QHash<QString, QVariant> value = data;
......@@ -122,15 +125,17 @@ void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Da
}
else if (source == "history") {
QHash<QString, QVariant> value = data;
foreach(QVariant call, value) {
if (!historyWidgetList[value.key(call)]) {
historyWidgetList[value.key(call)] = new CallItem();
historyWidgetList[value.key(call)]->setCallId(value.key(call));
historyLayout->addItem(historyWidgetList[value.key(call)]);
for (QHash<QString, QVariant>::iterator i = value.begin(); i != value.end(); ++i) {
QString key = i.key();
//QHash<QString, CallItem*> historyWidgetList;
if ( ! historyWidgetList[key]) {
historyWidgetList[ i.key() ] = new CallItem();
historyWidgetList[ i.key() ]->setCallId(i.key());
historyLayout->addItem(historyWidgetList[i.key()]);
}
historyWidgetList[value.key(call)]->setCallerName(call.toHash()["Name"].toString());
historyWidgetList[value.key(call)]->setCallerNumber(call.toHash()["Number"].toString());
historyWidgetList[value.key(call)]->setDate(call.toHash()["Date"].toInt());
historyWidgetList[ i.key() ]->setCallerName(i.value().toHash() [ "Name" ].toString());
historyWidgetList[ i.key() ]->setCallerNumber(i.value().toHash() [ "Number" ].toString());
historyWidgetList[ i.key() ]->setDate(i.value().toHash() [ "Date" ].toInt()) ;
}
}
}
......@@ -148,7 +153,7 @@ QGraphicsLinearLayout* MainWidget::mainLayout()
void MainWidget::call(QString number)
{
qDebug() << "Calling " << number << " with account " << currentAccountId << ", " << CallModelConvenience::getAccountList()->size() << " account registred";
CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
callManager.placeCall(currentAccountId, CallModelConvenience::generateCallId(), number);
// qDebug() << "Calling " << number << " with account " << currentAccountId << ", " << CallModelConvenience::getAccountList()->size() << " account registred";
// CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance();
// callManager.placeCall(currentAccountId, CallModelConvenience::generateCallId(), number);
}
......@@ -12,6 +12,7 @@
#include <Plasma/DataEngine>
#include <Plasma/ExtenderItem>
#include <KIcon>
#include <QHash>
#include "CallItem.h"
#include "ConferenceItem.h"
......
......@@ -12,7 +12,7 @@ SFLPhonePlasmoid::SFLPhonePlasmoid(QObject* parent, const QVariantList& args)
{
//m_svg.setImagePath("widgets/background");
setBackgroundHints(DefaultBackground);
CallModelConvenience::init();
setMinimumSize(24,24);
......
......@@ -21,6 +21,7 @@
#include "AccountListModel.h"
#include "lib/sflphone_const.h"
#include "conf/ConfigAccountList.h"
#include <QDebug>
AccountListModel::AccountListModel(QObject *parent)
......
......@@ -23,7 +23,8 @@
#include <QAbstractListModel>
#include "conf/ConfigAccountList.h"
//SFLPhone
class ConfigAccountList;
/**
@author Jérémy Quentin <jeremy.quentin@gmail.com>
......@@ -41,8 +42,6 @@ public:
QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
int rowCount(const QModelIndex & parent = QModelIndex()) const;
// int columnCount(const QModelIndex & parent = QModelIndex()) const;
// QVariant headerData(int section , Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex & index) const;
virtual bool setData ( const QModelIndex & index, const QVariant &value, int role);
......@@ -52,9 +51,6 @@ public:
bool addAccount( QString alias );
QString getOrderedList() const;
// QStringList getActiveCodecList() const ;
// void setActiveCodecList(const QStringList & activeCodecListToSet);
};
#endif
#include "AccountView.h"
#include <QDebug>
#include <QtGui/QListWidgetItem>
#include "lib/sflphone_const.h"
#include "lib/configurationmanager_interface_singleton.h"
///Constructor
AccountView::AccountView() : Account(), item2(0), itemWidget(0)
{
}
///Init
void AccountView::initItem()
{
if(item2 != NULL)
......@@ -20,6 +22,7 @@ void AccountView::initItem()
initItemWidget();
}
///Init widget
void AccountView::initItemWidget()
{
if(itemWidget != NULL)
......@@ -39,16 +42,19 @@ void AccountView::initItemWidget()
connect(itemWidget, SIGNAL(checkStateChanged(bool)), this, SLOT(setEnabled(bool)));
}
///Get the current item
QListWidgetItem* AccountView::getItem()
{
return item2;
}
///Get the current widget
AccountItemWidget* AccountView::getItemWidget()
{
return itemWidget;
}
///Return the state color
QColor AccountView::getStateColor()
{
if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED)
......@@ -58,7 +64,7 @@ QColor AccountView::getStateColor()
return Qt::red;
}
///Get the color name
QString AccountView::getStateColorName()
{
if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED)
......@@ -68,11 +74,13 @@ QString AccountView::getStateColorName()
return "red";
}
///Is this item checked?
bool AccountView::isChecked() const
{
return itemWidget->getEnabled();
}
///Build an item from an account id
AccountView* AccountView::buildExistingAccountFromId(QString _accountId)
{
//Account* a = Account::buildExistingAccountFromId( _accountId);
......@@ -84,6 +92,7 @@ AccountView* AccountView::buildExistingAccountFromId(QString _accountId)
return a;
}
///Build an item from an alias
AccountView* AccountView::buildNewAccountFromAlias(QString alias)
{
//Account* a = Account::buildNewAccountFromAlias(alias);
......@@ -94,6 +103,7 @@ AccountView* AccountView::buildNewAccountFromAlias(QString alias)
return a;
}
///Change LED color
void AccountView::updateState()
{
qDebug() << "updateState";
......
#ifndef ACCOUNT_VIEW_H
#define ACCOUNT_VIEW_H
#include <QtGui/QListWidgetItem>
#include "lib/Item.h"
#include "lib/Account.h"
#include "widgets/AccountItemWidget.h"
#include "lib/sflphone_const.h"
//Qt
class QListWidgetItem;
//SFLPhone
class AccountItemWidget;
class AccountView : public Account, public Item<AccountItemWidget> {
public:
......
This diff is collapsed.
......@@ -22,11 +22,12 @@
#define ACCOUNTWIZARD_H
#include <QWizard>
#include <QLabel>
#include <QRadioButton>
#include <QLineEdit>
#include <QCheckBox>
//Qt
class QLabel;
class QRadioButton;
class QLineEdit;
class QCheckBox;
/**
@author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>
......
......@@ -2,7 +2,6 @@
#include <QtCore/QTimer>
#include <akonadi/control.h>
#include <akonadi/collectionfilterproxymodel.h>
#include <akonadi/collectionmodel.h>
#include <akonadi/kmime/messagemodel.h>
#include <kabc/contactgroup.h>
#include <kabc/phonenumber.h>
......@@ -13,27 +12,37 @@
#include <akonadi/contact/contacteditor.h>
#include <kdialog.h>
#include <QObject>
#include <akonadi/session.h>
#include <kabc/addressee.h>
#include <kabc/addresseelist.h>
#include "lib/Contact.h"
#include "SFLPhone.h"
#include "SFLPhoneView.h"
///Init static attributes
AkonadiBackend* AkonadiBackend::m_pInstance = 0;
///Constructor
AkonadiBackend::AkonadiBackend(QObject* parent) : ContactBackend(parent)
{
//QTimer::singleShot( 0, this, SLOT( delayedInit() ) );
m_pSession = new Akonadi::Session( "SFLPhone::instance" );
// fetching all collections containing emails recursively, starting at the root collection
// fetching all collections containing emails recursively, starting at the root collection
Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob( Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive, this );
job->fetchScope().setContentMimeTypes( QStringList() << "text/directory" );
connect( job, SIGNAL( collectionsReceived( const Akonadi::Collection::List& ) ), this, SLOT( collectionsReceived( const Akonadi::Collection::List& ) ) );
}
///Destructor
AkonadiBackend::~AkonadiBackend()
{
}
///Singleton
ContactBackend* AkonadiBackend::getInstance()
{
if (m_pInstance == NULL) {
......@@ -42,6 +51,7 @@ ContactBackend* AkonadiBackend::getInstance()
return m_pInstance;
}
///Update the contact list when a new Akonadi collection is added
ContactList AkonadiBackend::update(Akonadi::Collection collection)
{
m_pCollection = collection;
......@@ -95,22 +105,25 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
return contacts;
}
///Update the contact list even without a new collection
ContactList AkonadiBackend::update_slot()
{
return update(m_pCollection);
}
///Find contact using a phone number
Contact* AkonadiBackend::getContactByPhone(QString phoneNumber)
{
return m_pContactByPhone[phoneNumber];
}
///Find contact by UID
Contact* AkonadiBackend::getContactByUid(QString uid)
{
return m_pContactByUid[uid];
}
///Called when a new collection is added
void AkonadiBackend::collectionsReceived( const Akonadi::Collection::List& list)
{
foreach (Akonadi::Collection coll, list) {
......@@ -119,6 +132,7 @@ void AkonadiBackend::collectionsReceived( const Akonadi::Collection::List& list
}
}
///Edit backend value using an updated frontend contact
void AkonadiBackend::editContact(Contact* contact)
{
KABC::Addressee ct = m_pAddrHash[contact->getUid()];
......@@ -135,6 +149,7 @@ void AkonadiBackend::editContact(Contact* contact)
dlg->exec();
}
///Add a new contact
void AkonadiBackend::addNewContact(Contact* contact)
{
KABC::Addressee newContact;
......@@ -177,8 +192,6 @@ void AkonadiBackend::addNewContact(Contact* contact)
dlg->setMainWidget(editor);
dlg->exec();
if ( !editor->saveContact() ) {
qDebug() << "Unable to save new contact to storage";
return;
......
#ifndef AKONADI_BACKEND_H
#define AKONADI_BACKEND_H
#include <QObject>
#include <akonadi/session.h>
#include <akonadi/collectionmodel.h>
#include <kabc/addressee.h>
#include <kabc/address