Commit 282de687 authored by Julien Wadel's avatar Julien Wadel

Reduce names

parent a467559a
......@@ -21,13 +21,13 @@
################################################################################
cmake_minimum_required(VERSION 3.1)
project(momentumEnswitchContacts VERSION 1.0.0)
project(mmhOneVoice VERSION 1.0.0)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
set(TARGET_NAME momentumEnswitchContacts-plugin)
set(TARGET_NAME mmhOneVoice )
set(CMAKE_CXX_STANDARD 11)
......@@ -76,15 +76,15 @@ bc_git_version(${TARGET_NAME} ${PROJECT_VERSION})
#-------------------------------------------------
set(SOURCES
src/MomentumEnswitchPlugin.cpp
src/MomentumEnswitchNetworkAPI.cpp
src/MomentumEnswitchDataAPI.cpp
src/Plugin.cpp
src/NetworkAPI.cpp
src/DataAPI.cpp
)
set(HEADERS
src/MomentumEnswitchPlugin.hpp
src/MomentumEnswitchNetworkAPI.hpp
src/MomentumEnswitchDataAPI.hpp
src/Plugin.hpp
src/NetworkAPI.hpp
src/DataAPI.hpp
)
# ------------------------------------------------------------------------------
......@@ -92,7 +92,7 @@ set(HEADERS
# ------------------------------------------------------------------------------
add_library(${TARGET_NAME} SHARED ${SOURCES})
find_library(CONTACTS_PLUGIN_LIBRARY linphoneAppContactsApi HINTS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
find_library(CONTACTS_PLUGIN_LIBRARY linphoneAppContacts HINTS "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
target_link_libraries(${TARGET_NAME} PRIVATE Qt5::Widgets Qt5::Network ${CONTACTS_PLUGIN_LIBRARY} ${LINPHONECXX_LIBRARIES})
target_compile_options(${TARGET_NAME} PRIVATE ${COMPILE_OPTIONS})
......
#include "MomentumEnswitchDataAPI.hpp"
#include "MomentumEnswitchNetworkAPI.hpp"
#include "MomentumEnswitchPlugin.hpp"
#include "DataAPI.hpp"
#include "NetworkAPI.hpp"
#include "Plugin.hpp"
#include <QInputDialog>
#include <linphone++/proxy_config.hh>
MomentumEnswitchDataAPI::MomentumEnswitchDataAPI(ContactsImporterPlugin *plugin, std::shared_ptr<linphone::Core> core) :ContactsImporterDataAPI(plugin, core){
DataAPI::DataAPI(ContactsImporterPlugin *plugin, std::shared_ptr<linphone::Core> core) :ContactsImporterDataAPI(plugin, core){
auto proxyConfig = mCore->getDefaultProxyConfig();
QVariantMap account;
std::string domain;
......@@ -21,29 +21,29 @@ MomentumEnswitchDataAPI::MomentumEnswitchDataAPI(ContactsImporterPlugin *plugin,
mInputFields["SIP_Domain"] = QString::fromLocal8Bit(domain.c_str(), int(domain.size()));;
}
QString MomentumEnswitchDataAPI::getUrl()const{
QString DataAPI::getUrl()const{
return mInputFields["URL"].toString();
}
QString MomentumEnswitchDataAPI::getDomain()const{
QString DataAPI::getDomain()const{
return mInputFields["SIP_Domain"].toString();
}
QString MomentumEnswitchDataAPI::getUsername()const{
QString DataAPI::getUsername()const{
return mInputFields["Username"].toString();
}
QString MomentumEnswitchDataAPI::getPassword()const{
QString DataAPI::getPassword()const{
return mInputFields["Password"].toString();
}
QString MomentumEnswitchDataAPI::getKey()const{
QString DataAPI::getKey()const{
return mInputFields["Key"].toString();
}
bool MomentumEnswitchDataAPI::isEnabled()const{
bool DataAPI::isEnabled()const{
return mInputFields["enabled"].toInt()>0;
}
void MomentumEnswitchDataAPI::setPassword(const QString &password){
void DataAPI::setPassword(const QString &password){
mInputFields["Password"] = password;
}
bool MomentumEnswitchDataAPI::isValid(const bool &pRequestData, QString * pError){
bool DataAPI::isValid(const bool &pRequestData, QString * pError){
QStringList errors;
if( getDomain().isEmpty())
errors << "Domain is empty.";
......@@ -53,7 +53,7 @@ bool MomentumEnswitchDataAPI::isValid(const bool &pRequestData, QString * pError
errors << "Username is empty.";
if( getPassword().isEmpty() && getKey().isEmpty()){
if(pRequestData)
setPassword(QInputDialog::getText(nullptr, "Enswitch Address Book","Password",QLineEdit::EchoMode::Password));
setPassword(QInputDialog::getText(nullptr, "MMH OneVoice Address Book","Password",QLineEdit::EchoMode::Password));
if( getPassword().isEmpty())
errors << "Password is empty.";
}
......@@ -65,20 +65,20 @@ bool MomentumEnswitchDataAPI::isValid(const bool &pRequestData, QString * pError
return true;
}
QVariantMap MomentumEnswitchDataAPI::getInputFields(){
QVariantMap DataAPI::getInputFields(){
QVariantMap data = mInputFields;
data.remove("Password");
return data;
}
void MomentumEnswitchDataAPI::importContacts(){
MomentumEnswitchNetworkAPI * network = new MomentumEnswitchNetworkAPI(this);
void DataAPI::importContacts(){
NetworkAPI * network = new NetworkAPI(this);
QObject::connect(this, SIGNAL(contactsReceived(QVector<QMultiMap<QString,QString> >)), network, SLOT(deleteLater()));
network->startRequest();
}
//-----------------------------------------------------------------------------------------
void MomentumEnswitchDataAPI::parse(const QByteArray& p_data){
void DataAPI::parse(const QByteArray& p_data){
QVector<QMultiMap<QString,QString> > parsedData;
QString statusText;
if(!p_data.isEmpty()) {
......@@ -112,6 +112,7 @@ void MomentumEnswitchDataAPI::parse(const QByteArray& p_data){
bool haveData = false;
QString company = contact["company"].toString();
if( contact.contains("firstname") && contact["firstname"].toString() != "")
name << contact["firstname"].toString();
if( contact.contains("surname") && contact["surname"].toString() != "")
......@@ -134,7 +135,7 @@ void MomentumEnswitchDataAPI::parse(const QByteArray& p_data){
++contactCount;
}
}
QString messageStatus = QString::number(contactCount) +" contact"+(contactCount>1?"s":"")+" on Enswitch have been synchronized at "+QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
QString messageStatus = QString::number(contactCount) +" contact"+(contactCount>1?"s":"")+" on OneVoice have been synchronized at "+QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
emit statusMessage(messageStatus);
qInfo() << messageStatus;
}
......
#ifndef MOMENTUMENSWITCHDATAAPI_HPP
#define MOMENTUMENSWITCHDATAAPI_HPP
#ifndef DATAAPI_HPP
#define DATAAPI_HPP
#include <QObject>
#include <QtNetwork>
......@@ -12,12 +12,12 @@ class ContactsImporterPlugin;
// Enswitch DATA address book importer
class MomentumEnswitchDataAPI : public ContactsImporterDataAPI
class DataAPI : public ContactsImporterDataAPI
{
Q_OBJECT
public:
MomentumEnswitchDataAPI(ContactsImporterPlugin *plugin, std::shared_ptr<linphone::Core> core);
virtual ~MomentumEnswitchDataAPI(){}
DataAPI(ContactsImporterPlugin *plugin, std::shared_ptr<linphone::Core> core);
virtual ~DataAPI(){}
QString getUrl()const;
QString getDomain()const;
......@@ -40,4 +40,4 @@ signals:
void inputFieldsChanged(const QVariantMap &inputs); // The plugin made updates on input
};
#endif // MOMENTUMENSWITCHDATAAPI_HPP
#endif // DATAAPI_HPP
#include "MomentumEnswitchNetworkAPI.hpp"
#include "MomentumEnswitchDataAPI.hpp"
#include "NetworkAPI.hpp"
#include "DataAPI.hpp"
#include <QInputDialog>
#include <linphoneapp/contacts/ContactsImporterDataAPI.hpp>
MomentumEnswitchNetworkAPI::MomentumEnswitchNetworkAPI(MomentumEnswitchDataAPI * data) : mData(data){
NetworkAPI::NetworkAPI(DataAPI * data) : mData(data){
if(mData ) {
connect(this, SIGNAL(requestFinished(const QByteArray&)), mData, SLOT(parse(const QByteArray&)));
connect(this, SIGNAL(requestError(const QString &)), mData, SIGNAL(errorMessage(const QString &)));
......@@ -13,15 +13,15 @@ MomentumEnswitchNetworkAPI::MomentumEnswitchNetworkAPI(MomentumEnswitchDataAPI *
}
}
MomentumEnswitchNetworkAPI::~MomentumEnswitchNetworkAPI(){
NetworkAPI::~NetworkAPI(){
}
bool MomentumEnswitchNetworkAPI::isEnabled()const{
bool NetworkAPI::isEnabled()const{
return mData && mData->isEnabled();
}
bool MomentumEnswitchNetworkAPI::isValid(ContactsImporterDataAPI * pData, const bool &pShowError){
bool NetworkAPI::isValid(ContactsImporterDataAPI * pData, const bool &pShowError){
QString errorMessage;
MomentumEnswitchDataAPI * data = dynamic_cast<MomentumEnswitchDataAPI*>(pData);
DataAPI * data = dynamic_cast<DataAPI*>(pData);
bool ok = data;
if(!ok)
errorMessage = "These data are not Enswitch data";
......@@ -35,7 +35,7 @@ bool MomentumEnswitchNetworkAPI::isValid(ContactsImporterDataAPI * pData, const
}
//-----------------------------------------------------------------------------------------
QString MomentumEnswitchNetworkAPI::prepareRequest()const{
QString NetworkAPI::prepareRequest()const{
QString url = mData->getUrl()+"?user="+mData->getUsername()+"&";
if( mData->getKey() != "")
url += "key="+mData->getKey();
......@@ -44,7 +44,7 @@ QString MomentumEnswitchNetworkAPI::prepareRequest()const{
return url;
}
void MomentumEnswitchNetworkAPI::startRequest() {
void NetworkAPI::startRequest() {
bool doRequest = false;
if(isValid(mData)){
if(isEnabled()){
......
#ifndef MOMENTUMENSWITCHNETWORKAPI_HPP
#define MOMENTUMENSWITCHNETWORKAPI_HPP
#ifndef NETWORKAPI_HPP
#define NETWORKAPI_HPP
#include <QObject>
#include <QtNetwork>
......@@ -7,16 +7,16 @@
#include <linphoneapp/contacts/ContactsImporterNetworkAPI.hpp>
class MomentumEnswitchDataAPI;
class DataAPI;
class ContactsImporterDataAPI;
// All-in-one for Enswitch address book importer
// Interface between Network API and Data.
class MomentumEnswitchNetworkAPI : public ContactsImporterNetworkAPI
class NetworkAPI : public ContactsImporterNetworkAPI
{
Q_OBJECT
public:
MomentumEnswitchNetworkAPI(MomentumEnswitchDataAPI * data);
virtual ~MomentumEnswitchNetworkAPI();
NetworkAPI(DataAPI * data);
virtual ~NetworkAPI();
void copy(ContactsImporterDataAPI *pData); // Copy a ContactsEnswitchDataAPI to the current Data. Ensure to get a ContactsEnswitchDataAPI. It doesn't replace data instance to keep signal/slot connections
bool isEnabled()const; // Interface to test if data is enabled
......@@ -27,9 +27,9 @@ public:
void startRequest();
// Data
MomentumEnswitchDataAPI * mData;
DataAPI * mData;
int mCurrentStep;
};
#endif // MOMENTUMENSWITCHNETWORKAPI_HPP
#endif // NETWORKAPI_HPP
......@@ -19,17 +19,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*******************************************************************************/
#include "MomentumEnswitchPlugin.hpp"
#include "Plugin.hpp"
#include <QJsonDocument>
#include <QJsonArray>
#include "MomentumEnswitchDataAPI.hpp"
#include "MomentumEnswitchNetworkAPI.hpp"
#include "DataAPI.hpp"
#include "NetworkAPI.hpp"
QString MomentumEnswitchPlugin::descriptionToJson()const{
QString Plugin::descriptionToJson()const{
QJsonObject description;
description["title"] = "MMH OneVoice";
description["description"] = "This is a plugin to import an address book from a Enswitch server with a custom interface";
description["description"] = "This is a plugin to import an address book from a OneVoice server with a custom interface";
QJsonObject field;
QJsonArray fields;
......@@ -67,6 +67,6 @@ QString MomentumEnswitchPlugin::descriptionToJson()const{
return document.toJson();
}
ContactsImporterDataAPI * MomentumEnswitchPlugin::createInstance(std::shared_ptr<linphone::Core> core){
return new MomentumEnswitchDataAPI(this, core);
ContactsImporterDataAPI * Plugin::createInstance(std::shared_ptr<linphone::Core> core){
return new DataAPI(this, core);
}
......@@ -19,6 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*******************************************************************************/
#ifndef PLUGIN_HPP
#define PLUGIN_HPP
#include <QObject>
#include <QtPlugin>
#include <linphoneapp/contacts/ContactsImporterPlugin.hpp>
......@@ -28,7 +31,7 @@
class ContactsImporterDataAPI;
class MomentumEnswitchPlugin : public QObject, public ContactsImporterPlugin
class Plugin : public QObject, public ContactsImporterPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID ContactsImporterPlugin_iid)
......@@ -38,3 +41,5 @@ public:
QString descriptionToJson()const;
virtual ContactsImporterDataAPI * createInstance(std::shared_ptr<linphone::Core> core);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment