Commit e8dda4e6 authored by Nicolas Jager's avatar Nicolas Jager Committed by Guillaume Roguez
Browse files

Add stubs and class diagram



add stubs for :
 - Database class.
 - ConversationModel class and Conversation namespace.
 - NewCallModel class and NewCall namespace.
 - ContactModel class and Contact namespace.
 - Message namespace.
 - NewAccountModel.
 - CallbacksHandler, will be used to bind the callbacks from the daemon
   and will emit signals for lrc and client.
 - Lrc class, this class is the root class of all models. Instating this
   class will build interfaces between the daemon, client and the
   database.
 - all these class are nested in the lrc namespace.
 - all publicly exposed API have been put into lrc::api namespace
 - add diagrams in doc folder

Change-Id: Ia06f874dd1baebb086edd570e52d8d61d73b905b
Reviewed-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 287e8236
......@@ -52,6 +52,7 @@ SET(QT5_MODULE_PATH ${QT5_PATH}/lib/cmake)
FIND_PACKAGE(Ring REQUIRED)
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5LinguistTools) # translations
FIND_PACKAGE(Qt5Sql REQUIRED)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT ENABLE_LIBWRAP)
FIND_PACKAGE(Qt5DBus)
......@@ -205,13 +206,13 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR})
# Build dbus interfaces
# Build dbus api
IF(DEFINED RING_XML_INTERFACES_DIR)
SET (dbus_xml_introspecs_path ${RING_XML_INTERFACES_DIR})
ELSEIF(EXISTS "${RING_BUILD_DIR}/../bin/dbus")
SET (dbus_xml_introspecs_path ${RING_BUILD_DIR}/../bin/dbus)
ELSE()
SET (dbus_xml_introspecs_path ${CMAKE_INSTALL_PREFIX}/share/dbus-1/interfaces)
SET (dbus_xml_introspecs_path ${CMAKE_INSTALL_PREFIX}/share/dbus-1/api)
ENDIF()
#File to compile
......@@ -293,6 +294,13 @@ SET( libringclient_LIB_SRCS
src/audio/settings.cpp
src/media/recordingmodel.cpp
src/bannedcontactmodel.cpp
src/contactmodel.cpp
src/newcallmodel.cpp
src/conversationmodel.cpp
src/database.cpp
src/lrc.cpp
src/newaccountmodel.cpp
src/callbackshandler.cpp
#Data collections
src/transitionalpersonbackend.cpp
......@@ -446,6 +454,20 @@ SET( libringclient_LIB_HDRS
src/bannedcontactmodel.h
)
SET(libringclient_api_LIB_HDRS
src/api/message.h
src/api/conversation.h
src/api/contact.h
src/api/call.h
src/api/account.h
src/api/lrc.h
src/api/newaccountmodel.h
src/api/newcallmodel.h
src/api/contactmodel.h
src/api/conversationmodel.h
)
SET(libringclient_video_LIB_HDRS
src/video/device.h
src/video/devicemodel.h
......@@ -637,6 +659,7 @@ IF(NOT ${ENABLE_STATIC} MATCHES false)
-lpthread
${QT_QTDBUS_LIBRARY}
${QT_QTCORE_LIBRARY}
Qt5::Sql
)
SET_TARGET_PROPERTIES( ringclient_static
PROPERTIES VERSION ${GENERIC_LIB_VERSION}
......@@ -661,6 +684,7 @@ ENDIF()
TARGET_LINK_LIBRARIES( ringclient
-lpthread
${QT_QTCORE_LIBRARY}
Qt5::Sql
)
IF(${ENABLE_LIBWRAP} MATCHES true)
......@@ -736,6 +760,12 @@ INSTALL( FILES ${libringclient_interface_LIB_HDRS}
COMPONENT Devel
)
INSTALL( FILES ${libringclient_api_LIB_HDRS}
DESTINATION ${INCLUDE_INSTALL_DIR}/libringclient/api
COMPONENT Devel
)
#This hack force Debian based system to return a non multi-arch path
#this is required to prevent the .deb libringclient.so from having an
#higher priority than the prefixed one.
......
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
#include <string>
#include <memory>
namespace lrc
{
namespace api
{
class NewCallModel;
class ContactModel;
class ConversationModel;
class NewAccountModel;
namespace account
{
enum class Type {
INVALID,
RING,
SIP
};
struct Info
{
std::string id;
Type type = account::Type::INVALID;
std::unique_ptr<lrc::api::NewCallModel> callModel;
std::unique_ptr<lrc::api::ContactModel> contactModel;
std::unique_ptr<lrc::api::ConversationModel> conversationModel;
std::unique_ptr<lrc::api::NewAccountModel> accountModel;
};
} // namespace account
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// std
#include <string>
#include <ctime>
namespace lrc
{
namespace api
{
namespace call
{
enum class Status {
INVALID,
OUTGOING_REQUESTED,
INCOMING_RINGING,
OUTGOING_RINGING,
CONNECTING,
SEARCHING,
IN_PROGRESS,
PAUSED,
PEER_PAUSED,
INACTIVE,
ENDED,
TERMINATING,
CONNECTED,
AUTO_ANSWERING
};
struct Info
{
std::string id;
std::time_t startTime = 0;
Status status = Status::INVALID;
};
} // namespace call
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// Std
#include <string>
namespace lrc
{
namespace api
{
namespace contact
{
enum class Type {
INVALID,
RING,
SIP
};
struct Info
{
std::string uri;
std::string avatar;
std::string registeredName;
std::string alias;
bool isTrusted = false;
bool isPresent = false;
Type type = Type::INVALID;
};
} // namespace contact
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// Std
#include <string>
#include <memory>
#include <map>
// Qt
#include <qobject.h>
// LRC
#include "typedefs.h"
namespace lrc
{
class Database;
class ContactModelPimpl;
namespace api
{
namespace contact { struct Info; }
namespace account { struct Info; }
class NewAccountModel;
class ConversationModel;
class LIB_EXPORT ContactModel : public QObject {
Q_OBJECT
public:
using ContactInfoMap = std::map<std::string, std::shared_ptr<contact::Info>>;
const account::Info& owner;
ContactModel(NewAccountModel& parent,
const Database& database,
const account::Info& info);
~ContactModel();
const contact::Info& getContact(const std::string& uri) const;
const ContactInfoMap& getAllContacts() const;
void addContact(const std::string& uri);
void removeContact(const std::string& uri);
void nameLookup(const std::string& uri) const;
void addressLookup(const std::string& name) const;
Q_SIGNALS:
void contactsChanged();
private:
std::unique_ptr<ContactModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// Std
#include <vector>
#include <map>
// Data
#include "message.h"
namespace lrc
{
namespace api
{
namespace conversation
{
struct Info
{
std::string uid;
std::string accountId;
std::vector<std::string> participants;
std::string callId;
std::map<int, message::Info> messages;
unsigned int lastMessageUid = 0;
bool isUsed = false;
unsigned int unreadMessages = 0;
};
} // namespace conversation
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// Std
#include <memory>
#include <map>
#include <string>
#include <deque>
// Qt
#include <qobject.h>
// Lrc
#include "typedefs.h"
// Data
#include "api/conversation.h"
namespace lrc
{
class Database;
class ConversationModelPimpl;
namespace api
{
namespace account { struct Info; }
namespace message { struct Info; }
class NewAccountModel;
class LIB_EXPORT ConversationModel : public QObject {
Q_OBJECT
public:
using ConversationQueue = std::deque<conversation::Info>;
const account::Info& owner;
ConversationModel(const NewAccountModel& parent,
const Database& database,
const account::Info& info);
~ConversationModel();
const ConversationQueue& getFilteredConversations() const;
conversation::Info getConversation(unsigned int row) const;
void addConversation(const std::string& uri) const;
void removeConversation(const std::string& uid);
void selectConversation(const std::string& uid);
void placeCall(const std::string& uid) const;
void sendMessage(const std::string& uid, const std::string& body) const;
void setFilter(const std::string& filter);
void addParticipant(const std::string& uid, const::std::string& uri);
void clearHistory(const std::string& uid);
Q_SIGNALS:
void newMessageAdded(const std::string& uid, const message::Info& msg);
void conversationUpdated(unsigned int row);
void modelUpdated() const;
void newContactAdded(const std::string& uri);
void incomingCallFromItem(const unsigned int row);
void showChatView(const conversation::Info& conversationInfo);
void showCallView(const conversation::Info& conversationInfo);
void showIncomingCallView(const conversation::Info& conversationInfo);
private:
std::unique_ptr<ConversationModelPimpl> pimpl_;
};
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// Std
#include <memory>
// Lrc
#include "typedefs.h"
namespace lrc
{
class Database;
class CallbacksHandler;
class LrcPimpl;
namespace api
{
class NewAccountModel;
class LIB_EXPORT Lrc {
public:
Lrc();
~Lrc();
NewAccountModel& getAccountModel();
private:
std::unique_ptr<LrcPimpl> lrcPipmpl_;
};
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// std
#include <ctime>
#include <string>
namespace lrc
{
namespace api
{
namespace message
{
enum class Type {
INVALID,
TEXT,
CALL,
CONTACT
};
enum class Status {
INVALID,
SENDING,
FAILED,
SUCCEED,
READ
};
struct Info
{
std::string contact;
std::string body;
std::time_t timestamp = 0;
Type type = Type::INVALID;
Status status = Status::INVALID;
};
} // namespace message
} // namespace api
} // namespace lrc
/****************************************************************************
* Copyright (C) 2017 Savoir-faire Linux *
* Author : Nicolas Jäger <nicolas.jager@savoirfairelinux.com> *
* Author : Sébastien Blin <sebastien.blin@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#pragma once
// std
#include <vector>
#include <map>
#include <memory>
#include <string>
// Qt
#include <qobject.h>
// Lrc
#include "typedefs.h"
namespace lrc
{
class Database;
class NewAccountModelPimpl;
namespace api
{
namespace account { struct Info; }
class LIB_EXPORT NewAccountModel : public QObject {
public: