Commit f59a8dbc authored by Édouard Denommée's avatar Édouard Denommée Committed by Sébastien Blin
Browse files

conversationsmodel: follow lrc api for copy reduction

Reducing the number of copies of account info objects and conversation
objects passed from lrc.

Related LRC patches: 16060, 15833, 15814

Change-Id: I0ff67e859250d6c6418754eddb82e8b2e3b40c17
parent f6d50ba8
......@@ -1150,14 +1150,14 @@ build_chat_view(ChatView* self)
GtkWidget *
chat_view_new (WebKitChatContainer* webkit_chat_container,
AccountInfoPointer const & accountInfo,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
lrc::api::AVModel& avModel)
{
ChatView *self = CHAT_VIEW(g_object_new(CHAT_VIEW_TYPE, NULL));
ChatViewPrivate *priv = CHAT_VIEW_GET_PRIVATE(self);
priv->webkit_chat_container = GTK_WIDGET(webkit_chat_container);
priv->conversation_ = conversation;
priv->conversation_ = &conversation;
priv->accountInfo_ = &accountInfo;
build_chat_view(self);
......@@ -1173,10 +1173,9 @@ chat_view_update_temporary(ChatView* self)
update_chatview_frame(self);
}
lrc::api::conversation::Info
lrc::api::conversation::Info&
chat_view_get_conversation(ChatView *self)
{
g_return_val_if_fail(IS_CHAT_VIEW(self), lrc::api::conversation::Info());
auto priv = CHAT_VIEW_GET_PRIVATE(self);
return *priv->conversation_;
}
......
......@@ -56,9 +56,9 @@ typedef struct _ChatViewClass ChatViewClass;
GType chat_view_get_type (void) G_GNUC_CONST;
GtkWidget *chat_view_new (WebKitChatContainer* view,
AccountInfoPointer const & accountInfo,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
lrc::api::AVModel& avModel);
lrc::api::conversation::Info chat_view_get_conversation(ChatView*);
lrc::api::conversation::Info& chat_view_get_conversation(ChatView*);
void chat_view_update_temporary(ChatView*);
void chat_view_set_header_visible(ChatView*, gboolean);
void chat_view_set_record_visible(ChatView*, gboolean);
......
......@@ -84,16 +84,14 @@ show_profile(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate* priv)
static void
remove_history_conversation(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate* priv)
{
try
{
if (!priv->cpp) return;
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(priv->cpp->uid_);
(*priv->accountInfo_)->conversationModel->clearHistory(conversation.uid);
}
catch (...)
{
if (!priv->cpp) return;
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(priv->cpp->uid_);
if (!convOpt) {
g_warning("Can't get conversation %s", priv->cpp? priv->cpp->uid_.toStdString().c_str() : "");
return;
}
(*priv->accountInfo_)->conversationModel->clearHistory(convOpt->get().uid);
}
static void
......@@ -113,25 +111,22 @@ remove_conversation(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate*
static void
unblock_conversation(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate* priv)
{
try
{
if (!priv->cpp) return;
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(priv->cpp->uid_);
auto uri = conversation.participants[0];
if (!priv->cpp) return;
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(priv->cpp->uid_);
if (!convOpt) {
g_warning("Can't get conversation %s", priv->cpp? priv->cpp->uid_.toStdString().c_str() : "");
return;
}
auto uri = convOpt->get().participants[0];
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(uri);
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(uri);
if (!contactInfo.isBanned) {
g_debug("unblock_conversation: trying to unban a contact which isn't banned !");
return;
}
(*priv->accountInfo_)->contactModel->addContact(contactInfo);
}
catch (...)
{
g_warning("Can't get conversation %s", priv->cpp? priv->cpp->uid_.toStdString().c_str() : "");
if (!contactInfo.isBanned) {
g_debug("unblock_conversation: trying to unban a contact which isn't banned !");
return;
}
(*priv->accountInfo_)->contactModel->addContact(contactInfo);
}
static void
......@@ -165,27 +160,26 @@ add_conversation(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate* pr
static void
place_video_call(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate* priv)
{
try
{
if (!priv->cpp) return;
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(priv->cpp->uid_);
(*priv->accountInfo_)->conversationModel->placeCall(conversation.uid);
} catch (...) {
if (!priv->cpp) return;
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(priv->cpp->uid_);
if (!convOpt) {
g_warning("Can't get conversation %s", priv->cpp? priv->cpp->uid_.toStdString().c_str() : "");
return;
}
(*priv->accountInfo_)->conversationModel->placeCall(convOpt->get().uid);
}
static void
place_audio_call(G_GNUC_UNUSED GtkWidget *menu, ConversationPopupMenuPrivate* priv)
{
try
{
if (!priv->cpp) return;
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(priv->cpp->uid_);
(*priv->accountInfo_)->conversationModel->placeAudioOnlyCall(conversation.uid);
} catch (...) {
if (!priv->cpp) return;
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(priv->cpp->uid_);
if (!convOpt) {
g_warning("Can't get conversation %s", priv->cpp? priv->cpp->uid_.toStdString().c_str() : "");
return;
}
(*priv->accountInfo_)->conversationModel->placeAudioOnlyCall(convOpt->get().uid);
}
/**
......@@ -208,14 +202,15 @@ update(GtkTreeSelection *selection, ConversationPopupMenu *self)
0 /* col# */, &uid /* data */,
-1);
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(uid);
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(uid);
if (priv->cpp) priv->cpp->uid_ = uid;
try {
if (conversation.participants.isEmpty()) {
if (!convOpt || convOpt->get().participants.isEmpty()) {
g_free(uid);
return;
}
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(conversation.participants.front());
auto& conv = convOpt->get();
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(conv.participants.front());
if (contactInfo.profileInfo.uri.isEmpty()) {
g_free(uid);
return;
......@@ -223,7 +218,7 @@ update(GtkTreeSelection *selection, ConversationPopupMenu *self)
// we always build a menu, however in some cases some or all of the conversations will be deactivated
// we prefer this to having an empty menu because GTK+ behaves weird in the empty menu case
auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
auto callId = conv.confId.isEmpty() ? conv.callId : conv.confId;
// Not in call
if (!contactInfo.isBanned && (*priv->accountInfo_)->enabled) {
......
......@@ -120,39 +120,34 @@ render_contact_photo(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
0 /* col# */, &uid /* data */,
-1);
try
{
// Draw first contact.
// NOTE: We just draw the first contact, must change this for conferences when they will have their own object
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(uid);
auto isPresent = false;
auto isBanned = false;
if (not conversation.participants.empty()) {
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(conversation.participants.front());
isPresent = contactInfo.isPresent;
isBanned = contactInfo.isBanned;
}
std::shared_ptr<GdkPixbuf> image;
auto var_photo = GlobalInstances::pixmapManipulator().conversationPhoto(
conversation,
**(priv->accountInfo_),
QSize(50, 50),
isPresent
);
image = var_photo.value<std::shared_ptr<GdkPixbuf>>();
// set the width of the cell rendered to the width of the photo
// so that the other renderers are shifted to the right
g_object_set(G_OBJECT(cell), "width", 50, NULL);
g_object_set(G_OBJECT(cell), "pixbuf", image.get(), NULL);
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(uid);
// Banned contacts should be displayed with grey bg
g_object_set(G_OBJECT(cell), "cell-background", isBanned ? "#BDBDBD" : NULL, NULL);
}
catch (const std::exception&)
{
g_warning("Can't get conversation %s", uid);
// Draw first contact.
// NOTE: We just draw the first contact, must change this for conferences when they will have their own object
auto isPresent = false;
auto isBanned = false;
if (convOpt && !convOpt->get().participants.empty()) {
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(convOpt->get().participants.front());
isPresent = contactInfo.isPresent;
isBanned = contactInfo.isBanned;
}
std::shared_ptr<GdkPixbuf> image;
static lrc::api::conversation::Info invalidConverstation = {.uid = "-1"};
auto var_photo = GlobalInstances::pixmapManipulator().conversationPhoto(
convOpt ? convOpt->get() : invalidConverstation,
**(priv->accountInfo_),
QSize(50, 50),
isPresent
);
image = var_photo.value<std::shared_ptr<GdkPixbuf>>();
// set the width of the cell rendered to the width of the photo
// so that the other renderers are shifted to the right
g_object_set(G_OBJECT(cell), "width", 50, NULL);
g_object_set(G_OBJECT(cell), "pixbuf", image.get(), NULL);
// Banned contacts should be displayed with grey bg
g_object_set(G_OBJECT(cell), "cell-background", isBanned ? "#BDBDBD" : NULL, NULL);
g_free(uid);
}
......@@ -191,10 +186,10 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
auto bestId = std::string(registeredName).empty() ? uri: registeredName;
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(uid);
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(uid);
auto isBanned = false;
if (not conversation.participants.empty()) {
auto contactUri = conversation.participants.front();
if (convOpt && not convOpt->get().participants.empty()) {
auto contactUri = convOpt->get().participants.front();
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(contactUri);
isBanned = contactInfo.isBanned;
}
......@@ -274,15 +269,16 @@ render_time(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
{
// Draw first contact.
// NOTE: We just draw the first contact, must change this for conferences when they will have their own object
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(uid);
if (conversation.participants.empty()) return;
auto contactUri = conversation.participants.front();
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(uid);
if (!convOpt || convOpt->get().participants.empty()) return;
auto& conv = convOpt->get();
auto contactUri = conv.participants.front();
auto& contactInfo = (*priv->accountInfo_)->contactModel->getContact(contactUri);
// Banned contacts should be displayed with grey bg
g_object_set(G_OBJECT(cell), "cell-background", contactInfo.isBanned ? "#BDBDBD" : NULL, NULL);
auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
auto callId = conv.confId.isEmpty() ? conv.callId : conv.confId;
if (!callId.isEmpty()) {
auto call = (*priv->accountInfo_)->callModel->getCall(callId);
if (call.status != lrc::api::call::Status::ENDED) {
......@@ -292,8 +288,8 @@ render_time(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
}
}
auto& interactions = conversation.interactions;
auto lastUid = conversation.lastMessageUid;
auto& interactions = conv.interactions;
auto lastUid = conv.lastMessageUid;
if (!interactions.empty() && interactions.find(lastUid) != interactions.end()) {
std::time_t lastTimestamp = interactions[lastUid].timestamp;
......@@ -336,23 +332,25 @@ update_conversation(ConversationsView *self, const std::string& uid) {
0 /* col# */, &uidModel /* data */,
-1);
if(std::string(uid) == uidModel) {
// Get information
auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(uidModel);
if (conversation.participants.empty()) {
// Get informations
auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(uidModel);
if (!convOpt || convOpt->get().participants.empty()) {
g_free(uidModel);
return;
}
auto contactUri = conversation.participants.front();
auto& conv = convOpt->get();
auto contactUri = conv.participants.front();
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(contactUri);
auto lastMessage = conversation.interactions.empty() ? "" :
conversation.interactions.at(conversation.lastMessageUid).body;
auto lastMessage = conv.interactions.empty() ? "" :
conv.interactions.at(conv.lastMessageUid).body;
std::replace(lastMessage.begin(), lastMessage.end(), '\n', ' ');
auto alias = contactInfo.profileInfo.alias;
alias.remove('\r');
// Update iter
gtk_list_store_set (GTK_LIST_STORE(model), &iter,
0 /* col # */ , qUtf8Printable(conversation.uid) /* celldata */,
0 /* col # */ , qUtf8Printable(conv.uid) /* celldata */,
1 /* col # */ , qUtf8Printable(alias) /* celldata */,
2 /* col # */ , qUtf8Printable(contactInfo.profileInfo.uri) /* celldata */,
3 /* col # */ , qUtf8Printable(contactInfo.registeredName) /* celldata */,
......@@ -396,7 +394,7 @@ create_and_fill_model(ConversationsView *self)
auto fillModelLambda = [&](const auto& queue) {
for (auto conversation : queue) {
for (const lrc::api::conversation::Info& conversation : queue) {
if (conversation.participants.empty()) {
g_debug("Found conversation with empty list of participants - most likely the result of earlier bug.");
break;
......@@ -426,7 +424,7 @@ create_and_fill_model(ConversationsView *self)
};
fillModelLambda((*priv->accountInfo_)->conversationModel->getAllSearchResults());
fillModelLambda((*priv->accountInfo_)->conversationModel->allFilteredConversations());
fillModelLambda((*priv->accountInfo_)->conversationModel->allFilteredConversations().get());
return GTK_TREE_MODEL (store);
}
......@@ -718,7 +716,7 @@ build_conversations_view(ConversationsView *self)
// This view should be synchronized and redraw at each update.
priv->modelSortedConnection_ = QObject::connect(
&*(*priv->accountInfo_)->conversationModel,
&lrc::api::ConversationModel::modelSorted,
&lrc::api::ConversationModel::modelChanged,
[self] () {
auto model = create_and_fill_model(self);
......
......@@ -236,7 +236,7 @@ public:
void init();
void setup(WebKitChatContainer* chat_widget,
AccountInfoPointer const & account_info,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
lrc::api::AVModel& avModel);
void updateConvList();
......@@ -1030,11 +1030,11 @@ CppImpl::init()
void
CppImpl::setup(WebKitChatContainer* chat_widget,
AccountInfoPointer const & account_info,
lrc::api::conversation::Info* conv_info,
lrc::api::conversation::Info& conv_info,
lrc::api::AVModel& avModel)
{
widgets->webkit_chat_container = GTK_WIDGET(chat_widget);
conversation = conv_info;
conversation = &conv_info;
accountInfo = &account_info;
avModel_ = &avModel;
setCallInfo();
......@@ -1052,8 +1052,8 @@ CppImpl::setup(WebKitChatContainer* chat_widget,
gtk_container_remove(GTK_CONTAINER(widgets->list_conversations), children);
// Fill with SIP contacts
add_transfer_contact(""); // Temporary item
for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations(lrc::api::profile::Type::SIP))
add_transfer_contact(c.participants.front().toStdString());
for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations(lrc::api::profile::Type::SIP).get())
add_transfer_contact(c.get().participants.front().toStdString());
gtk_widget_show_all(widgets->list_conversations);
gtk_widget_show(widgets->togglebutton_transfer);
gtk_widget_show(widgets->togglebutton_hold);
......@@ -1226,9 +1226,9 @@ CppImpl::updateConvList()
}
first = true;
for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations((*accountInfo)->profileInfo.type)) {
for (const auto& c : (*accountInfo)->conversationModel->getFilteredConversations((*accountInfo)->profileInfo.type).get()) {
try {
auto participant = c.participants.front();
auto participant = c.get().participants.front();
auto contactInfo = (*accountInfo)->contactModel->getContact(participant);
auto isPresent = std::find(uris.cbegin(), uris.cend(), participant) != uris.cend();
if (!isPresent
......@@ -1570,7 +1570,7 @@ CppImpl::setCallInfo()
// init chat view
widgets->chat_view = chat_view_new(WEBKIT_CHAT_CONTAINER(widgets->webkit_chat_container),
*accountInfo, conversation, *avModel_);
*accountInfo, *conversation, *avModel_);
gtk_container_add(GTK_CONTAINER(widgets->frame_chat), widgets->chat_view);
chat_view_set_header_visible(CHAT_VIEW(widgets->chat_view), FALSE);
......@@ -2035,10 +2035,9 @@ CppImpl::set_remote_record_animation(std::string callId, QSet<QString> peerName,
//==============================================================================
lrc::api::conversation::Info
lrc::api::conversation::Info&
current_call_view_get_conversation(CurrentCallView *self)
{
g_return_val_if_fail(IS_CURRENT_CALL_VIEW(self), lrc::api::conversation::Info());
auto* priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
return *priv->cpp->conversation;
}
......@@ -2156,7 +2155,7 @@ current_call_view_class_init(CurrentCallViewClass *klass)
GtkWidget *
current_call_view_new(WebKitChatContainer* chat_widget,
AccountInfoPointer const & accountInfo,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
lrc::api::AVModel& avModel,
const lrc::api::Lrc& lrc)
{
......
......@@ -54,10 +54,10 @@ typedef struct _CurrentCallViewClass CurrentCallViewClass;
GType current_call_view_get_type (void) G_GNUC_CONST;
GtkWidget *current_call_view_new (WebKitChatContainer* view,
AccountInfoPointer const & accountInfo,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
lrc::api::AVModel& avModel,
const lrc::api::Lrc& lrc);
lrc::api::conversation::Info current_call_view_get_conversation(CurrentCallView*);
lrc::api::conversation::Info& current_call_view_get_conversation(CurrentCallView*);
GtkWidget *current_call_view_get_chat_view(CurrentCallView*);
std::string current_call_view_get_rendered_call(CurrentCallView*);
void current_call_view_show_chat(CurrentCallView*);
......
......@@ -319,7 +319,7 @@ set_call_info(IncomingCallView *view) {
auto chat_view = chat_view_new(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
*priv->accountInfo_,
priv->conversation_,
*priv->conversation_,
*priv->avModel_);
gtk_widget_show(chat_view);
chat_view_set_header_visible(CHAT_VIEW(chat_view), FALSE);
......@@ -331,13 +331,13 @@ GtkWidget *
incoming_call_view_new(WebKitChatContainer* view,
lrc::api::AVModel& avModel,
AccountInfoPointer const & accountInfo,
lrc::api::conversation::Info* conversation)
lrc::api::conversation::Info& conversation)
{
auto self = g_object_new(INCOMING_CALL_VIEW_TYPE, NULL);
IncomingCallViewPrivate *priv = INCOMING_CALL_VIEW_GET_PRIVATE(self);
priv->webkit_chat_container = GTK_WIDGET(view);
priv->conversation_ = conversation;
priv->conversation_ = &conversation;
priv->accountInfo_ = &accountInfo;
priv->avModel_ = &avModel;
......@@ -350,17 +350,16 @@ incoming_call_view_new(WebKitChatContainer* view,
return GTK_WIDGET(self);
}
lrc::api::conversation::Info
lrc::api::conversation::Info&
incoming_call_view_get_conversation(IncomingCallView *self)
{
g_return_val_if_fail(IS_INCOMING_CALL_VIEW(self), lrc::api::conversation::Info());
auto priv = INCOMING_CALL_VIEW_GET_PRIVATE(self);
return *priv->conversation_;
}
void
incoming_call_view_let_a_message(IncomingCallView* view, lrc::api::conversation::Info conv)
incoming_call_view_let_a_message(IncomingCallView* view, const lrc::api::conversation::Info& conv)
{
g_return_if_fail(IS_INCOMING_CALL_VIEW(view));
auto priv = INCOMING_CALL_VIEW_GET_PRIVATE(view);
......@@ -376,7 +375,7 @@ incoming_call_view_let_a_message(IncomingCallView* view, lrc::api::conversation:
}
bool
is_showing_let_a_message_view(IncomingCallView* view, lrc::api::conversation::Info conv)
is_showing_let_a_message_view(IncomingCallView* view, lrc::api::conversation::Info& conv)
{
g_return_val_if_fail(IS_INCOMING_CALL_VIEW(view), false);
auto priv = INCOMING_CALL_VIEW_GET_PRIVATE(view);
......
......@@ -57,9 +57,9 @@ GType incoming_call_view_get_type (void) G_GNUC_CONST;
GtkWidget *incoming_call_view_new (WebKitChatContainer* view,
lrc::api::AVModel& avModel,
AccountInfoPointer const & accountInfo,
lrc::api::conversation::Info* conversation);
void incoming_call_view_let_a_message(IncomingCallView* view, lrc::api::conversation::Info conv);
bool is_showing_let_a_message_view(IncomingCallView* view, lrc::api::conversation::Info conv);
lrc::api::conversation::Info incoming_call_view_get_conversation (IncomingCallView*);
lrc::api::conversation::Info& conversation);
void incoming_call_view_let_a_message(IncomingCallView* view, const lrc::api::conversation::Info& conv);
bool is_showing_let_a_message_view(IncomingCallView* view, lrc::api::conversation::Info& conv);
lrc::api::conversation::Info& incoming_call_view_get_conversation (IncomingCallView*);
G_END_DECLS
This diff is collapsed.
......@@ -88,7 +88,7 @@ public:
void init();
void setup(lrc::api::AVModel& avModel,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
AccountInfoPointer const & accountInfo);
void set_state(MessagingWidgetState newState);
......@@ -206,10 +206,10 @@ CppImpl::init()
void
CppImpl::setup(lrc::api::AVModel& avModel,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
AccountInfoPointer const & accountInfo)
{
conversation_ = conversation;
conversation_ = &conversation;
accountInfo_ = &accountInfo;
avModel_ = &avModel;
}
......@@ -339,7 +339,7 @@ messaging_widget_init(MessagingWidget *self)
GtkWidget*
messaging_widget_new(lrc::api::AVModel& avModel,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
AccountInfoPointer const & accountInfo)
{
auto self = g_object_new(MESSAGING_WIDGET_TYPE, NULL);
......
......@@ -60,7 +60,7 @@ typedef enum
GType messaging_widget_get_type (void) G_GNUC_CONST;
GtkWidget* messaging_widget_new (lrc::api::AVModel& avModel,
lrc::api::conversation::Info* conversation,
lrc::api::conversation::Info& conversation,
AccountInfoPointer const & accountInfo);
void messaging_widget_set_peer_name (MessagingWidget *self, std::string name);
......
......@@ -112,9 +112,9 @@ build_view(ProfileView* view)
try
{
const auto conversation = (*priv->accountInfo_)->conversationModel->getConversationForUID(priv->cpp->uid_);
if (conversation.participants.empty()) return false;
const auto& contact = (*priv->accountInfo_)->contactModel->getContact(conversation.participants.front());
const auto convOpt = (*priv->accountInfo_)->conversationModel->getConversationForUid(priv->cpp->uid_);
if (!convOpt || convOpt->get().participants.empty()) return false;
const auto& contact = (*priv->accountInfo_)->contactModel->getContact(convOpt->get().participants.front());
auto alias = contact.profileInfo.alias;
alias.remove('\r');
......@@ -139,7 +139,7 @@ build_view(ProfileView* view)
uint32_t img_size = 128;
std::shared_ptr<GdkPixbuf> image;
auto var_photo = GlobalInstances::pixmapManipulator().conversationPhoto(
conversation,
*convOpt,
**(priv->accountInfo_),
QSize(img_size, img_size),
false
......@@ -190,4 +190,4 @@ profile_view_new(AccountInfoPointer const & accountInfo, const QString& uid)
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
return static_cast<GtkWidget*>(view);
}
\ No newline at end of file
}
......@@ -331,7 +331,7 @@ on_hangup(GtkButton *button, VideoWidget *self)
auto call = callModel->getCall(priv->cpp->callId);
auto callId = "";
auto conversations = (*priv->cpp->accountInfo)->conversationModel->allFilteredConversations();
for (const auto& conversation: conversations) {
for (const lrc::api::conversation::Info& conversation: conversations.get()) {
if (conversation.participants.empty()) continue;
auto participant = conversation.participants.front();
if (uri == participant) {
......@@ -1276,4 +1276,4 @@ video_widget_set_preview_visible(VideoWidget *self, bool show)
else
clutter_actor_show(priv->local->actor);
}
}
\ No newline at end of file
}
Supports Markdown
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