Commit 989bbc4e authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): use new compilations flags

parent 24eb82f6
...@@ -12,6 +12,22 @@ set(CMAKE_CXX_STANDARD 11) ...@@ -12,6 +12,22 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
# -Wold-style-cast \
set(CUSTOM_FLAGS "\
-Wcast-align \
-Wconversion \
-Wextra \
-Wfloat-equal \
-Winit-self \
-Winline \
-Wlogical-op \
-Woverloaded-virtual \
-Wpointer-arith \
-Wuninitialized \
-Wunused \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS}")
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Define packages, libs, sources, headers, resources and languages # Define packages, libs, sources, headers, resources and languages
# -------------------------------------------------------------------- # --------------------------------------------------------------------
......
...@@ -140,11 +140,13 @@ ...@@ -140,11 +140,13 @@
<file>ui/modules/Linphone/Styles/qmldir</file> <file>ui/modules/Linphone/Styles/qmldir</file>
<file>ui/modules/Linphone/Styles/TimelineStyle.qml</file> <file>ui/modules/Linphone/Styles/TimelineStyle.qml</file>
<file>ui/modules/Linphone/Timeline.qml</file> <file>ui/modules/Linphone/Timeline.qml</file>
<file>ui/scripts/LinphoneUtils/linphone-utils.js</file>
<file>ui/scripts/LinphoneUtils/qmldir</file>
<file>ui/scripts/Utils/qmldir</file> <file>ui/scripts/Utils/qmldir</file>
<file>ui/scripts/Utils/uri-tools.js</file> <file>ui/scripts/Utils/uri-tools.js</file>
<file>ui/scripts/Utils/utils.js</file> <file>ui/scripts/Utils/utils.js</file>
<file>ui/views/App/Calls/AbstractCall.qml</file>
<file>ui/views/App/Calls/Calls.qml</file> <file>ui/views/App/Calls/Calls.qml</file>
<file>ui/views/App/Calls/StartingCall.qml</file>
<file>ui/views/App/Calls/StartingIncomingCall.qml</file> <file>ui/views/App/Calls/StartingIncomingCall.qml</file>
<file>ui/views/App/Calls/StartingOutgoingCall.qml</file> <file>ui/views/App/Calls/StartingOutgoingCall.qml</file>
<file>ui/views/App/MainWindow/Contact.qml</file> <file>ui/views/App/MainWindow/Contact.qml</file>
......
...@@ -20,6 +20,10 @@ QHash<int, QByteArray> ChatModel::roleNames () const { ...@@ -20,6 +20,10 @@ QHash<int, QByteArray> ChatModel::roleNames () const {
return roles; return roles;
} }
int ChatModel::rowCount (const QModelIndex &) const {
return m_entries.count();
}
QVariant ChatModel::data (const QModelIndex &index, int role) const { QVariant ChatModel::data (const QModelIndex &index, int role) const {
int row = index.row(); int row = index.row();
...@@ -88,7 +92,9 @@ void ChatModel::fillMessageEntry ( ...@@ -88,7 +92,9 @@ void ChatModel::fillMessageEntry (
const shared_ptr<linphone::ChatMessage> &message const shared_ptr<linphone::ChatMessage> &message
) { ) {
dest["type"] = EntryType::MessageEntry; dest["type"] = EntryType::MessageEntry;
dest["timestamp"] = QDateTime::fromTime_t(message->getTime()); dest["timestamp"] = QDateTime::fromMSecsSinceEpoch(
static_cast<qint64>(message->getTime()) * 1000
);
dest["content"] = Utils::linphoneStringToQString( dest["content"] = Utils::linphoneStringToQString(
message->getText() message->getText()
); );
...@@ -97,9 +103,11 @@ void ChatModel::fillMessageEntry ( ...@@ -97,9 +103,11 @@ void ChatModel::fillMessageEntry (
void ChatModel::fillCallStartEntry ( void ChatModel::fillCallStartEntry (
QVariantMap &dest, QVariantMap &dest,
const std::shared_ptr<linphone::CallLog> &call_log const shared_ptr<linphone::CallLog> &call_log
) { ) {
QDateTime timestamp = QDateTime::fromTime_t(call_log->getStartDate()); QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(
static_cast<qint64>(call_log->getStartDate()) * 1000
);
dest["type"] = EntryType::CallEntry; dest["type"] = EntryType::CallEntry;
dest["timestamp"] = timestamp; dest["timestamp"] = timestamp;
...@@ -110,10 +118,10 @@ void ChatModel::fillCallStartEntry ( ...@@ -110,10 +118,10 @@ void ChatModel::fillCallStartEntry (
void ChatModel::fillCallEndEntry ( void ChatModel::fillCallEndEntry (
QVariantMap &dest, QVariantMap &dest,
const std::shared_ptr<linphone::CallLog> &call_log const shared_ptr<linphone::CallLog> &call_log
) { ) {
QDateTime timestamp = QDateTime::fromTime_t( QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(
call_log->getStartDate() + call_log->getDuration() static_cast<qint64>(call_log->getStartDate() + call_log->getDuration()) * 1000
); );
dest["type"] = EntryType::CallEntry; dest["type"] = EntryType::CallEntry;
...@@ -139,7 +147,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) { ...@@ -139,7 +147,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
// WARNING: Unable to remove symmetric call here. (start/end) // WARNING: Unable to remove symmetric call here. (start/end)
// We are between `beginRemoveRows` and `endRemoveRows`. // We are between `beginRemoveRows` and `endRemoveRows`.
// A solution is to schedule a `removeEntry` call in the Qt main loop. // A solution is to schedule a `removeEntry` call in the Qt main loop.
std::shared_ptr<void> linphone_ptr = pair.second; shared_ptr<void> linphone_ptr = pair.second;
QTimer::singleShot(0, this, [this, linphone_ptr]() { QTimer::singleShot(0, this, [this, linphone_ptr]() {
auto it = find_if( auto it = find_if(
m_entries.begin(), m_entries.end(), m_entries.begin(), m_entries.end(),
...@@ -149,7 +157,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) { ...@@ -149,7 +157,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
); );
if (it != m_entries.end()) if (it != m_entries.end())
removeEntry(distance(m_entries.begin(), it)); removeEntry(static_cast<int>(distance(m_entries.begin(), it)));
}); });
} }
......
...@@ -47,9 +47,7 @@ public: ...@@ -47,9 +47,7 @@ public:
ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {} ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {}
int rowCount (const QModelIndex &index = QModelIndex()) const { int rowCount (const QModelIndex &index = QModelIndex()) const;
return m_entries.count();
}
QHash<int, QByteArray> roleNames () const; QHash<int, QByteArray> roleNames () const;
QVariant data (const QModelIndex &index, int role) const; QVariant data (const QModelIndex &index, int role) const;
......
...@@ -75,7 +75,7 @@ private: ...@@ -75,7 +75,7 @@ private:
ChatModelFilter m_chat_model_filter; ChatModelFilter m_chat_model_filter;
unsigned int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE; int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE;
static const unsigned int ENTRIES_CHUNK_SIZE; static const unsigned int ENTRIES_CHUNK_SIZE;
}; };
......
...@@ -24,6 +24,10 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren ...@@ -24,6 +24,10 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren
} }
} }
int ContactsListModel::rowCount (const QModelIndex &) const {
return m_list.count();
}
QHash<int, QByteArray> ContactsListModel::roleNames () const { QHash<int, QByteArray> ContactsListModel::roleNames () const {
QHash<int, QByteArray> roles; QHash<int, QByteArray> roles;
roles[Qt::DisplayRole] = "$contact"; roles[Qt::DisplayRole] = "$contact";
......
...@@ -16,9 +16,7 @@ class ContactsListModel : public QAbstractListModel { ...@@ -16,9 +16,7 @@ class ContactsListModel : public QAbstractListModel {
public: public:
ContactsListModel (QObject *parent = Q_NULLPTR); ContactsListModel (QObject *parent = Q_NULLPTR);
int rowCount (const QModelIndex &index = QModelIndex()) const { int rowCount (const QModelIndex &index = QModelIndex()) const;
return m_list.count();
}
QHash<int, QByteArray> roleNames () const; QHash<int, QByteArray> roleNames () const;
QVariant data (const QModelIndex &index, int role) const; QVariant data (const QModelIndex &index, int role) const;
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
#include "ContactsListProxyModel.hpp" #include "ContactsListProxyModel.hpp"
#define USERNAME_WEIGHT 50.0 #define USERNAME_WEIGHT 50.0f
#define MAIN_SIP_ADDRESS_WEIGHT 25.0 #define MAIN_SIP_ADDRESS_WEIGHT 25.0f
#define OTHER_SIP_ADDRESSES_WEIGHT 25.0 #define OTHER_SIP_ADDRESSES_WEIGHT 25.0f
#define FACTOR_POS_1 0.90 #define FACTOR_POS_1 0.90f
#define FACTOR_POS_2 0.80 #define FACTOR_POS_2 0.80f
#define FACTOR_POS_3 0.70 #define FACTOR_POS_3 0.70f
#define FACTOR_POS_OTHER 0.60 #define FACTOR_POS_OTHER 0.60f
using namespace std; using namespace std;
...@@ -63,7 +63,9 @@ bool ContactsListProxyModel::filterAcceptsRow ( ...@@ -63,7 +63,9 @@ bool ContactsListProxyModel::filterAcceptsRow (
index.data() index.data()
); );
int weight = m_weights[contact] = computeContactWeight(*contact); unsigned int weight = m_weights[contact] = static_cast<unsigned int>(
computeContactWeight(*contact)
);
return weight > 0 && ( return weight > 0 && (
!m_use_connected_filter || !m_use_connected_filter ||
...@@ -79,8 +81,8 @@ bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelInde ...@@ -79,8 +81,8 @@ bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelInde
sourceModel()->data(right) sourceModel()->data(right)
); );
float weight_a = m_weights[contact_a]; unsigned int weight_a = m_weights[contact_a];
float weight_b = m_weights[contact_b]; unsigned int weight_b = m_weights[contact_b];
// Sort by weight and name. // Sort by weight and name.
return ( return (
...@@ -139,8 +141,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) ...@@ -139,8 +141,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact)
); );
// Compute for other addresses. // Compute for other addresses.
int size = addresses.size(); float size = static_cast<float>(addresses.size());
for (++it; it != addresses.cend(); ++it) for (++it; it != addresses.cend(); ++it)
weight += computeStringWeight( weight += computeStringWeight(
Utils::linphoneStringToQString((*it)->asString()), Utils::linphoneStringToQString((*it)->asString()),
......
...@@ -50,7 +50,7 @@ private: ...@@ -50,7 +50,7 @@ private:
// It's just a cache to save values computed by `filterAcceptsRow` // It's just a cache to save values computed by `filterAcceptsRow`
// and reused by `lessThan`. // and reused by `lessThan`.
mutable QHash<const ContactModel *, int> m_weights; mutable QHash<const ContactModel *, unsigned int> m_weights;
bool m_use_connected_filter; bool m_use_connected_filter;
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
CoreManager *CoreManager::m_instance = nullptr; CoreManager *CoreManager::m_instance = nullptr;
CoreManager::CoreManager (QObject *parent) : m_core( CoreManager::CoreManager (QObject *parent) : QObject(parent), m_core(
linphone::Factory::get()->createCore(nullptr, "", "", nullptr) linphone::Factory::get()->createCore(nullptr, "", "", nullptr)
) { ) {
setDatabasesPaths(); setDatabasesPaths();
......
...@@ -81,7 +81,9 @@ void TimelineModel::init_entries () { ...@@ -81,7 +81,9 @@ void TimelineModel::init_entries () {
// Insert event message in timeline entries. // Insert event message in timeline entries.
QVariantMap map; QVariantMap map;
map["timestamp"] = QDateTime::fromTime_t(message->getTime()); map["timestamp"] = QDateTime::fromMSecsSinceEpoch(
static_cast<qint64>(message->getTime()) * 1000
);
map["sipAddresses"] = Utils::linphoneStringToQString( map["sipAddresses"] = Utils::linphoneStringToQString(
chat_room->getPeerAddress()->asString() chat_room->getPeerAddress()->asString()
); );
...@@ -104,8 +106,8 @@ void TimelineModel::init_entries () { ...@@ -104,8 +106,8 @@ void TimelineModel::init_entries () {
// Make a new map. // Make a new map.
QVariantMap map; QVariantMap map;
map["timestamp"] = QDateTime::fromTime_t( map["timestamp"] = QDateTime::fromMSecsSinceEpoch(
call_log->getStartDate() + call_log->getDuration() static_cast<qint64>(call_log->getStartDate() + call_log->getDuration()) * 1000
); );
map["sipAddresses"] = address; map["sipAddresses"] = address;
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
#include <QString> #include <QString>
// ===================================================================
namespace Utils { namespace Utils {
inline QString linphoneStringToQString (const std::string &string) { inline QString linphoneStringToQString (const std::string &string) {
return QString::fromLocal8Bit(string.c_str(), string.size()); return QString::fromLocal8Bit(string.c_str(), static_cast<int>(string.size()));
} }
inline std::string qStringToLinphoneString (const QString &string) { inline std::string qStringToLinphoneString (const QString &string) {
......
...@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3 ...@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Linphone 1.0 import Linphone 1.0
import LinphoneUtils 1.0
import Linphone.Styles 1.0 import Linphone.Styles 1.0
import Utils 1.0 import Utils 1.0
...@@ -39,9 +40,7 @@ Rectangle { ...@@ -39,9 +40,7 @@ Rectangle {
Layout.preferredWidth: ContactStyle.contentHeight Layout.preferredWidth: ContactStyle.contentHeight
image: contact.avatar || '' image: contact.avatar || ''
presenceLevel: contact.presenceLevel || Presence.White presenceLevel: contact.presenceLevel || Presence.White
username: Utils.isString(contact) username: LinphoneUtils.getContactUsername(contact)
? contact.substring(4, contact.indexOf('@')) // 4 = length("sip:")
: contact.username
} }
ContactDescription { ContactDescription {
......
...@@ -26,43 +26,48 @@ Window { ...@@ -26,43 +26,48 @@ Window {
// Calls list. // Calls list.
// --------------------------------------------------------------- // ---------------------------------------------------------------
childA: ColumnLayout { childA: Rectangle {
anchors.fill: parent anchors.fill: parent
spacing: 0 color: 'yellow'
}
Rectangle {
Layout.fillWidth: true /* childA: ColumnLayout { */
Layout.preferredHeight: 50 /* anchors.fill: parent */
color: '#FFFFFF' /* spacing: 0 */
ActionBar { /* Rectangle { */
anchors.verticalCenter: parent.verticalCenter /* Layout.fillWidth: true */
anchors.leftMargin: 10 /* Layout.preferredHeight: 50 */
anchors.left: parent.left /* color: '#FFFFFF' */
iconSize: 30
spacing: 16 /* ActionBar { */
/* anchors.verticalCenter: parent.verticalCenter */
ActionButton { /* anchors.leftMargin: 10 */
icon: 'call' /* anchors.left: parent.left */
} /* iconSize: 30 */
/* spacing: 16 */
ActionButton {
icon: 'conference' /* ActionButton { */
} /* icon: 'call' */
} /* } */
}
/* ActionButton { */
ScrollableListView { /* icon: 'conference' */
Layout.fillWidth: true /* } */
Layout.fillHeight: true /* } */
spacing: 1 /* } */
delegate: CallControls {
width: parent.width /* ScrollableListView { */
} /* Layout.fillWidth: true */
/* Layout.fillHeight: true */
model: callsList /* spacing: 1 */
} /* delegate: CallControls { */
} /* width: parent.width */
/* } */
/* model: callsList */
/* } */
/* } */
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Content. // Content.
...@@ -78,14 +83,20 @@ Window { ...@@ -78,14 +83,20 @@ Window {
resizeAInPriority: true resizeAInPriority: true
// Call. // Call.
childA: Rectangle { childA: AbstractCall {
anchors.fill: parent anchors.fill: parent
callTypeLabel: 'INCOMING VIDEO CALL'
} }
// Chat. childB: Rectangle {
childB: Chat {
anchors.fill: parent anchors.fill: parent
color: 'green'
} }
// Chat.
//childB: Chat {
// anchors.fill: parent
//}
} }
} }
......
import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
Rectangle {
property alias callType: callType.text
property alias sipAddress: contactDescription.sipAddress
property alias username: contactDescription.username
property alias avatarImage: image.source
default property alias _actionArea: actionArea.data
color: '#EAEAEA'
ColumnLayout {
anchors {
fill: parent
margins: 20
}
spacing: 0
// Call type.
Column {
Layout.fillWidth: true
Text {
id: callType
color: '#8E8E8E'
font.bold: true
font.pointSize: 17
horizontalAlignment: Text.AlignHCenter
width: parent.width
}
CaterpillarAnimation {
anchors.horizontalCenter: parent.horizontalCenter
}
}
// Contact area.
Item {
id: contactContainer
Layout.fillWidth: true
Layout.fillHeight: true
Item {
anchors.verticalCenter: parent.verticalCenter
implicitHeight: contactDescription.height + image.height
width: parent.width
ContactDescription {
id: contactDescription
height: 60
horizontalTextAlignment: Text.AlignHCenter
width: parent.width
}
RoundedImage {
id: image
function _computeImageSize () {
var height = contactContainer.height - contactDescription.height
var width = contactContainer.width
var size = height < 400 ? height : 400
return size < width ? size : width
}
anchors.top: contactDescription.bottom
anchors.horizontalCenter: parent.horizontalCenter
height: _computeImageSize()
width: height
}
}
}
// Actions area.
Item {
id: actionArea
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Layout.preferredHeight: 80
Layout.topMargin: 20
}
}
}
...@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3 ...@@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Linphone 1.0 import Linphone 1.0
import LinphoneUtils 1.0
import Utils 1.0 import Utils 1.0
import App.Styles 1.0 import App.Styles 1.0
...@@ -57,9 +58,7 @@ ColumnLayout { ...@@ -57,9 +58,7 @@ ColumnLayout {
Layout.preferredHeight: ConversationStyle.bar.avatarSize Layout.preferredHeight: ConversationStyle.bar.avatarSize
Layout.preferredWidth: ConversationStyle.bar.avatarSize Layout.preferredWidth: ConversationStyle.bar.avatarSize
presenceLevel: _contact.presenceLevel || Presence.White presenceLevel: _contact.presenceLevel || Presence.White
username: Utils.isString(_contact) username: LinphoneUtils.getContactUsername(_contact)
? _contact.substring(4, _contact.indexOf('@')) // 4 = length("sip:")
: _contact.username
} }
ContactDescription { ContactDescription {
......
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