diff --git a/kde/plasma/CMakeLists.txt b/kde/plasma/CMakeLists.txt index a671e1337faf25196de17f2aa45689c860d7090a..f1eba1ab0f0017cc2c809b71822b40bf461bce54 100644 --- a/kde/plasma/CMakeLists.txt +++ b/kde/plasma/CMakeLists.txt @@ -1,4 +1,3 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -add_subdirectory(dataengine) add_subdirectory(plasmoid) diff --git a/kde/plasma/dataengine/sflphonEngine.cpp b/kde/plasma/dataengine/sflphonEngine.cpp deleted file mode 100644 index 4c7c51c90c4d4a4ccb464cece20ccbc1963e76f8..0000000000000000000000000000000000000000 --- a/kde/plasma/dataengine/sflphonEngine.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "sflphonEngine.h" - -#include <Plasma/DataContainer> - -#include "../../src/lib/Call.h" -#include "../../src/lib/dbus/metatypes.h" -#include "../../src/lib/instance_interface_singleton.h" -#include "../../src/lib/configurationmanager_interface_singleton.h" -#include "../../src/lib/callmanager_interface_singleton.h" -#include "../../src/lib/sflphone_const.h" - -SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent, args) -{ - Q_UNUSED(args) - m_pModel = new CallModelConvenience(CallModelConvenience::ActiveCall); - m_pModel->initCall(); - m_pModel->initHistory(); - - CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - - 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" ) { - updateHistory(); - } - else if ( name == "calls" ) { - updateCallList(); - } - else if ( name == "conferences" ) { - updateConferenceList(); - } - else if ( name == "info" ) { - updateInfo(); - } - return true;//updateSourceEvent(name); -} - -bool SFLPhoneEngine::updateSourceEvent(const QString &name) -{ - Q_UNUSED(name) - return true; -} - -QStringList SFLPhoneEngine::sources() const { - QStringList toReturn; - toReturn << "calls" << "history" << "conferences" << "info"; - return toReturn; -} - -QString SFLPhoneEngine::getCallStateName(call_state state) -{ - if (state == CALL_STATE_INCOMING) { - return I18N_NOOP("Ringing (in)"); - } else if (state == CALL_STATE_RINGING) { - return I18N_NOOP("Ringing (out)"); - } else if (state == CALL_STATE_CURRENT) { - return I18N_NOOP("Talking"); - } else if (state == CALL_STATE_DIALING) { - return I18N_NOOP("Dialing"); - } else if (state == CALL_STATE_HOLD) { - return I18N_NOOP("Hold"); - } else if (state == CALL_STATE_FAILURE) { - return I18N_NOOP("Failed"); - } else if (state == CALL_STATE_BUSY) { - return I18N_NOOP("Busy"); - } else if (state == CALL_STATE_TRANSFER) { - return I18N_NOOP("Transfer"); - } else if (state == CALL_STATE_TRANSF_HOLD) { - return I18N_NOOP("Transfer hold"); - } else if (state == CALL_STATE_OVER) { - return I18N_NOOP("Over"); - } else if (state == CALL_STATE_ERROR) { - return I18N_NOOP("Error"); - } - return ""; -} - -void SFLPhoneEngine::updateHistory() -{ - 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, 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()]); - } - } -} - -void SFLPhoneEngine::updateConferenceList() -{ - 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()]); - } - } -} - -void SFLPhoneEngine::updateContacts() -{ - -} - -void SFLPhoneEngine::updateInfo() -{ - qDebug() << "Currentaccount: " << m_pModel->getCurrentAccountId(); - setData("info", I18N_NOOP("Account"), m_pModel->getCurrentAccountId()); -} - -void SFLPhoneEngine::callStateChangedSignal(Call* call) -{ - Q_UNUSED(call) - updateCallList(); -} - -void SFLPhoneEngine::incomingCallSignal(Call* call) -{ - Q_UNUSED(call) - updateCallList(); -} - -void SFLPhoneEngine::conferenceCreatedSignal(Call* conf) -{ - Q_UNUSED(conf) - updateConferenceList(); -} - -void SFLPhoneEngine::conferenceChangedSignal(Call* conf) -{ - Q_UNUSED(conf) - updateConferenceList(); -} - -void SFLPhoneEngine::incomingMessageSignal(const QString& accountId, const QString& message) -{ - Q_UNUSED(accountId) - Q_UNUSED(message) - //TODO -} - -void SFLPhoneEngine::voiceMailNotifySignal(const QString& accountId, int count) -{ - Q_UNUSED(accountId) - Q_UNUSED(count) - //TODO -} - -void SFLPhoneEngine::accountChanged() -{ - -} - -K_EXPORT_PLASMA_DATAENGINE(sflphone, SFLPhoneEngine) diff --git a/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp b/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp index 293df0fa9ab29501536eb13062dbb9a25388d780..8f5a5b6fc5bd9ebc25ee94f1ef7b54a01309e2f0 100644 --- a/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp +++ b/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp @@ -13,7 +13,7 @@ SFLPhonePlasmoid::SFLPhonePlasmoid(QObject* parent, const QVariantList& args) //m_svg.setImagePath("widgets/background"); setBackgroundHints(DefaultBackground); - CallModelConvenience::init(); + CallModel<>::init(); setMinimumSize(24,24); } diff --git a/kde/src/CMakeLists.txt b/kde/src/CMakeLists.txt index 41338d80f92adf0b2a415e8c1ae3ef0e8a4fe6d8..2e1af6b3ffe31a053534b0fa9c4ec1d7442f7a49 100755 --- a/kde/src/CMakeLists.txt +++ b/kde/src/CMakeLists.txt @@ -1,28 +1,30 @@ ADD_DEFINITIONS( - ${KDE4_DEFINITIONS} - ${QT_DEFINITIONS} - -fexceptions - -DDATA_INSTALL_DIR="\\\"${DATA_INSTALL_DIR}\\\"" - -DSHARE_INSTALL_PREFIX="\\\"${SHARE_INSTALL_PREFIX}\\\"" + ${KDE4_DEFINITIONS} + ${QT_DEFINITIONS} + -fexceptions + -DDATA_INSTALL_DIR="\\\"${DATA_INSTALL_DIR}\\\"" + -DSHARE_INSTALL_PREFIX="\\\"${SHARE_INSTALL_PREFIX}\\\"" ) ADD_DEFINITIONS("-std=c++0x") -add_subdirectory(lib) +add_subdirectory( lib ) +add_subdirectory( klib ) find_package(Phonon) MESSAGE("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") IF(${CMAKE_BUILD_TYPE} MATCHES Release) - MESSAGE("NO DEBUG OUTPUT") - ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT) + MESSAGE("NO DEBUG OUTPUT") + ADD_DEFINITIONS( -DQT_NO_DEBUG_OUTPUT) ENDIF(${CMAKE_BUILD_TYPE} MATCHES Release) SET ( KDE4_KABC_LIBS -lkabc ) -SET( sflphone_client_kde_SRCS +SET( + sflphone_client_kde_SRCS SFLPhoneView.cpp SFLPhone.cpp SFLPhoneapplication.cpp @@ -40,7 +42,6 @@ SET( sflphone_client_kde_SRCS conf/dlgaudio.cpp conf/dlgaddressbook.cpp conf/dlghooks.cpp - conf/ConfigurationSkeleton.cpp conf/ConfigAccountList.cpp widgets/Dialpad.cpp widgets/ContactItemWidget.cpp @@ -50,10 +51,8 @@ SET( sflphone_client_kde_SRCS widgets/TranslucentButtons.cpp widgets/CategoryDrawer.cpp widgets/CategorizedTreeWidget.cpp - widgets/SortableDockCommon.cpp Codec.cpp AccountListModel.cpp - AkonadiBackend.cpp CallView.cpp AccountView.cpp ) @@ -66,27 +65,26 @@ QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS}) # kde4_automoc(${sflphone_client_kde_SRCS}) -SET( config_ui_files - conf/dlggeneralbase.ui - conf/dlgdisplaybase.ui - conf/dlgaccountsbase.ui - conf/dlgaudiobase.ui - conf/dlgaddressbookbase.ui - conf/dlghooksbase.ui +SET( + config_ui_files + conf/dlggeneralbase.ui + conf/dlgdisplaybase.ui + conf/dlgaccountsbase.ui + conf/dlgaudiobase.ui + conf/dlgaddressbookbase.ui + conf/dlghooksbase.ui ) KDE4_ADD_UI_FILES(sflphone_client_kde_SRCS ui/SFLPhoneView_base.ui ${config_ui_files} ) -KDE4_ADD_KCFG_FILES(sflphone_client_kde_SRCS conf/kcfg_settings.kcfgc) -INSTALL(FILES conf/sflphone-client-kde.kcfg DESTINATION ${KCFG_INSTALL_DIR}) KDE4_ADD_EXECUTABLE(sflphone-client-kde ${sflphone_client_kde_SRCS} ${QtApp_RCC_SRCS}) -TARGET_LINK_LIBRARIES(sflphone-client-kde qtsflphone ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDEPIMLIBS_AKONADI_KMIME_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_AKONADI_CONTACT_LIBS} ${KDE4_PHONON_LIBS} ) +TARGET_LINK_LIBRARIES(sflphone-client-kde ksflphone qtsflphone ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDEPIMLIBS_AKONADI_KMIME_LIBS} ${KDEPIMLIBS_AKONADI_LIBS} ${KDEPIMLIBS_AKONADI_CONTACT_LIBS} ${KDE4_PHONON_LIBS} ) ########### install files ############### -INSTALL(TARGETS sflphone-client-kde DESTINATION ${BIN_INSTALL_DIR}) +INSTALL(TARGETS sflphone-client-kde DESTINATION ${BIN_INSTALL_DIR} ) INSTALL( FILES icons/transferarraw.png DESTINATION ${DATA_INSTALL_DIR}/sflphone-client-kde ) INSTALL( FILES icons/transfertarrow.svg DESTINATION ${DATA_INSTALL_DIR}/sflphone-client-kde ) INSTALL( FILES icons/confBlackWhite.svg DESTINATION ${DATA_INSTALL_DIR}/sflphone-client-kde ) diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp index d44d330229b66f36026c5243e0e7bcab8fab389e..de0b5dfc42fbb365419ee88b70d7e9347135d8e3 100644 --- a/kde/src/CallView.cpp +++ b/kde/src/CallView.cpp @@ -44,7 +44,7 @@ #include "widgets/CallTreeItem.h" #include "SFLPhone.h" #include "SFLPhoneView.h" -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" ///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop diff --git a/kde/src/SFLPhone.cpp b/kde/src/SFLPhone.cpp index c2a60787f5a3b56bf7cd5b8c9b32307cc8f5876b..adaf9693d80bc6f7308443a796fb89b855f78ddb 100755 --- a/kde/src/SFLPhone.cpp +++ b/kde/src/SFLPhone.cpp @@ -47,14 +47,14 @@ #include "lib/Contact.h" //SFLPhone -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" #include "AccountWizard.h" #include "SFLPhoneView.h" #include "widgets/SFLPhoneTray.h" #include "widgets/ContactDock.h" #include "widgets/HistoryDock.h" #include "widgets/BookmarkDock.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" SFLPhone* SFLPhone::m_sApp = NULL; TreeWidgetCallModel* SFLPhone::m_pModel = NULL; diff --git a/kde/src/SFLPhoneView.cpp b/kde/src/SFLPhoneView.cpp index 1eabaacf8fbfc4b50d1a687f782e3829ac55de21..d6c7475e6d093ad908593e4be1668fb35fe81239 100755 --- a/kde/src/SFLPhoneView.cpp +++ b/kde/src/SFLPhoneView.cpp @@ -38,7 +38,7 @@ //SFLPhone #include "conf/ConfigurationDialog.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "AccountWizard.h" #include "ActionSetAccountFirst.h" #include "SFLPhone.h" diff --git a/kde/src/conf/ConfigurationDialog.cpp b/kde/src/conf/ConfigurationDialog.cpp index 0cc5f16e3a7ec4149c7054088f45e185a972a21b..3c65966eb867514b2f7efb54daf7407131432e76 100755 --- a/kde/src/conf/ConfigurationDialog.cpp +++ b/kde/src/conf/ConfigurationDialog.cpp @@ -24,7 +24,7 @@ #include <KDebug> -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "dlggeneral.h" #include "dlgdisplay.h" diff --git a/kde/src/conf/ConfigurationDialog.h b/kde/src/conf/ConfigurationDialog.h index 06bc43c9ae9c398982f6116a9047ff38849fe644..4669efc65408ea650499eb6dda19a9d29ce70cb9 100755 --- a/kde/src/conf/ConfigurationDialog.h +++ b/kde/src/conf/ConfigurationDialog.h @@ -24,7 +24,7 @@ #include <kconfigdialog.h> -#include "kcfg_settings.h" +#include "klib/kcfg_settings.h" #include "SFLPhoneView.h" diff --git a/kde/src/conf/dlgaddressbook.cpp b/kde/src/conf/dlgaddressbook.cpp index 8145b7cc337d9be0f68920a3159923f4fbb26d94..f568fa645203908c14e5910f201ebfef0b3ba5d1 100755 --- a/kde/src/conf/dlgaddressbook.cpp +++ b/kde/src/conf/dlgaddressbook.cpp @@ -20,7 +20,7 @@ ***************************************************************************/ #include "dlgaddressbook.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" DlgAddressBook::DlgAddressBook(QWidget *parent) : QWidget(parent) diff --git a/kde/src/conf/dlgaudio.cpp b/kde/src/conf/dlgaudio.cpp index 1366b5457d58858d5055528a4ce9ace00f37e8ab..95a77beb2d5cd860da3b144f41cce17ff382af7c 100755 --- a/kde/src/conf/dlgaudio.cpp +++ b/kde/src/conf/dlgaudio.cpp @@ -22,7 +22,7 @@ #include <KLineEdit> #include "lib/configurationmanager_interface_singleton.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "conf/ConfigurationDialog.h" #include <QtGui/QHeaderView> #include <KStandardDirs> diff --git a/kde/src/conf/dlgaudio.h b/kde/src/conf/dlgaudio.h index 5b9a9885e3f41c5ed6539c38c011761e65b0d774..c3d7fa7e326beabcf5403b5d5c8978fc6de074ed 100755 --- a/kde/src/conf/dlgaudio.h +++ b/kde/src/conf/dlgaudio.h @@ -25,7 +25,7 @@ #include <kconfigdialog.h> #include "ui_dlgaudiobase.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" /** @author Jérémy Quentin <jeremy.quentin@gmail.com> diff --git a/kde/src/conf/dlggeneral.cpp b/kde/src/conf/dlggeneral.cpp index ea7f3a6a811784ee1480a4466d83cd1e79ade071..3424327b6c31b004a7b8becad403eb9979221b44 100755 --- a/kde/src/conf/dlggeneral.cpp +++ b/kde/src/conf/dlggeneral.cpp @@ -22,7 +22,7 @@ #include <QToolButton> #include <QAction> -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "conf/ConfigurationDialog.h" DlgGeneral::DlgGeneral(QWidget *parent) diff --git a/kde/src/AkonadiBackend.cpp b/kde/src/klib/AkonadiBackend.cpp similarity index 92% rename from kde/src/AkonadiBackend.cpp rename to kde/src/klib/AkonadiBackend.cpp index 52f698723e537b301de783eab8900f7a988f81d2..f47c793f6d494feee856dbd428ebc1e65c44ffed 100644 --- a/kde/src/AkonadiBackend.cpp +++ b/kde/src/klib/AkonadiBackend.cpp @@ -43,16 +43,17 @@ #include <kabc/phonenumber.h> //SFLPhone library -#include "lib/Contact.h" -#include "lib/AccountList.h" -#include "lib/Account.h" +#include "../lib/Contact.h" +#include "../lib/AccountList.h" +#include "../lib/Account.h" //SFLPhone -#include "SFLPhone.h" -#include "SFLPhoneView.h" +//#include "SFLPhone.h" +//#include "SFLPhoneView.h" ///Init static attributes AkonadiBackend* AkonadiBackend::m_pInstance = 0; +CallModel<>* AkonadiBackend::m_pModel = 0; ///Constructor AkonadiBackend::AkonadiBackend(QObject* parent) : ContactBackend(parent) @@ -60,6 +61,12 @@ AkonadiBackend::AkonadiBackend(QObject* parent) : ContactBackend(parent) //QTimer::singleShot( 0, this, SLOT( delayedInit() ) ); m_pSession = new Akonadi::Session( "SFLPhone::instance" ); + if ( not m_pModel ) { + m_pModel = new CallModel<>(CallModel<>::ActiveCall); + m_pModel->initCall(); + m_pModel->initHistory(); + } + // 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" ); @@ -95,7 +102,7 @@ Contact* AkonadiBackend::getContactByPhone(const QString& phoneNumber,bool resol if (!resolveDNS || phoneNumber.indexOf("@") == -1) return m_ContactByPhone[phoneNumber]; else if (!getHostNameFromPhone(phoneNumber).isEmpty() && m_ContactByPhone[getUserFromPhone(phoneNumber)]) { - foreach (Account* a, SFLPhone::model()->getAccountList()->getAccounts()) { + foreach (Account* a, m_pModel->getAccountList()->getAccounts()) { if (a->getAccountDetail(ACCOUNT_HOSTNAME) == getHostNameFromPhone(phoneNumber)) return m_ContactByPhone[getUserFromPhone(phoneNumber)]; } @@ -120,10 +127,9 @@ Contact* AkonadiBackend::getContactByUid(const QString& uid) ContactList AkonadiBackend::update(Akonadi::Collection collection) { m_Collection = collection; - ContactList contacts; if ( !collection.isValid() ) { kDebug() << "The current collection is not valid"; - return contacts; + return ContactList(); } Akonadi::RecursiveItemFetchJob *job = new Akonadi::RecursiveItemFetchJob( collection, QStringList() << KABC::Addressee::mimeType() << KABC::ContactGroup::mimeType()); @@ -164,33 +170,32 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection) aContact->setPhoto(new QPixmap(QPixmap::fromImage( tmp.photo().data()).scaled(QSize(48,48)))); else aContact->setPhoto(0); - contacts << aContact; } } m_pContacts = m_ContactByUid.values(); } - return contacts; + return m_ContactByUid.values(); } ///Edit backend value using an updated frontend contact -void AkonadiBackend::editContact(Contact* contact) +void AkonadiBackend::editContact(Contact* contact,QWidget* parent) { KABC::Addressee ct = m_AddrHash[contact->getUid()]; if (ct.uid() != contact->getUid()) { kDebug() << "Contact not found"; return; } - Akonadi::ContactEditor *editor = new Akonadi::ContactEditor( Akonadi::ContactEditor::EditMode, SFLPhone::app()->view() ); + Akonadi::ContactEditor *editor = new Akonadi::ContactEditor( Akonadi::ContactEditor::EditMode, parent ); Akonadi::Item item; item.setPayload<KABC::Addressee>(ct); editor->loadContact(item); - KDialog* dlg = new KDialog(SFLPhone::app()->view()); + KDialog* dlg = new KDialog(parent); dlg->setMainWidget(editor); dlg->exec(); } ///Add a new contact -void AkonadiBackend::addNewContact(Contact* contact) +void AkonadiBackend::addNewContact(Contact* contact,QWidget* parent) { KABC::Addressee newContact; newContact.setNickName ( contact->getNickName() ); @@ -222,14 +227,13 @@ void AkonadiBackend::addNewContact(Contact* contact) newContact.insertPhoneNumber(pn); } - //aContact->setPhoneNumbers (newNumbers );//TODO - Akonadi::ContactEditor *editor = new Akonadi::ContactEditor( Akonadi::ContactEditor::CreateMode, SFLPhone::app()->view() ); + Akonadi::ContactEditor *editor = new Akonadi::ContactEditor( Akonadi::ContactEditor::CreateMode, parent ); editor->setContactTemplate(newContact); - KDialog* dlg = new KDialog(SFLPhone::app()->view()); + KDialog* dlg = new KDialog(parent); dlg->setMainWidget(editor); dlg->exec(); @@ -239,6 +243,18 @@ void AkonadiBackend::addNewContact(Contact* contact) } } +///Implement virtual pure method +void AkonadiBackend::editContact(Contact* contact) +{ + editContact(contact,0); +} + +///Implement virtual pure method +void AkonadiBackend::addNewContact(Contact* contact) +{ + addNewContact(contact,0); +} + /***************************************************************************** * * diff --git a/kde/src/AkonadiBackend.h b/kde/src/klib/AkonadiBackend.h similarity index 84% rename from kde/src/AkonadiBackend.h rename to kde/src/klib/AkonadiBackend.h index cfbf5cde5deff6243edc52a4d29e2921d634147e..e2d9a57c2204a1b2d544b20bf9952bb0cd42f55f 100644 --- a/kde/src/AkonadiBackend.h +++ b/kde/src/klib/AkonadiBackend.h @@ -20,7 +20,9 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * **************************************************************************/ -#include <lib/ContactBackend.h> +#include "../lib/ContactBackend.h" +#include "../lib/CallModel.h" +#include "../lib/typedefs.h" #include <akonadi/collectionmodel.h> //Qt @@ -41,17 +43,18 @@ namespace Akonadi { //SFLPhone class Contact; -typedef QList<Contact*> ContactList; - ///@class AkonadiBackend Implement a backend for Akonadi -class AkonadiBackend : public ContactBackend { +class LIB_EXPORT AkonadiBackend : public ContactBackend { Q_OBJECT public: static ContactBackend* getInstance(); Contact* getContactByPhone ( const QString& phoneNumber ,bool resolveDNS = false ); Contact* getContactByUid ( const QString& uid ); - void editContact ( Contact* contact ); - void addNewContact ( Contact* contact ); + void editContact ( Contact* contact , QWidget* parent = 0 ); + void addNewContact ( Contact* contact , QWidget* parent = 0 ); + + virtual void editContact ( Contact* contact ); + virtual void addNewContact ( Contact* contact ); private: AkonadiBackend(QObject* parent); @@ -63,6 +66,7 @@ private: //Attributes static AkonadiBackend* m_pInstance ; + static CallModel<>* m_pModel ; Akonadi::Session* m_pSession ; Akonadi::Collection m_Collection ; QHash<QString,KABC::Addressee> m_AddrHash ; diff --git a/kde/src/klib/CMakeLists.txt b/kde/src/klib/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ac2581263fb133df34b900ee27bd2db3b9dadb98 --- /dev/null +++ b/kde/src/klib/CMakeLists.txt @@ -0,0 +1,67 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +ADD_DEFINITIONS("-std=c++0x") + +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + -fexceptions +) + +PROJECT(ksflphone) + +SET ( KDE4_KABC_LIBS -lkabc ) + + +add_subdirectory(dataengine) + +SET(LOCAL_CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") +SET(CMAKE_MODULE_PATH "${LOCAL_CMAKE_MODULE_PATH}") + +FIND_PACKAGE ( KDE4 REQUIRED ) +FIND_PACKAGE ( Qt4 REQUIRED ) + +INCLUDE ( KDE4Defaults ) + +set(GENERIC_LIB_VERSION "1.1.0") + +INCLUDE_DIRECTORIES ( ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) + +#File to compile +set( ksflphone_LIB_SRCS + HelperFunctions.cpp + AkonadiBackend.cpp + SortableDockCommon.cpp + ConfigurationSkeleton.cpp +) + +KDE4_ADD_KCFG_FILES(ksflphone_LIB_SRCS kcfg_settings.kcfgc) + +kde4_add_library( ksflphone SHARED ${ksflphone_LIB_SRCS} ) + +target_link_libraries( ksflphone + qtsflphone + ${QT_QTCORE_LIBRARY} + ${KDEPIMLIBS_AKONADI_KMIME_LIBS} + ${KDEPIMLIBS_AKONADI_LIBS} + ${KDEPIMLIBS_AKONADI_CONTACT_LIBS} + ${KDE4_KDEUI_LIBS} +) + +set_target_properties( ksflphone + PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} +) + +set( ksflphone_LIB_HDRS + AkonadiBackend.h + HelperFunctions.h + SortableDockCommon.h +) + +INSTALL(FILES sflphone-client-kde.kcfg DESTINATION ${KCFG_INSTALL_DIR}) + +install( FILES ${ksflphone_LIB_HDRS} + DESTINATION ${INCLUDE_INSTALL_DIR}/ksflphone + COMPONENT Devel +) + +install( TARGETS ksflphone ${INSTALL_TARGETS_DEFAULT_ARGS} ) diff --git a/kde/src/conf/ConfigurationSkeleton.cpp b/kde/src/klib/ConfigurationSkeleton.cpp similarity index 99% rename from kde/src/conf/ConfigurationSkeleton.cpp rename to kde/src/klib/ConfigurationSkeleton.cpp index 2efa9721a8c9b73c71e6a4f865c3be18729045aa..c7d07ef85067a9293f81c62b43ca0c3f5e02b2ae 100755 --- a/kde/src/conf/ConfigurationSkeleton.cpp +++ b/kde/src/klib/ConfigurationSkeleton.cpp @@ -20,8 +20,8 @@ ***************************************************************************/ #include "ConfigurationSkeleton.h" -#include "lib/configurationmanager_interface_singleton.h" -#include "lib/sflphone_const.h" +#include "../lib/configurationmanager_interface_singleton.h" +#include "../lib/sflphone_const.h" //KDE #include <KDebug> diff --git a/kde/src/conf/ConfigurationSkeleton.h b/kde/src/klib/ConfigurationSkeleton.h similarity index 95% rename from kde/src/conf/ConfigurationSkeleton.h rename to kde/src/klib/ConfigurationSkeleton.h index cd99acd48a1770c1f31181f2677f399355c01fd2..389535463c510deb5b91dc2fc250888d917522a8 100755 --- a/kde/src/conf/ConfigurationSkeleton.h +++ b/kde/src/klib/ConfigurationSkeleton.h @@ -22,10 +22,10 @@ #define CONFIGURATIONSKELETON_H #include <QWidget> +#include "../lib/typedefs.h" -#include "kcfg_settings.h" +#include "src/klib/kcfg_settings.h" //#include "CodecListModel.h" -#include "AccountListModel.h" /** @author Jérémy Quentin <jeremy.quentin@gmail.com> @@ -38,7 +38,7 @@ This class reimplements the writeConfig and readConfig functions to ask the daemon instead of the normal behavior (read and write in a kconfig file). */ -class ConfigurationSkeleton : public ConfigurationSkeletonBase +class LIB_EXPORT ConfigurationSkeleton : public ConfigurationSkeletonBase { Q_OBJECT diff --git a/kde/src/klib/HelperFunctions.cpp b/kde/src/klib/HelperFunctions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c94a1eda75568325c6d4a5d05a8f76703b686bef --- /dev/null +++ b/kde/src/klib/HelperFunctions.cpp @@ -0,0 +1,16 @@ +#include "HelperFunctions.h" + +//Qt +#include <QtCore/QString> +#include <QtCore/QVariant> + +//SFLPhone +#include "../lib/Contact.h" + +ContactHash HelperFunctions::toHash(QList<Contact*> contacts) { + QHash<QString,QHash<QString,QVariant> > hash; + for (int i=0;i<contacts.size();i++) { + hash[contacts[i]->getUid()] = contacts[i]->toHash(); + } + return hash; +} \ No newline at end of file diff --git a/kde/src/klib/HelperFunctions.h b/kde/src/klib/HelperFunctions.h new file mode 100644 index 0000000000000000000000000000000000000000..2ff2dff4475067edc853f149b15ef4d33ba3e34f --- /dev/null +++ b/kde/src/klib/HelperFunctions.h @@ -0,0 +1,22 @@ +#ifndef HELPER_FUNCTIONS +#define HELPER_FUNCTIONS + +//Qt +#include <QtCore/QString> +#include <QtCore/QVariant> +#include <QtCore/QHash> +#include <QtCore/QList> + +//SFLPhone +#include "../lib/Contact.h" + +//Typedef +typedef QHash<QString,QHash<QString,QVariant> > ContactHash; + +///@class HelperFunctions little visitor not belonging to libqtsflphone +///Ramdom mix of dynamic property and transtypping +class LIB_EXPORT HelperFunctions { +public: + static ContactHash toHash(QList<Contact*> contacts); +}; +#endif \ No newline at end of file diff --git a/kde/src/klib/SortableDockCommon.cpp b/kde/src/klib/SortableDockCommon.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fc33fd17ae5298456ade30a8c7ee9475def89454 --- /dev/null +++ b/kde/src/klib/SortableDockCommon.cpp @@ -0,0 +1,53 @@ +#include "SortableDockCommon.h" + +//Qt +#include <QtCore/QDateTime> +#include <QtCore/QStringList> +#include <QtCore/QTimer> + +//SFLPhone +#include "../lib/Call.h" +#include "../lib/Contact.h" +#include "../lib/CallModel.h" +#include "AkonadiBackend.h" + +///StaticEventHandler constructor +StaticEventHandler::StaticEventHandler(QObject* parent, QStringList* list) : QObject(parent),m_pList(list) +{ + QTimer* timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(update())); + timer->start(86400000); //1 day + update(); +} + +///Update the days constant, necessary to cycle after midnight +void StaticEventHandler::update() +{ + (*m_pList)= { + "Today" ,//0 + "Yesterday" ,//1 + QDate::currentDate().addDays(-2).toString("dddd"),//2 + QDate::currentDate().addDays(-3).toString("dddd"),//3 + QDate::currentDate().addDays(-4).toString("dddd"),//4 + QDate::currentDate().addDays(-5).toString("dddd"),//5 + QDate::currentDate().addDays(-6).toString("dddd"),//6 + "Last week" ,//7 + "Two weeks ago" ,//8 + "Three weeks ago" ,//9 + "Last month" ,//10 + "Two months ago" ,//11 + "Three months ago" ,//12 + "Four months ago" ,//13 + "Five months ago" ,//14 + "Six months ago" ,//15 + "Seven months ago" ,//16 + "Eight months ago" ,//17 + "Nine months ago" ,//18 + "Ten months ago" ,//19 + "Eleven months ago" ,//20 + "Twelve months ago" ,//21 + "Last year" ,//22 + "Very long time ago" ,//23 + "Never" //24 + }; +} diff --git a/kde/src/widgets/SortableDockCommon.h b/kde/src/klib/SortableDockCommon.h similarity index 52% rename from kde/src/widgets/SortableDockCommon.h rename to kde/src/klib/SortableDockCommon.h index 04ad4ac3d519528f529a6351f9a9962e1b4e8bcd..7e873d7787a313d00e5a0d26722f9d003d428620 100644 --- a/kde/src/widgets/SortableDockCommon.h +++ b/kde/src/klib/SortableDockCommon.h @@ -1,8 +1,12 @@ #ifndef SORTABLE_DOCK_COMMON #define SORTABLE_DOCK_COMMON -#include <QObject> -#include <QHash> +#include <QtCore/QObject> +#include <QtCore/QHash> +#include <QtCore/QModelIndex> +#include <QtGui/QWidget> + +#include "HelperFunctions.h" //Qt class QString; @@ -13,16 +17,41 @@ class QDateTime; //SFLPhone class StaticEventHandler; class Contact; +class Call; + +///@enum ContactSortingMode Available sorting mode +enum ContactSortingMode { + Name , + Organisation , + Recently_used , + Group , + Department +}; + +///@enum HistorySortingMode +enum HistorySortingMode { + Date = 0, + Name2 = 1, + Popularity = 2, + Length = 3 +}; -class SortableDockCommon { +template <typename CallWidget = QWidget*, typename Index = QModelIndex*> +class LIB_EXPORT SortableDockCommon { public: friend class StaticEventHandler; + //Helpers + static QString getIdentity(Call* item); + static int usableNumberCount(Contact* cont); + static void setHistoryCategory ( QList<Call*>& calls , HistorySortingMode mode ); + static void setContactCategory ( QList<Contact*> contacts , ContactSortingMode mode ); + protected: - SortableDockCommon(){}; + SortableDockCommon(); //Helpers - static QString timeToHistoryCategory(QDate date); - static QHash<Contact*, QDateTime> getContactListByTime(/*ContactList list*/); + static QString timeToHistoryCategory ( QDate date ); + static QHash<Contact*, QDateTime> getContactListByTime ( /*ContactList list*/ ); //Attributes static QStringList m_slHistoryConst; @@ -62,14 +91,18 @@ class SortableDockCommon { ///@class StaticEventHandler "cron jobs" for static member; -class StaticEventHandler : public QObject +class LIB_EXPORT StaticEventHandler : public QObject { Q_OBJECT public: - StaticEventHandler(QObject* parent); + StaticEventHandler(QObject* parent, QStringList* list); - private slots: + public slots: void update(); + private: + QStringList* m_pList; }; +#include "SortableDockCommon.hpp" + #endif \ No newline at end of file diff --git a/kde/src/klib/SortableDockCommon.hpp b/kde/src/klib/SortableDockCommon.hpp new file mode 100644 index 0000000000000000000000000000000000000000..213752e004640d78cac3cf4b296eed16dbda68b3 --- /dev/null +++ b/kde/src/klib/SortableDockCommon.hpp @@ -0,0 +1,211 @@ +//Qt +#include <QtCore/QDateTime> +#include <QtCore/QStringList> +#include <QtCore/QTimer> + +//SFLPhone +#include "../lib/Call.h" +#include "../lib/Contact.h" +#include "../lib/CallModel.h" +#include "AkonadiBackend.h" +#include "HelperFunctions.h" +#include "ConfigurationSkeleton.h" + +//Define +#define CALLMODEL_TEMPLATE template<typename CallWidget, typename Index> +#define SORTABLE_T SortableDockCommon<CallWidget,Index> + +CALLMODEL_TEMPLATE QStringList SORTABLE_T::m_slHistoryConst = QStringList(); +CALLMODEL_TEMPLATE StaticEventHandler* SORTABLE_T::m_spEvHandler = new StaticEventHandler(0,&(SORTABLE_T::m_slHistoryConst)); + +CALLMODEL_TEMPLATE SORTABLE_T::SortableDockCommon() +{ + /*if (not m_spEvHandler) { + m_spEvHandler = new StaticEventHandler(0,&(SORTABLE_T::m_slHistoryConst)); + }*/ +} + + +/***************************************************************************** + * * + * Helpers * + * * + ****************************************************************************/ + +CALLMODEL_TEMPLATE QString SORTABLE_T::timeToHistoryCategory(QDate date) +{ + if (m_slHistoryConst.size() < 10) + m_spEvHandler->update(); + + //m_spEvHandler->update(); + if (QDate::currentDate() == date || QDate::currentDate() < date) //The future case would be a bug, but it have to be handled anyway or it will appear in "very long time ago" + return m_slHistoryConst[HistoryConst::Today]; + + //Check for last week + for (int i=1;i<7;i++) { + if (QDate::currentDate().addDays(-i) == date) + return m_slHistoryConst[i]; //Yesterday to Six_days_ago + } + + //Check for last month + for (int i=1;i<4;i++) { + if (QDate::currentDate().addDays(-(i*7)) >= date && QDate::currentDate().addDays(-(i*7) -7) < date) + return m_slHistoryConst[i+Last_week-1]; //Last_week to Three_weeks_ago + } + + //Check for last year + for (int i=1;i<12;i++) { + if (QDate::currentDate().addMonths(-i) >= date && QDate::currentDate().addMonths((-i) - 1) < date) + return m_slHistoryConst[i+Last_month-1]; //Last_month to Twelve_months ago + } + + if (QDate::currentDate().addYears(-1) >= date && QDate::currentDate().addYears(-2) < date) + return m_slHistoryConst[Last_year]; + + //Every other senario + return m_slHistoryConst[Very_long_time_ago]; +} + +///Return the list of contact from history (in order, most recently used first) +CALLMODEL_TEMPLATE QHash<Contact*, QDateTime> SORTABLE_T::getContactListByTime(/*ContactList list*/) +{ + const CallMap& history= CallModel<CallWidget,Index>::getHistory(); + QHash<Contact*, QDateTime> toReturn; + QSet<QString> alreadyUsed; + QMapIterator<QString, Call*> i(history); + i.toBack(); + while (i.hasPrevious()) { //Iterate from the end up + i.previous(); + (alreadyUsed.find(i.value()->getPeerPhoneNumber()) == alreadyUsed.constEnd()); //Don't ask, leave it there Elv13(2012) + if (alreadyUsed.find(i.value()->getPeerPhoneNumber()) == alreadyUsed.constEnd()) { + Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(i.value()->getPeerPhoneNumber(),true); + if (contact && toReturn.find(contact) == toReturn.end()) { + toReturn[contact] = QDateTime::fromTime_t(i.value()->getStartTimeStamp().toUInt()); + } + alreadyUsed << i.value()->getPeerPhoneNumber(); + } + } + return toReturn; +} + +CALLMODEL_TEMPLATE void SORTABLE_T::setHistoryCategory(QList<Call*>& calls,HistorySortingMode mode) +{ + QHash<QString,uint> popularityCount; + QMap<QString, QList<Call*> > byDate; + switch (mode) { + case HistorySortingMode::Date: + foreach (QString cat, m_slHistoryConst) { + byDate[cat] = QList<Call*>(); + } + break; + case HistorySortingMode::Popularity: + foreach (Call* call, calls) { + popularityCount[getIdentity(call)]++; + } + break; + default: + break; + } + foreach (Call* call, calls) { + QString category; + switch (mode) { + case HistorySortingMode::Date: + { + category = timeToHistoryCategory(QDateTime::fromTime_t(call->getStartTimeStamp().toUInt()).date()); + byDate[category] <<call; + } + break; + case HistorySortingMode::Name2: + category = getIdentity(call); + break; + case HistorySortingMode::Popularity: + { + QString identity = getIdentity(call); + category = identity+"("+QString::number(popularityCount[identity])+")"; + } + break; + case HistorySortingMode::Length: + category = "TODO"; + break; + default: + break; + } + call->setProperty("section",category); + } + switch (mode) { + case HistorySortingMode::Date: + calls.clear(); + foreach (QString cat, m_slHistoryConst) { + foreach (Call* call, byDate[cat]) { + calls << call; + } + } + break; + default: + break; + } +} + +CALLMODEL_TEMPLATE void SORTABLE_T::setContactCategory(QList<Contact*> contacts,ContactSortingMode mode) +{ + QHash<Contact*, QDateTime> recentlyUsed; + switch (mode) { + case ContactSortingMode::Recently_used: + recentlyUsed = getContactListByTime(); + foreach (QString cat, m_slHistoryConst) { + //m_pContactView->addCategory(cat); + } + break; + default: + break; + } + foreach (Contact* cont, contacts) { + if (cont->getPhoneNumbers().count() && usableNumberCount(cont)) { + QString category; + switch (mode) { + case ContactSortingMode::Name: + category = QString(cont->getFormattedName()[0]); + break; + case ContactSortingMode::Organisation: + category = (cont->getOrganization().isEmpty())?"Unknow":cont->getOrganization(); + break; + case ContactSortingMode::Recently_used: + if (recentlyUsed.find(cont) != recentlyUsed.end()) + category = timeToHistoryCategory(recentlyUsed[cont].date()); + else + category = m_slHistoryConst[Never]; + break; + case ContactSortingMode::Group: + category = "TODO"; + break; + case ContactSortingMode::Department: + category = (cont->getDepartment().isEmpty())?"Unknow":cont->getDepartment();; + break; + default: + break; + } + } + } +} + +///Return the identity of the call caller, try to return something usefull +CALLMODEL_TEMPLATE QString SORTABLE_T::getIdentity(Call* item) +{ + Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(item->getPeerPhoneNumber()); + if (contact) + return contact->getFormattedName(); + else if (!item->getPeerName().isEmpty()) + return item->getPeerName(); + else + return item->getPeerPhoneNumber(); +} + +CALLMODEL_TEMPLATE int SORTABLE_T::usableNumberCount(Contact* cont) +{ + uint result =0; + QStringList list = ConfigurationSkeleton::phoneTypeList(); + foreach (Contact::PhoneNumber* pn,cont->getPhoneNumbers()) { + result += list.indexOf(pn->getType()) != -1; + } + return result; +} diff --git a/kde/src/klib/dataengine.h b/kde/src/klib/dataengine.h new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/kde/plasma/dataengine/CMakeLists.txt b/kde/src/klib/dataengine/CMakeLists.txt similarity index 64% rename from kde/plasma/dataengine/CMakeLists.txt rename to kde/src/klib/dataengine/CMakeLists.txt index 867b10900d910300e50955897785df5fb46c5f9a..94632a980d0533e4e9244ed7cea09d4b262dfb20 100644 --- a/kde/plasma/dataengine/CMakeLists.txt +++ b/kde/src/klib/dataengine/CMakeLists.txt @@ -13,14 +13,19 @@ include_directories( set(sflphone_engine_SRCS sflphonEngine.cpp + sflphoneService.cpp ) kde4_add_plugin(plasma_engine_sflphone ${sflphone_engine_SRCS}) target_link_libraries(plasma_engine_sflphone qtsflphone + ksflphone ${KDE4_KDECORE_LIBS} - ${KDE4_PLASMA_LIBS}) + ${KDE4_PLASMA_LIBS} + ${KDEPIMLIBS_AKONADI_KMIME_LIBS} + ${KDEPIMLIBS_AKONADI_LIBS} + ${KDEPIMLIBS_AKONADI_CONTACT_LIBS} ) install(TARGETS plasma_engine_sflphone DESTINATION ${PLUGIN_INSTALL_DIR}) @@ -28,4 +33,6 @@ install(TARGETS plasma_engine_sflphone install(FILES plasma-engine-sflphone.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -#TARGET_LINK_LIBRARIES(sflphone-client-kde sflphonekde ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KABC_LIBS}) +install(FILES sflphone.operations + DESTINATION ${DATA_INSTALL_DIR}/plasma/services) + diff --git a/kde/plasma/dataengine/plasma-engine-sflphone.desktop b/kde/src/klib/dataengine/plasma-engine-sflphone.desktop similarity index 100% rename from kde/plasma/dataengine/plasma-engine-sflphone.desktop rename to kde/src/klib/dataengine/plasma-engine-sflphone.desktop diff --git a/kde/plasma/dataengine/plasma-engine-testtime.desktop b/kde/src/klib/dataengine/plasma-engine-testtime.desktop similarity index 100% rename from kde/plasma/dataengine/plasma-engine-testtime.desktop rename to kde/src/klib/dataengine/plasma-engine-testtime.desktop diff --git a/kde/src/klib/dataengine/sflphonEngine.cpp b/kde/src/klib/dataengine/sflphonEngine.cpp new file mode 100644 index 0000000000000000000000000000000000000000..046c24e4f7805bfb2c4d03eb9ba235e76cd3a2d2 --- /dev/null +++ b/kde/src/klib/dataengine/sflphonEngine.cpp @@ -0,0 +1,254 @@ +#include "sflphonEngine.h" + +#include <Plasma/DataContainer> + +#include "../../lib/Call.h" +#include "../../lib/Account.h" +#include "../../lib/AccountList.h" +#include "../../lib/dbus/metatypes.h" +#include "../../lib/instance_interface_singleton.h" +#include "../../lib/configurationmanager_interface_singleton.h" +#include "../../lib/callmanager_interface_singleton.h" +#include "../../lib/sflphone_const.h" +#include "../../klib/AkonadiBackend.h" +#include "../../klib/HelperFunctions.h" +#include "sflphoneService.h"> + +CallModel<>* SFLPhoneEngine::m_pModel = NULL; + +SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args) + : Plasma::DataEngine(parent, args) +{ + Q_UNUSED(args) + if (not m_pModel) { + m_pModel = new CallModel<>(CallModel<>::ActiveCall); + m_pModel->initCall(); + m_pModel->initHistory(); + } + + //CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); + + 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*) )); + connect(AkonadiBackend::getInstance(), SIGNAL( collectionChanged()) , this , SLOT(updateCollection() )); + +} + +bool SFLPhoneEngine::sourceRequestEvent(const QString &name) +{ + if ( name == "history" ) { + updateHistory(); + } + else if ( name == "calls" ) { + updateCallList(); + } + else if ( name == "conferences" ) { + updateConferenceList(); + } + else if ( name == "info" ) { + updateInfo(); + } + else if ( name == "accounts" ) { + updateAccounts(); + } + else if ( name == "contacts" ) { + updateContacts(); + } + return true;//updateSourceEvent(name); +} + +bool SFLPhoneEngine::updateSourceEvent(const QString &name) +{ + Q_UNUSED(name) + return true; +} + +QStringList SFLPhoneEngine::sources() const { + QStringList toReturn; + toReturn << "calls" << "history" << "conferences" << "info" << "accounts" << "contacts"; + return toReturn; +} + +Plasma::Service* SFLPhoneEngine::serviceForSource(const QString &source) +{ + if (source != "calls") { + return 0; + } + + SFLPhoneService *service = new SFLPhoneService(this); + service->setParent(this); + return service; +} + +QString SFLPhoneEngine::getCallStateName(call_state state) +{ + if (state == CALL_STATE_INCOMING) { + return I18N_NOOP("Ringing (in)"); + } else if (state == CALL_STATE_RINGING) { + return I18N_NOOP("Ringing (out)"); + } else if (state == CALL_STATE_CURRENT) { + return I18N_NOOP("Talking"); + } else if (state == CALL_STATE_DIALING) { + return I18N_NOOP("Dialing"); + } else if (state == CALL_STATE_HOLD) { + return I18N_NOOP("Hold"); + } else if (state == CALL_STATE_FAILURE) { + return I18N_NOOP("Failed"); + } else if (state == CALL_STATE_BUSY) { + return I18N_NOOP("Busy"); + } else if (state == CALL_STATE_TRANSFER) { + return I18N_NOOP("Transfer"); + } else if (state == CALL_STATE_TRANSF_HOLD) { + return I18N_NOOP("Transfer hold"); + } else if (state == CALL_STATE_OVER) { + return I18N_NOOP("Over"); + } else if (state == CALL_STATE_ERROR) { + return I18N_NOOP("Error"); + } + return ""; +} + +void SFLPhoneEngine::updateHistory() +{ + CallList list = m_pModel->getHistory().values(); + setHistoryCategory(list,HistorySortingMode::Date); + + foreach (Call* oldCall, list) { + qDebug() << oldCall->getStopTimeStamp(); + historyCall[oldCall->getCallId()][ "peerName" ] = oldCall->getPeerName(); + historyCall[oldCall->getCallId()][ "peerNumber" ] = oldCall->getPeerPhoneNumber(); + historyCall[oldCall->getCallId()][ "length" ] = oldCall->getStopTimeStamp().toInt() - oldCall->getStartTimeStamp().toInt(); + historyCall[oldCall->getCallId()][ "date" ] = oldCall->getStopTimeStamp(); + if (oldCall->property("section").isValid()) + historyCall[oldCall->getCallId()][ "section" ] = oldCall->property("section"); + setData("history", oldCall->getCallId() , historyCall[oldCall->getCallId()]); + } +} + +void SFLPhoneEngine::updateCallList() +{ + foreach (Call* call, m_pModel->getCalls()) { + if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) { + currentCall[call->getCallId()][ "peerName" ] = call->getPeerName(); + currentCall[call->getCallId()][ "peerNumber" ] = call->getPeerPhoneNumber(); + currentCall[call->getCallId()][ "stateName" ] = getCallStateName(call->getState()); + currentCall[call->getCallId()][ "state" ] = call->getState(); + setData("calls", call->getCallId(), currentCall[call->getCallId()]); + } + } +} + +void SFLPhoneEngine::updateConferenceList() +{ + 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()]); + } + } +} + +void SFLPhoneEngine::updateCollection() +{ + + typedef QHash<QString,QVariant> SerializedContact; + ContactList list = AkonadiBackend::getInstance()->update(); + if (!list.size()) + return; + ContactHash hash = HelperFunctions::toHash(list); + foreach (SerializedContact cont, hash) { + if (!m_hContacts[hash.key(cont)].size()) { + m_hContacts[hash.key(cont)] = cont; + } + // + } + removeAllData("contacts"); + int i=0; + foreach (SerializedContact cont, m_hContacts) { + cont["section"] = "test"; + setData("contacts", QString::number(i), QVariant(cont)); + i++; + } +} + +void SFLPhoneEngine::updateContacts() +{ + QHash<QString,QVariant> test; + test[ "nickName" ] = ""; + test[ "firstName" ] = ""; + test[ "secondName" ] = ""; + test[ "formattedName" ] = ""; + test[ "organization" ] = ""; + test[ "Uid" ] = ""; + test[ "preferredEmail" ] = ""; + test[ "type" ] = ""; + test[ "group" ] = ""; + test[ "department" ] = ""; + setData("contacts", "fake",test ); +} + +void SFLPhoneEngine::updateInfo() +{ + setData("info", I18N_NOOP("Current_account"), m_pModel->getCurrentAccountId()); +} + +void SFLPhoneEngine::updateAccounts() +{ + const QVector<Account*>& list = m_pModel->getAccountList()->getAccounts(); + foreach(Account* a,list) { + setData("accounts", a->getAccountDetail(ACCOUNT_ALIAS), a->getAccountId()); + } +} + +void SFLPhoneEngine::callStateChangedSignal(Call* call) +{ + Q_UNUSED(call) + updateCallList(); +} + +void SFLPhoneEngine::incomingCallSignal(Call* call) +{ + Q_UNUSED(call) + updateCallList(); +} + +void SFLPhoneEngine::conferenceCreatedSignal(Call* conf) +{ + Q_UNUSED(conf) + updateConferenceList(); +} + +void SFLPhoneEngine::conferenceChangedSignal(Call* conf) +{ + Q_UNUSED(conf) + updateConferenceList(); +} + +void SFLPhoneEngine::incomingMessageSignal(const QString& accountId, const QString& message) +{ + Q_UNUSED(accountId) + Q_UNUSED(message) + //TODO +} + +void SFLPhoneEngine::voiceMailNotifySignal(const QString& accountId, int count) +{ + Q_UNUSED(accountId) + Q_UNUSED(count) + //TODO +} + +void SFLPhoneEngine::accountChanged() +{ + +} + +CallModel<>* SFLPhoneEngine::getModel() +{ + return m_pModel; +} + +K_EXPORT_PLASMA_DATAENGINE(sflphone, SFLPhoneEngine) diff --git a/kde/plasma/dataengine/sflphonEngine.h b/kde/src/klib/dataengine/sflphonEngine.h similarity index 77% rename from kde/plasma/dataengine/sflphonEngine.h rename to kde/src/klib/dataengine/sflphonEngine.h index 9a234f254094761e2d0e6db71e2968f05999f0da..47370f3065ebfaa6671d5fcc08aec33dc0e04448 100644 --- a/kde/plasma/dataengine/sflphonEngine.h +++ b/kde/src/klib/dataengine/sflphonEngine.h @@ -22,37 +22,48 @@ #define SFLPHONEENGINE_H #include <Plasma/DataEngine> +#include <Plasma/Service> #include <QHash> -#include "../../src/lib/CallModel.h" +#include "../../lib/CallModel.h" +#include "../SortableDockCommon.h" typedef QHash<QString,QVariant> HashStringString; +typedef QHash<QString,QHash<QString,QVariant> > ContactHash; class Call; -class SFLPhoneEngine : public Plasma::DataEngine +class SFLPhoneEngine : public Plasma::DataEngine,public SortableDockCommon<> { Q_OBJECT public: SFLPhoneEngine(QObject* parent, const QVariantList& args); + Plasma::Service *serviceForSource(const QString &source); virtual QStringList sources() const; + static CallModel<>* getModel(); + + friend class SFLPhoneService; + protected: bool sourceRequestEvent(const QString& name); bool updateSourceEvent(const QString& source); private: - QHash<QString, HashStringString > historyCall ; - QHash<QString, HashStringString > currentCall ; - QHash<QString, QStringList> currentConferences ; - CallModelConvenience* m_pModel; + QHash<QString, HashStringString > historyCall ; + QHash<QString, HashStringString > currentCall ; + QHash<QString, QStringList> currentConferences ; + static CallModel<>* m_pModel ; + ContactHash m_hContacts ; QString getCallStateName(call_state state); void updateHistory (); void updateCallList (); - void updateContacts (); + void updateAccounts (); void updateConferenceList (); + void updateContacts (); void updateInfo(); private slots: + void updateCollection(); void callStateChangedSignal (Call* call); void incomingCallSignal (Call* conf); void conferenceCreatedSignal (Call* conf); diff --git a/kde/src/klib/dataengine/sflphone.operations b/kde/src/klib/dataengine/sflphone.operations new file mode 100644 index 0000000000000000000000000000000000000000..f80ca1c77835731302c6ce6301126f2d1f5b45eb --- /dev/null +++ b/kde/src/klib/dataengine/sflphone.operations @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE kcfg SYSTEM + "http://www.kde.org/standards/kcfg/1.0/kcfg.xsd"> +<kcfg> + <group name="Call"> + <entry name="AccountId" type="String"> + <label>Account id to make this call</label> + </entry> + <entry name="Number" type="String"> + <label>Number to call</label> + </entry> + </group> +</kcfg> diff --git a/kde/src/klib/dataengine/sflphoneService.cpp b/kde/src/klib/dataengine/sflphoneService.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9a0e455f2fb8318e0890c9c60ac60556abcb3ba1 --- /dev/null +++ b/kde/src/klib/dataengine/sflphoneService.cpp @@ -0,0 +1,23 @@ +#include "sflphoneService.h" + +#include "../../lib/Call.h" + +SFLPhoneService::SFLPhoneService(SFLPhoneEngine *engine) + +{ + m_engine = engine; + setName("sflphone"); +} + +ServiceJob *SFLPhoneService::createJob(const QString &operation, QMap<QString, QVariant> ¶meters) +{ + if (!m_engine) { + return 0; + } + + if (operation == "Call") { + return new CallJob(this, operation,parameters); + } + m_engine->setData(operation, parameters["query"]); + return 0; +} \ No newline at end of file diff --git a/kde/src/klib/dataengine/sflphoneService.h b/kde/src/klib/dataengine/sflphoneService.h new file mode 100644 index 0000000000000000000000000000000000000000..bca8880bfbe0beaa42f57fdf77dc59db7da62a64 --- /dev/null +++ b/kde/src/klib/dataengine/sflphoneService.h @@ -0,0 +1,49 @@ +#ifndef SFLPHONE_SERVICE_H +#define SFLPHONE_SERVICE_H + +#include "sflphonEngine.h" + +#include <Plasma/Service> +#include <Plasma/ServiceJob> + +#include "../../lib/Call.h" +#include "../../lib/CallModel.h" + +using namespace Plasma; + +class SFLPhoneService : public Plasma::Service +{ + Q_OBJECT + +public: + SFLPhoneService(SFLPhoneEngine *engine); + ServiceJob *createJob(const QString &operation, QMap<QString, QVariant> ¶meters); + +private: + SFLPhoneEngine *m_engine; + +}; + +class CallJob : public Plasma::ServiceJob +{ + Q_OBJECT +public: + CallJob(QObject* parent, const QString& operation, const QVariantMap& parameters = QVariantMap()) + : Plasma::ServiceJob("", operation, parameters, parent) + , m_AccountId ( parameters[ "AccountId" ].toString() ) + , m_Number ( parameters[ "Number" ].toString() ) + {} + + void start() + { + Call* call = SFLPhoneEngine::getModel()->addDialingCall("112",m_AccountId); + call->setCallNumber(m_Number); + call->actionPerformed(CALL_ACTION_ACCEPT); + } + +private: + QString m_AccountId; + QString m_Number; +}; + +#endif //SFLPHONE_SERVICE_H diff --git a/kde/src/conf/kcfg_settings.kcfgc b/kde/src/klib/kcfg_settings.kcfgc similarity index 61% rename from kde/src/conf/kcfg_settings.kcfgc rename to kde/src/klib/kcfg_settings.kcfgc index b14ca1863f8e830d10729b176f512a36358b339b..d64e6e44c5aca7b83f34998d1795e2ef470e1c44 100755 --- a/kde/src/conf/kcfg_settings.kcfgc +++ b/kde/src/klib/kcfg_settings.kcfgc @@ -3,3 +3,5 @@ File=sflphone-client-kde.kcfg ClassName=ConfigurationSkeletonBase Singleton=true Mutators=true +Visibility=LIB_EXPORT +IncludeFiles=\"../src/lib/typedefs.h\" \ No newline at end of file diff --git a/kde/src/conf/sflphone-client-kde.kcfg b/kde/src/klib/sflphone-client-kde.kcfg similarity index 100% rename from kde/src/conf/sflphone-client-kde.kcfg rename to kde/src/klib/sflphone-client-kde.kcfg diff --git a/kde/src/lib/CMakeLists.txt b/kde/src/lib/CMakeLists.txt index f0c574c9d0f4296a9c5fc15b43dd237ab1cdfe76..3db06e46222025221271cb49ff41cf8d14a01202 100644 --- a/kde/src/lib/CMakeLists.txt +++ b/kde/src/lib/CMakeLists.txt @@ -20,7 +20,7 @@ FIND_PACKAGE ( Qt4 REQUIRED ) INCLUDE ( KDE4Defaults ) -set(GENERIC_LIB_VERSION "1.0.2") +set(GENERIC_LIB_VERSION "1.1.0") INCLUDE_DIRECTORIES ( ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/kde/src/lib/Call.cpp b/kde/src/lib/Call.cpp index d700174dda1cbecba349c2566486c3d942a90eda..b1683e4b4a22008fbb906172fff0a4d936f755f6 100644 --- a/kde/src/lib/Call.cpp +++ b/kde/src/lib/Call.cpp @@ -471,6 +471,12 @@ void Call::setRecordingPath(const QString& path) m_RecordingPath = path; } +///Set peer name +void Call::setPeerName(const QString& name) +{ + m_PeerName = name; +} + /***************************************************************************** * * * Mutator * @@ -625,7 +631,7 @@ void Call::call() qDebug() << "account = " << m_Account; if(m_Account.isEmpty()) { qDebug() << "Account is not set, taking the first registered."; - this->m_Account = CallModelConvenience::getCurrentAccountId(); + this->m_Account = CallModel<>::getCurrentAccountId(); } if(!m_Account.isEmpty()) { qDebug() << "Calling " << m_CallNumber << " with account " << m_Account << ". callId : " << m_CallId; diff --git a/kde/src/lib/Call.h b/kde/src/lib/Call.h index 4d763bf472382627dd873f99db678a8a7d3891f5..ad2fbdc004fedf5bd57fa8549ee36db4b2183bde 100644 --- a/kde/src/lib/Call.h +++ b/kde/src/lib/Call.h @@ -158,11 +158,12 @@ public: call_state actionPerformed(call_action action); //Setters - void setConference(bool value); - void setConfId(QString value); - void setTransferNumber(const QString& number); - void setCallNumber(const QString& number); - void setRecordingPath(const QString& path); + void setConference ( bool value ); + void setConfId ( QString value ); + void setTransferNumber ( const QString& number ); + void setCallNumber ( const QString& number ); + void setRecordingPath ( const QString& path ); + void setPeerName ( const QString& name ); //Mutators void appendText(const QString& str); diff --git a/kde/src/lib/CallModel.h b/kde/src/lib/CallModel.h index 3346f93d6c3921466fda1f999ee6f14150436004..d5654546c3c3fae720be34358874229956e48e23 100644 --- a/kde/src/lib/CallModel.h +++ b/kde/src/lib/CallModel.h @@ -23,6 +23,8 @@ #include <QObject> #include <QVector> +#include <QWidget> +#include <QModelIndex> #include <QMap> #include "typedefs.h" @@ -86,7 +88,7 @@ signals: * solution may be less "clean" than MVC, but is 3 time smaller and easier to improve (in fact, possible to improve). */ ///@class CallModel Central model/frontend to deal with sflphoned -template <typename CallWidget, typename Index> +template <typename CallWidget = QWidget*, typename Index = QModelIndex*> class LIB_EXPORT CallModel : public CallModelBase { public: enum ModelType { @@ -126,11 +128,11 @@ class LIB_EXPORT CallModel : public CallModelBase { void removeConference ( Call* call ); //Getters - int size (); - CallList getCallList (); - static const CallMap& getHistory (); - static const QStringList getNumbersByPopularity (); - static const QStringList getHistoryCallId (); + int size (); + CallList getCallList (); + static const CallMap& getHistory (); + static const QStringList getNumbersByPopularity (); + static const QStringList getHistoryCallId (); //Account related static Account* getCurrentAccount ( ); @@ -212,11 +214,11 @@ class LIB_EXPORT CallModel : public CallModelBase { bool updateCommon (Call* call); }; -class CallModelConvenience : public CallModel<QWidget*,QModelIndex*> +/*class CallModelConvenience : public CallModel<QWidget*,QModelIndex*> { public: CallModelConvenience(ModelType type) : CallModel<QWidget*,QModelIndex*>(type) {} -}; +};*/ #include "CallModel.hpp" diff --git a/kde/src/lib/CallModel.hpp b/kde/src/lib/CallModel.hpp index cff7ce9808ea661e696bac41aa5885e1b15e86b6..43b667221cb0dcd8f1337a302d0f05f2346fa080 100644 --- a/kde/src/lib/CallModel.hpp +++ b/kde/src/lib/CallModel.hpp @@ -38,20 +38,24 @@ //System #include "unistd.h" +//Define +#define CALLMODEL_TEMPLATE template<typename CallWidget, typename Index> +#define CALLMODEL_T CallModel<CallWidget,Index> + //Static member -template <typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::m_sPriorAccountId = "" ; -template <typename CallWidget, typename Index> AccountList* CallModel<CallWidget,Index>::m_spAccountList = 0 ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_sInstanceInit = false ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_sCallInit = false ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_sHistoryInit = false ; +CALLMODEL_TEMPLATE QString CALLMODEL_T::m_sPriorAccountId = "" ; +CALLMODEL_TEMPLATE AccountList* CALLMODEL_T::m_spAccountList = 0 ; +CALLMODEL_TEMPLATE bool CALLMODEL_T::m_sInstanceInit = false ; +CALLMODEL_TEMPLATE bool CALLMODEL_T::m_sCallInit = false ; +CALLMODEL_TEMPLATE bool CALLMODEL_T::m_sHistoryInit = false ; -template <typename CallWidget, typename Index> CallMap CallModel<CallWidget,Index>::m_sActiveCalls ; -template <typename CallWidget, typename Index> CallMap CallModel<CallWidget,Index>::m_sHistoryCalls ; +CALLMODEL_TEMPLATE CallMap CALLMODEL_T::m_sActiveCalls ; +CALLMODEL_TEMPLATE CallMap CALLMODEL_T::m_sHistoryCalls ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalCall CallModel<CallWidget,Index>::m_sPrivateCallList_call ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalCallId CallModel<CallWidget,Index>::m_sPrivateCallList_callId ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalIndex CallModel<CallWidget,Index>::m_sPrivateCallList_index ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalWidget CallModel<CallWidget,Index>::m_sPrivateCallList_widget ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalCall CALLMODEL_T::m_sPrivateCallList_call ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalCallId CALLMODEL_T::m_sPrivateCallList_callId ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalIndex CALLMODEL_T::m_sPrivateCallList_index ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalWidget CALLMODEL_T::m_sPrivateCallList_widget ; /***************************************************************************** * * @@ -81,7 +85,7 @@ inline bool operator< (const SortableCallSource & s1, const SortableCallSource & ****************************************************************************/ ///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop -template<typename CallWidget, typename Index> CallModel<CallWidget,Index>::CallModel(ModelType type) : CallModelBase(0) +CALLMODEL_TEMPLATE CALLMODEL_T::CallModel(ModelType type) : CallModelBase(0) { Q_UNUSED(type) init(); @@ -89,7 +93,7 @@ template<typename CallWidget, typename Index> CallModel<CallWidget,Index>::CallM } ///Open the connection to the daemon and register this client -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::init() +CALLMODEL_TEMPLATE bool CALLMODEL_T::init() { if (!m_sInstanceInit) { registerCommTypes(); @@ -106,7 +110,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ///Fill the call list ///@warning This solution wont scale to multiple call or history model implementation. Some static addCall + foreach for each call would be needed if this case ever become unavoidable -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::initCall() +CALLMODEL_TEMPLATE bool CALLMODEL_T::initCall() { if (!m_sCallInit) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -127,14 +131,14 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Set how the call can find more informations about the call it receive -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::initContact ( ContactBackend* be ) +CALLMODEL_TEMPLATE void CALLMODEL_T::initContact ( ContactBackend* be ) { Call::setContactBackend(be); } ///Fill the history list ///@warning This solution wont scale to multiple call or history model implementation. Some static addCall + foreach for each call would be needed if this case ever become unavoidable -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::initHistory() +CALLMODEL_TEMPLATE bool CALLMODEL_T::initHistory() { if (!m_sHistoryInit) { ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -149,6 +153,9 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: hc[ PEER_NUMBER_KEY ] , hc[ STATE_KEY ] ); + if (pastCall->getPeerName().isEmpty()) { + pastCall->setPeerName("Unknow"); + } pastCall->setRecordingPath(hc[ RECORDING_PATH_KEY ]); m_sHistoryCalls[ hc[TIMESTAMP_START_KEY ]] = pastCall; addCall(pastCall); @@ -167,19 +174,19 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ****************************************************************************/ ///Return the active call count -template<typename CallWidget, typename Index> int CallModel<CallWidget,Index>::size() +CALLMODEL_TEMPLATE int CALLMODEL_T::size() { return m_sActiveCalls.size(); } ///Return a call corresponding to this ID or NULL -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::findCallByCallId(const QString& callId) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::findCallByCallId(const QString& callId) { return m_sActiveCalls[callId]; } ///Return the action call list -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCallList() +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCallList() { QList<Call*> callList; foreach(Call* call, m_sActiveCalls) { @@ -196,7 +203,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, ****************************************************************************/ ///Add a call in the model structure, the call must exist before being added to the model -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCall(Call* call, Call* parent) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addCall(Call* call, Call* parent) { Q_UNUSED(parent) if (!call) @@ -215,7 +222,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Common set of instruction shared by all call adder -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCallCommon(Call* call) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addCallCommon(Call* call) { m_sActiveCalls[call->getCallId()] = call; addCall(call); @@ -224,7 +231,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Create a new dialing call from peer name and the account ID -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addDialingCall(const QString& peerName, QString account) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addDialingCall(const QString& peerName, QString account) { QString account2 = account; if (account2.isEmpty()) { @@ -236,21 +243,21 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Create a new incomming call when the daemon is being called -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addIncomingCall(const QString& callId) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addIncomingCall(const QString& callId) { Call* call = Call::buildIncomingCall(callId); return addCallCommon(call); } ///Create a ringing call -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addRingingCall(const QString& callId) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addRingingCall(const QString& callId) { Call* call = Call::buildRingingCall(callId); return addCallCommon(call); } ///Generate a new random call unique identifier (callId) -template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::generateCallId() +CALLMODEL_TEMPLATE QString CALLMODEL_T::generateCallId() { int id = qrand(); QString res = QString::number(id); @@ -258,7 +265,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index } ///Remove a call and update the internal structure -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::removeCall(Call* call) +CALLMODEL_TEMPLATE void CALLMODEL_T::removeCall(Call* call) { InternalStruct* internal = m_sPrivateCallList_call[call]; @@ -285,7 +292,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: } ///Transfer "toTransfer" to "target" and wait to see it it succeeded -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::attendedTransfer(Call* toTransfer, Call* target) +CALLMODEL_TEMPLATE void CALLMODEL_T::attendedTransfer(Call* toTransfer, Call* target) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); callManager.attendedTransfer(toTransfer->getCallId(),target->getCallId()); @@ -296,7 +303,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: } ///Transfer this call to "target" number -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::transfer(Call* toTransfer, QString target) +CALLMODEL_TEMPLATE void CALLMODEL_T::transfer(Call* toTransfer, QString target) { qDebug() << "Transferring call " << toTransfer->getCallId() << "to" << target; toTransfer->setTransferNumber(target); @@ -312,7 +319,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ****************************************************************************/ ///Add a new conference, get the call list and update the interface as needed -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addConference(const QString & confID) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addConference(const QString & confID) { qDebug() << "Notified of a new conference " << confID; CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -341,7 +348,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Join two call to create a conference, the conference will be created later (see addConference) -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::createConferenceFromCall(Call* call1, Call* call2) +CALLMODEL_TEMPLATE bool CALLMODEL_T::createConferenceFromCall(Call* call1, Call* call2) { qDebug() << "Joining call: " << call1->getCallId() << " and " << call2->getCallId(); CallManagerInterface &callManager = CallManagerInterfaceSingleton::getInstance(); @@ -350,7 +357,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Add a new participant to a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::addParticipant(Call* call2, Call* conference) +CALLMODEL_TEMPLATE bool CALLMODEL_T::addParticipant(Call* call2, Call* conference) { if (conference->isConference()) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -364,7 +371,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Remove a participant from a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::detachParticipant(Call* call) +CALLMODEL_TEMPLATE bool CALLMODEL_T::detachParticipant(Call* call) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); callManager.detachParticipant(call->getCallId()); @@ -372,7 +379,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Merge two conferences -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::mergeConferences(Call* conf1, Call* conf2) +CALLMODEL_TEMPLATE bool CALLMODEL_T::mergeConferences(Call* conf1, Call* conf2) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); callManager.joinConference(conf1->getConfId(),conf2->getConfId()); @@ -380,7 +387,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Executed when the daemon signal a modification in an existing conference. Update the call list and update the TreeView -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::changeConference(const QString& confId, const QString& state) +CALLMODEL_TEMPLATE bool CALLMODEL_T::changeConference(const QString& confId, const QString& state) { qDebug() << "Conf changed"; Q_UNUSED(state) @@ -398,14 +405,14 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Remove a conference from the model and the TreeView -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::removeConference(const QString &confId) +CALLMODEL_TEMPLATE void CALLMODEL_T::removeConference(const QString &confId) { qDebug() << "Ending conversation containing " << m_sPrivateCallList_callId[confId]->children.size() << " participants"; removeConference(getCall(confId)); } ///Remove a conference using it's call object -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::removeConference(Call* call) +CALLMODEL_TEMPLATE void CALLMODEL_T::removeConference(Call* call) { InternalStruct* internal = m_sPrivateCallList_call[call]; @@ -424,7 +431,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ****************************************************************************/ ///Return a list of all previous calls -template<typename CallWidget, typename Index> const QStringList CallModel<CallWidget,Index>::getHistoryCallId() +CALLMODEL_TEMPLATE const QStringList CALLMODEL_T::getHistoryCallId() { QStringList toReturn; foreach(Call* call, m_sHistoryCalls) { @@ -434,13 +441,13 @@ template<typename CallWidget, typename Index> const QStringList CallModel<CallWi } ///Return the history list -template<typename CallWidget, typename Index> const CallMap& CallModel<CallWidget,Index>::getHistory() +CALLMODEL_TEMPLATE const CallMap& CALLMODEL_T::getHistory() { return m_sHistoryCalls; } ///Add to history -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::addToHistory(Call* call) +CALLMODEL_TEMPLATE void CALLMODEL_T::addToHistory(Call* call) { if (call) { m_sHistoryCalls[call->getStartTimeStamp()] = call; @@ -448,7 +455,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: } ///Sort all history call by popularity and return the result (most popular first) -template<typename CallWidget, typename Index> const QStringList CallModel<CallWidget,Index>::getNumbersByPopularity() +CALLMODEL_TEMPLATE const QStringList CALLMODEL_T::getNumbersByPopularity() { QHash<QString,SortableCallSource*> hc; foreach (Call* call, getHistory()) { @@ -481,7 +488,7 @@ template<typename CallWidget, typename Index> const QStringList CallModel<CallWi ****************************************************************************/ ///Return the current account id (do not put in the cpp file) -template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::getCurrentAccountId() +CALLMODEL_TEMPLATE QString CALLMODEL_T::getCurrentAccountId() { Account* firstRegistered = getCurrentAccount(); if(firstRegistered == NULL) { @@ -494,7 +501,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index ///Return the current account -template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Index>::getCurrentAccount() +CALLMODEL_TEMPLATE Account* CALLMODEL_T::getCurrentAccount() { Account* priorAccount = getAccountList()->getAccountById(m_sPriorAccountId); if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED ) { @@ -507,7 +514,7 @@ template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Inde } ///Return a list of registered accounts -template<typename CallWidget, typename Index> AccountList* CallModel<CallWidget,Index>::getAccountList() +CALLMODEL_TEMPLATE AccountList* CALLMODEL_T::getAccountList() { if (m_spAccountList == NULL) { m_spAccountList = new AccountList(true); @@ -516,13 +523,13 @@ template<typename CallWidget, typename Index> AccountList* CallModel<CallWidget, } ///Return the previously used account ID -template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::getPriorAccoundId() +CALLMODEL_TEMPLATE QString CALLMODEL_T::getPriorAccoundId() { return m_sPriorAccountId; } ///Set the previous account used -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::setPriorAccountId(const QString& value) { +CALLMODEL_TEMPLATE void CALLMODEL_T::setPriorAccountId(const QString& value) { m_sPriorAccountId = value; } @@ -533,7 +540,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ****************************************************************************/ ///Get a call from it's widget -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const CallWidget widget ) const +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->call_real; @@ -542,7 +549,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Get a call list from a conference -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const CallWidget widget ) const +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const CallWidget widget ) const { QList<Call*> toReturn; if (m_sPrivateCallList_widget[widget] && m_sPrivateCallList_widget[widget]->conference) { @@ -554,7 +561,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Get a list of every call -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( ) +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( ) { QList<Call*> toReturn; foreach (InternalStruct* child, m_sPrivateCallList_call) { @@ -564,7 +571,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Is the call associated with that widget a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const CallWidget widget ) const +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->conference; @@ -573,7 +580,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Is that call a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const Call* call ) const +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const Call* call ) const { if (m_sPrivateCallList_call[(Call*)call]) { return m_sPrivateCallList_call[(Call*)call]->conference; @@ -582,13 +589,13 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Do nothing, provided for API consistency -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const Call* call ) const +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const Call* call ) const { return call; } ///Return the calls from the "call" conference -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const Call* call ) const +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const Call* call ) const { QList<Call*> toReturn; if (m_sPrivateCallList_call[call] && m_sPrivateCallList_call[call]->conference) { @@ -600,7 +607,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Is the call associated with that Index a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const Index idx ) const +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->conference; @@ -609,7 +616,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Get the call associated with this index -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const Index idx ) const +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->call_real; @@ -619,7 +626,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Get the call associated with that conference index -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const Index idx ) const +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const Index idx ) const { QList<Call*> toReturn; if (m_sPrivateCallList_index[idx] && m_sPrivateCallList_index[idx]->conference) { @@ -631,7 +638,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Is the call associated with that ID a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const QString& callId ) const +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const QString& callId ) const { if (m_sPrivateCallList_callId[callId]) { return m_sPrivateCallList_callId[callId]->conference; @@ -640,7 +647,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Get the call associated with this ID -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const QString& callId ) const +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const QString& callId ) const { if (m_sPrivateCallList_callId[callId]) { return m_sPrivateCallList_callId[callId]->call_real; @@ -649,7 +656,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Get the calls associated with this ID -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const QString& callId ) const +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const QString& callId ) const { QList<Call*> toReturn; if (m_sPrivateCallList_callId[callId] && m_sPrivateCallList_callId[callId]->conference) { @@ -661,7 +668,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Get the index associated with this call -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const Call* call ) const +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const Call* call ) const { if (m_sPrivateCallList_call[(Call*)call]) { return m_sPrivateCallList_call[(Call*)call]->index; @@ -670,7 +677,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the index associated with this index (dummy implementation) -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const Index idx ) const +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->index; @@ -679,7 +686,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the index associated with this call -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const CallWidget widget ) const +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->index; @@ -688,7 +695,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the index associated with this ID -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const QString& callId ) const +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const QString& callId ) const { if (m_sPrivateCallList_callId[callId]) { return m_sPrivateCallList_callId[callId]->index; @@ -697,7 +704,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the widget associated with this call -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const Call* call ) const +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const Call* call ) const { if (m_sPrivateCallList_call[call]) { return m_sPrivateCallList_call[call]->call; @@ -706,7 +713,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Get the widget associated with this ID -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const Index idx ) const +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->call; @@ -715,7 +722,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Get the widget associated with this widget (dummy) -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const CallWidget widget ) const +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->call; @@ -724,7 +731,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Get the widget associated with this ID -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const QString& widget ) const +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const QString& widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->call; @@ -733,7 +740,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Common set of instruction shared by all gui updater -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateCommon(Call* call) +CALLMODEL_TEMPLATE bool CALLMODEL_T::updateCommon(Call* call) { if (!m_sPrivateCallList_call[call] && dynamic_cast<Call*>(call)) { m_sPrivateCallList_call [ call ] = new InternalStruct ; @@ -747,7 +754,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Update the widget associated with this call -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateWidget (Call* call, CallWidget value ) +CALLMODEL_TEMPLATE bool CALLMODEL_T::updateWidget (Call* call, CallWidget value ) { if (!updateCommon(call)) return false; m_sPrivateCallList_call[call]->call = value ; @@ -756,7 +763,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Update the index associated with this call -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateIndex (Call* call, Index value ) +CALLMODEL_TEMPLATE bool CALLMODEL_T::updateIndex (Call* call, Index value ) { updateCommon(call); m_sPrivateCallList_call[call]->index = value ; diff --git a/kde/src/lib/Contact.cpp b/kde/src/lib/Contact.cpp index 6aa277e09460954b5434c8601b509327a19e213e..ce53582cb4a15610822ae89fdeea38205fc087f2 100644 --- a/kde/src/lib/Contact.cpp +++ b/kde/src/lib/Contact.cpp @@ -150,7 +150,7 @@ void Contact::setFamilyName(const QString& name) ///Set the Photo/Avatar void Contact::setPhoto(QPixmap* photo) { - m_pPhoto = photo; + m_pPhoto = photo; } ///Set the formatted name (display name) @@ -187,4 +187,23 @@ void Contact::setGroup(const QString& name) void Contact::setDepartment(const QString& name) { m_Department = name; +} + +///Turn the contact into QString-QString hash +QHash<QString,QVariant> Contact::toHash() +{ + QHash<QString,QVariant> aContact; + //aContact[""] = PhoneNumbers getPhoneNumbers() const; + aContact[ "nickName" ] = getNickName(); + aContact[ "firstName" ] = getFirstName(); + aContact[ "secondName" ] = getSecondName(); + aContact[ "formattedName" ] = getFormattedName(); + aContact[ "organization" ] = getOrganization(); + aContact[ "Uid" ] = getUid(); + aContact[ "preferredEmail" ] = getPreferredEmail(); + //aContact["Photo"] = getPhoto( const; + aContact[ "type" ] = getType(); + aContact[ "group" ] = getGroup(); + aContact[ "department" ] = getDepartment(); + return aContact; } \ No newline at end of file diff --git a/kde/src/lib/Contact.h b/kde/src/lib/Contact.h index 0e23260292183429759f88788e3bab275335e4be..c13a6e0d01b25b5191564fccfda7c8a497960d79 100644 --- a/kde/src/lib/Contact.h +++ b/kde/src/lib/Contact.h @@ -21,7 +21,8 @@ #ifndef CONTACT_H #define CONTACT_H -#include <QObject> +#include <QtCore/QObject> +#include <QtCore/QVariant> //Qt class QListWidgetItem; @@ -106,6 +107,9 @@ public: virtual void setDepartment ( const QString& name ); virtual void setUid ( const QString& id ); virtual void setPhoto ( QPixmap* photo ); + + //Mutator + QHash<QString,QVariant> toHash(); protected: virtual void initItemWidget(); diff --git a/kde/src/lib/ContactBackend.h b/kde/src/lib/ContactBackend.h index 66d65cd8dae12ed87942f5bc46c2daab109e9995..64ad72cca992066de42adf718fc3d821d7bbdfc7 100644 --- a/kde/src/lib/ContactBackend.h +++ b/kde/src/lib/ContactBackend.h @@ -24,12 +24,16 @@ #include <QObject> #include <QHash> +#include <QStringList> +#include <QVariant> #include "typedefs.h" +#include "Contact.h" //SFLPhone class Contact; +//Typedef typedef QList<Contact*> ContactList; ///@class ContactBackend Allow different way to handle contact without poluting the library diff --git a/kde/src/main.cpp b/kde/src/main.cpp index f91419b4ffb3540ee6335b4d9b6c4160bbab439c..69053c16b48251e16f31e442224e22fe8ed3652f 100755 --- a/kde/src/main.cpp +++ b/kde/src/main.cpp @@ -41,7 +41,7 @@ #include "AccountWizard.h" #include "SFLPhoneapplication.h" #include "conf/ConfigurationDialog.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "CallView.h" #include "SFLPhone.h" #include "AccountListModel.h" diff --git a/kde/src/widgets/BookmarkDock.cpp b/kde/src/widgets/BookmarkDock.cpp index 4b6722456b3dc4d9af6149ba02d805b1e34ee343..cd4a08861379376ba81439494d3297058ffe7e84 100644 --- a/kde/src/widgets/BookmarkDock.cpp +++ b/kde/src/widgets/BookmarkDock.cpp @@ -35,12 +35,12 @@ #include <KLineEdit> //SFLPhone -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "widgets/HistoryTreeItem.h" #include "SFLPhone.h" #include "widgets/CategoryDrawer.h" #include "widgets/CategorizedTreeWidget.h" -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" ///@class QNumericTreeWidgetItem : Tree widget with different sorting criterias class QNumericTreeWidgetItem : public QTreeWidgetItem { diff --git a/kde/src/widgets/CallTreeItem.cpp b/kde/src/widgets/CallTreeItem.cpp index 9ea46ccc42c5ec81f937287098a773adb8967a17..041ddaae881455186e99daea9fbf569b9b095448 100644 --- a/kde/src/widgets/CallTreeItem.cpp +++ b/kde/src/widgets/CallTreeItem.cpp @@ -48,7 +48,7 @@ #include "lib/Call.h" //SFLPhone -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" #include "widgets/TranslucentButtons.h" #include "SFLPhone.h" diff --git a/kde/src/widgets/ContactDock.cpp b/kde/src/widgets/ContactDock.cpp index 6003df1fed88ff9f63e1ec7902ea585c9a741bd7..349be089f88c4354433e7dec2d28ce51404e426d 100644 --- a/kde/src/widgets/ContactDock.cpp +++ b/kde/src/widgets/ContactDock.cpp @@ -40,10 +40,10 @@ #include <KIcon> //SFLPhone -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" #include "ContactItemWidget.h" #include "SFLPhone.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/ConfigurationSkeleton.h" #include "CallView.h" #include "SFLPhoneView.h" @@ -74,15 +74,6 @@ class QNumericTreeWidgetItem_hist : public QTreeWidgetItem { } }; -///@enum SortingMode Available sorting mode -enum SortingMode { - Name , - Organisation , - Recently_used , - Group , - Department -}; - ///Forward keypresses to the filter line edit bool KeyPressEaterC::eventFilter(QObject *obj, QEvent *event) { @@ -390,13 +381,3 @@ void ContactDock::keyPressEvent(QKeyEvent* event) { * Helpers * * * ****************************************************************************/ - -int ContactDock::usableNumberCount(Contact* cont) -{ - uint result =0; - QStringList list = ConfigurationSkeleton::phoneTypeList(); - foreach (Contact::PhoneNumber* pn,cont->getPhoneNumbers()) { - result += list.indexOf(pn->getType()) != -1; - } - return result; -} diff --git a/kde/src/widgets/ContactDock.h b/kde/src/widgets/ContactDock.h index 06dbe812456297cff4f258a6c7284ebf9178caa9..c7318a0b4f6a1d0a986a0d73a5c8ce80019f412d 100644 --- a/kde/src/widgets/ContactDock.h +++ b/kde/src/widgets/ContactDock.h @@ -23,7 +23,9 @@ #include <QtCore/QHash> #include <QtGui/QDockWidget> #include "CategorizedTreeWidget.h" -#include "SortableDockCommon.h" +#include "../klib/SortableDockCommon.h" +#include "CallTreeItem.h" +#include <QtGui/QTreeWidgetItem> //Qt class QSplitter; @@ -57,7 +59,7 @@ class StaticEventHandler; class Contact; ///@class ContactDock Dock to access contacts -class ContactDock : public QDockWidget, public SortableDockCommon +class ContactDock : public QDockWidget, public SortableDockCommon<CallTreeItem*,QTreeWidgetItem*> { Q_OBJECT public: @@ -75,9 +77,6 @@ private: QCheckBox* m_pShowHistoCK; QList<ContactItemWidget*> m_Contacts; - //Helpers - int usableNumberCount(Contact* cont); - public slots: virtual void keyPressEvent(QKeyEvent* event); diff --git a/kde/src/widgets/ContactItemWidget.cpp b/kde/src/widgets/ContactItemWidget.cpp index db15eaa48bca58d0e31186ffb1d15bb4919b2776..b253adfff36ad505dab9ab0e4bb4a234d1d9c16c 100644 --- a/kde/src/widgets/ContactItemWidget.cpp +++ b/kde/src/widgets/ContactItemWidget.cpp @@ -40,7 +40,7 @@ #include <unistd.h> //SFLPhone -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" #include "widgets/BookmarkDock.h" #include "SFLPhone.h" diff --git a/kde/src/widgets/HistoryDock.cpp b/kde/src/widgets/HistoryDock.cpp index 8202c3405e8a9afa412a80f3317e05d0d743cacf..6dad617dee1c63ec8ac302b95a594a6824dee54a 100644 --- a/kde/src/widgets/HistoryDock.cpp +++ b/kde/src/widgets/HistoryDock.cpp @@ -42,8 +42,8 @@ //SFLPhone #include "SFLPhone.h" #include "widgets/HistoryTreeItem.h" -#include "AkonadiBackend.h" -#include "conf/ConfigurationSkeleton.h" +#include "klib/AkonadiBackend.h" +#include "klib/ConfigurationSkeleton.h" //SFLPhone library #include "lib/sflphone_const.h" @@ -122,7 +122,7 @@ HistoryDock::HistoryDock(QWidget* parent) : QDockWidget(parent) m_pFilterLE->setClearButtonShown(true); QStringList sortBy; - sortBy << "Date" << "Name" << "Popularity" << "Duration"; + sortBy << "Date" << "Name" << "Popularity" << "Length"; m_pSortByCBB->addItems(sortBy); QWidget* mainWidget = new QWidget(this); @@ -174,15 +174,6 @@ HistoryDock::~HistoryDock() * * ****************************************************************************/ -///Return the identity of the call caller -QString HistoryDock::getIdentity(HistoryTreeItem* item) -{ - if (item->getName().trimmed().isEmpty()) - return item->getPhoneNumber(); - else - return item->getName(); -} - /***************************************************************************** * * @@ -234,7 +225,7 @@ void HistoryDock::reload() m_pItemView->setItemWidget(item,0,hitem); } break; - case Name: { + case Name2: { QHash<QString,QTreeWidgetItem*> group; foreach(HistoryTreeItem* item, m_History) { // if (!group[getIdentity(item)]) { @@ -242,7 +233,7 @@ void HistoryDock::reload() // group[getIdentity(item)]->setText(0,getIdentity(item)); // m_pItemView->addTopLevelItem(group[getIdentity(item)]); // } - QNumericTreeWidgetItem* twItem = m_pItemView->addItem<QNumericTreeWidgetItem>(getIdentity(item)); + QNumericTreeWidgetItem* twItem = m_pItemView->addItem<QNumericTreeWidgetItem>(getIdentity(item->call())); item->setItem(twItem); twItem->widget = item; m_pItemView->setItemWidget(twItem,0,item); @@ -252,24 +243,24 @@ void HistoryDock::reload() case Popularity: { QHash<QString,QNumericTreeWidgetItem*> group; foreach(HistoryTreeItem* item, m_History) { - if (!group[getIdentity(item)]) { - group[getIdentity(item)] = m_pItemView->addCategory<QNumericTreeWidgetItem>(getIdentity(item)); - group[getIdentity(item)]->weight = 0; - m_pItemView->addTopLevelItem(group[getIdentity(item)]); + if (!group[getIdentity(item->call())]) { + group[getIdentity(item->call())] = m_pItemView->addCategory<QNumericTreeWidgetItem>(getIdentity(item->call())); + group[getIdentity(item->call())]->weight = 0; + m_pItemView->addTopLevelItem(group[getIdentity(item->call())]); } - group[getIdentity(item)]->weight++; - group[getIdentity(item)]->setText(0,getIdentity(item)+" ("+QString::number(group[getIdentity(item)]->weight)+")"); - QNumericTreeWidgetItem* twItem = m_pItemView->addItem<QNumericTreeWidgetItem>(getIdentity(item)); + group[getIdentity(item->call())]->weight++; + group[getIdentity(item->call())]->setText(0,getIdentity(item->call())+" ("+QString::number(group[getIdentity(item->call())]->weight)+")"); + QNumericTreeWidgetItem* twItem = m_pItemView->addItem<QNumericTreeWidgetItem>(getIdentity(item->call())); item->setItem(twItem); twItem->widget = item; m_pItemView->setItemWidget(twItem,0,item); } break; } - case Duration: + case Length: foreach(HistoryTreeItem* hitem, m_History) { QNumericTreeWidgetItem* item = m_pItemView->addItem<QNumericTreeWidgetItem>(" "); - item->weight = hitem->getDuration(); + item->weight = hitem->getLength(); hitem->setItem(item); m_pItemView->addTopLevelItem(item); m_pItemView->setItemWidget(item,0,hitem); diff --git a/kde/src/widgets/HistoryDock.h b/kde/src/widgets/HistoryDock.h index f82e8d022b6cece1c79dbebb1fa17440efaad0ae..51ce18b1ec07b05ff5a84f19b8b00956703db9c2 100644 --- a/kde/src/widgets/HistoryDock.h +++ b/kde/src/widgets/HistoryDock.h @@ -23,8 +23,10 @@ #include <QtGui/QDockWidget> #include <QtGui/QTreeWidget> #include <QtCore/QDate> -#include "SortableDockCommon.h" +#include "../klib/SortableDockCommon.h" #include "CategorizedTreeWidget.h" +#include "CallTreeItem.h" +#include <QtGui/QTreeWidgetItem> //Qt class QTreeWidgetItem; @@ -48,7 +50,7 @@ class HistoryTree; typedef QList<HistoryTreeItem*> HistoryList; ///@class HistoryDock Dock to see the previous SFLPhone calls -class HistoryDock : public QDockWidget, public SortableDockCommon { +class HistoryDock : public QDockWidget, public SortableDockCommon<CallTreeItem*,QTreeWidgetItem*> { Q_OBJECT public: @@ -60,17 +62,6 @@ public: virtual ~HistoryDock(); private: - //Enum - enum SortBy { - Date = 0, - Name = 1, - Popularity = 2, - Duration = 3 - }; - - //Getters - QString getIdentity(HistoryTreeItem* item); - //Attributes HistoryTree* m_pItemView ; KLineEdit* m_pFilterLE ; diff --git a/kde/src/widgets/HistoryTreeItem.cpp b/kde/src/widgets/HistoryTreeItem.cpp index 74f54d9f8344ff22bbe4500bbd4089decbe8ea8b..656b957513ddb499a47ef3dbe46c61a44ba3a77c 100644 --- a/kde/src/widgets/HistoryTreeItem.cpp +++ b/kde/src/widgets/HistoryTreeItem.cpp @@ -52,7 +52,7 @@ #include "lib/Call.h" //SFLPhone -#include "AkonadiBackend.h" +#include "klib/AkonadiBackend.h" #include "SFLPhone.h" #include "widgets/BookmarkDock.h" @@ -140,7 +140,7 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) m_pIconL = new QLabel( this ); m_pPeerNameL = new QLabel( this ); m_pCallNumberL = new QLabel( this ); - m_pDurationL = new QLabel( this ); + m_pLengthL = new QLabel( this ); m_pTimeL = new QLabel( this ); m_pIconL->setMinimumSize(70,0); @@ -155,7 +155,7 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) m_pMainLayout->addItem ( verticalSpacer , 4 , 1 ); m_pMainLayout->addWidget ( m_pPlay , 0 , 2 , 4 , 1 ); m_pMainLayout->addWidget ( m_pRemove , 0 , 3 , 4 , 1 ); - m_pMainLayout->addWidget ( m_pDurationL , 0 , 4 , 4 , 1 ); + m_pMainLayout->addWidget ( m_pLengthL , 0 , 4 , 4 , 1 ); setLayout(m_pMainLayout); setMinimumSize(QSize(50, 30)); setMaximumSize(QSize(300,99999)); @@ -483,13 +483,13 @@ void HistoryTreeItem::setCall(Call *call) m_pTimeL->setText(QDateTime::fromTime_t(m_pItemCall->getStartTimeStamp().toUInt()).toString()); int dur = m_pItemCall->getStopTimeStamp().toInt() - m_pItemCall->getStartTimeStamp().toInt(); - m_pDurationL->setText(QString("%1").arg(dur/3600,2).trimmed()+":"+QString("%1").arg((dur%3600)/60,2).trimmed()+":"+QString("%1").arg((dur%3600)%60,2).trimmed()+" "); + m_pLengthL->setText(QString("%1").arg(dur/3600,2).trimmed()+":"+QString("%1").arg((dur%3600)/60,2).trimmed()+":"+QString("%1").arg((dur%3600)%60,2).trimmed()+" "); connect(m_pItemCall , SIGNAL(changed()) , this , SLOT(updated() )); updated(); m_TimeStamp = m_pItemCall->getStartTimeStamp().toUInt(); - m_Duration = dur; + m_Length = dur; m_Name = m_pItemCall->getPeerName(); m_PhoneNumber = m_pItemCall->getPeerPhoneNumber(); @@ -505,8 +505,8 @@ void HistoryTreeItem::setItem(QTreeWidgetItem* item) void HistoryTreeItem::setDurWidth(uint width) { - m_pDurationL->setMaximumSize(width, 9999 ); - m_pDurationL->setMinimumSize(width, 0 ); + m_pLengthL->setMaximumSize(width, 9999 ); + m_pLengthL->setMinimumSize(width, 0 ); } @@ -543,9 +543,9 @@ uint HistoryTreeItem::getTimeStamp() } ///Return the duration -uint HistoryTreeItem::getDuration() +uint HistoryTreeItem::getLength() { - return m_Duration; + return m_Length; } ///Return the caller name @@ -575,6 +575,6 @@ QTreeWidgetItem* HistoryTreeItem::getItem() ///Get the width of the durationWidget uint HistoryTreeItem::getDurWidth() { - QFontMetrics fm(m_pDurationL->font()); - return fm.width(m_pDurationL->text()); + QFontMetrics fm(m_pLengthL->font()); + return fm.width(m_pLengthL->text()); } diff --git a/kde/src/widgets/HistoryTreeItem.h b/kde/src/widgets/HistoryTreeItem.h index 308fd0fcb8207488920fcb0469b0f75f7c2f6504..8533ed91fc09b0d48beb8097970551fc2041c073 100644 --- a/kde/src/widgets/HistoryTreeItem.h +++ b/kde/src/widgets/HistoryTreeItem.h @@ -65,7 +65,7 @@ class HistoryTreeItem : public QWidget //Getters Call* call () const; uint getTimeStamp (); - uint getDuration (); + uint getLength (); QString getName (); QString getPhoneNumber (); QTreeWidgetItem* getItem (); @@ -87,7 +87,7 @@ class HistoryTreeItem : public QWidget QLabel* m_pPeerNameL ; QLabel* m_pCallNumberL ; QLabel* m_pTimeL ; - QLabel* m_pDurationL ; + QLabel* m_pLengthL ; KAction* m_pCallAgain ; KAction* m_pAddContact ; @@ -101,7 +101,7 @@ class HistoryTreeItem : public QWidget QToolButton* m_pRemove ; uint m_TimeStamp ; - uint m_Duration ; + uint m_Length ; QString m_Name ; QString m_PhoneNumber ; QGridLayout* m_pMainLayout ; diff --git a/kde/src/widgets/SortableDockCommon.cpp b/kde/src/widgets/SortableDockCommon.cpp deleted file mode 100644 index caaea4666b95756528e2fec3bec69b41faa17cb6..0000000000000000000000000000000000000000 --- a/kde/src/widgets/SortableDockCommon.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include "SortableDockCommon.h" - -//Qt -#include <QtCore/QDateTime> -#include <QtCore/QStringList> -#include <QtCore/QTimer> - -//SFLPhone -#include "lib/Call.h" -#include "lib/Contact.h" -#include "lib/CallModel.h" -#include "SFLPhone.h" -#include "AkonadiBackend.h" - -///StaticEventHandler constructor -StaticEventHandler::StaticEventHandler(QObject* parent) : QObject(parent) -{ - QTimer* timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(update())); - timer->start(86400000); //1 day - update(); -} - -///Update the days constant, necessary to cycle after midnight -void StaticEventHandler::update() -{ - SortableDockCommon::m_slHistoryConst = { - "Today" ,//0 - "Yesterday" ,//1 - QDate::currentDate().addDays(-2).toString("dddd"),//2 - QDate::currentDate().addDays(-3).toString("dddd"),//3 - QDate::currentDate().addDays(-4).toString("dddd"),//4 - QDate::currentDate().addDays(-5).toString("dddd"),//5 - QDate::currentDate().addDays(-6).toString("dddd"),//6 - "Last week" ,//7 - "Two weeks ago" ,//8 - "Three weeks ago" ,//9 - "Last month" ,//10 - "Two months ago" ,//11 - "Three months ago" ,//12 - "Four months ago" ,//13 - "Five months ago" ,//14 - "Six months ago" ,//15 - "Seven months ago" ,//16 - "Eight months ago" ,//17 - "Nine months ago" ,//18 - "Ten months ago" ,//19 - "Eleven months ago" ,//20 - "Twelve months ago" ,//21 - "Last year" ,//22 - "Very long time ago" ,//23 - "Never" //24 - }; -} - -QStringList SortableDockCommon::m_slHistoryConst; -StaticEventHandler* SortableDockCommon::m_spEvHandler = new StaticEventHandler(0); - -/***************************************************************************** - * * - * Helpers * - * * - ****************************************************************************/ - -QString SortableDockCommon::timeToHistoryCategory(QDate date) -{ - if (QDate::currentDate() == date || QDate::currentDate() < date) //The future case would be a bug, but it have to be handled anyway or it will appear in "very long time ago" - return m_slHistoryConst[HistoryConst::Today]; - - //Check for last week - for (int i=1;i<7;i++) { - if (QDate::currentDate().addDays(-i) == date) - return m_slHistoryConst[i]; //Yesterday to Six_days_ago - } - - //Check for last month - for (int i=1;i<4;i++) { - if (QDate::currentDate().addDays(-(i*7)) >= date && QDate::currentDate().addDays(-(i*7) -7) < date) - return m_slHistoryConst[i+Last_week-1]; //Last_week to Three_weeks_ago - } - - //Check for last year - for (int i=1;i<12;i++) { - if (QDate::currentDate().addMonths(-i) >= date && QDate::currentDate().addMonths((-i) - 1) < date) - return m_slHistoryConst[i+Last_month-1]; //Last_month to Twelve_months ago - } - - if (QDate::currentDate().addYears(-1) >= date && QDate::currentDate().addYears(-2) < date) - return m_slHistoryConst[Last_year]; - - //Every other senario - return m_slHistoryConst[Very_long_time_ago]; -} - -///Return the list of contact from history (in order, most recently used first) -QHash<Contact*, QDateTime> SortableDockCommon::getContactListByTime(/*ContactList list*/) -{ - const CallMap& history= SFLPhone::model()->getHistory(); - QHash<Contact*, QDateTime> toReturn; - QSet<QString> alreadyUsed; - QMapIterator<QString, Call*> i(history); - i.toBack(); - while (i.hasPrevious()) { //Iterate from the end up - i.previous(); - (alreadyUsed.find(i.value()->getPeerPhoneNumber()) == alreadyUsed.constEnd()); //Don't ask, leave it there Elv13(2012) - if (alreadyUsed.find(i.value()->getPeerPhoneNumber()) == alreadyUsed.constEnd()) { - Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(i.value()->getPeerPhoneNumber(),true); - if (contact && toReturn.find(contact) == toReturn.end()) { - toReturn[contact] = QDateTime::fromTime_t(i.value()->getStartTimeStamp().toUInt()); - } - alreadyUsed << i.value()->getPeerPhoneNumber(); - } - } - return toReturn; -} \ No newline at end of file