Commit 4f6f5f5d authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin
Browse files

lrc api: interface lrc Qt objects

Change-Id: I62671db5878f84ed7217bc83b09cacd02b450677
parent 1f0a1a40
......@@ -312,11 +312,11 @@ connect_to_manager(AccountCreationWizard *view, gchar* username, gchar* password
auto* priv = ACCOUNT_CREATION_WIZARD_GET_PRIVATE(view);
g_signal_emit(G_OBJECT(view), account_creation_wizard_signals[ACCOUNT_CREATION_LOCK], 0);
std::string accountId = lrc::api::NewAccountModel::connectToAccountManager(
auto accountId = lrc::api::NewAccountModel::connectToAccountManager(
username? username : "",
password? password : "",
managerUri? managerUri : "");
priv->accountId = g_strdup(accountId.c_str());
priv->accountId = g_strdup(qUtf8Printable(accountId));
// NOTE: NewAccountModel::accountAdded will be triggered here and will call account_creation_wizard_account_added
g_object_ref(view); // ref so its not destroyed too early
......@@ -339,13 +339,13 @@ create_account(AccountCreationWizard *view,
priv->username = g_strdup(username);
priv->password = g_strdup(password);
std::string accountId = lrc::api::NewAccountModel::createNewAccount(
auto accountId = lrc::api::NewAccountModel::createNewAccount(
lrc::api::profile::Type::RING,
display_name? display_name : "",
archivePath? archivePath : "",
password? password : "",
pin? pin : "");
priv->accountId = g_strdup(accountId.c_str());
priv->accountId = g_strdup(qUtf8Printable(accountId));
priv->avatar = g_strdup(avatar_manipulation_get_temporary(AVATAR_MANIPULATION(priv->avatar_manipulation)));
// NOTE: NewAccountModel::accountAdded will be triggered here and will call account_creation_wizard_account_added
......@@ -761,9 +761,9 @@ choose_export_file(AccountCreationWizard *view)
nullptr);
const auto& accountInfo = priv->accountModel_->getAccountInfo(priv->accountId);
std::string alias = accountInfo.profileInfo.alias;
std::string uri = alias.empty()? "export.gz" : alias + ".gz";
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), uri.c_str());
auto alias = accountInfo.profileInfo.alias;
auto uri = alias.isEmpty() ? "export.gz" : alias + ".gz";
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), qUtf8Printable(uri));
res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
......@@ -803,7 +803,7 @@ choose_export_file(AccountCreationWizard *view)
}
// export account
auto success = priv->accountModel_->exportToFile(priv->accountId, filename, password);
auto success = priv->accountModel_->exportToFile(priv->accountId, filename, password.c_str());
std::string label = success? _("Account exported!") : _("Export account failure.");
gtk_button_set_label(GTK_BUTTON(priv->button_export_account), label.c_str());
g_free(filename);
......
......@@ -152,7 +152,7 @@ migrate(AccountMigrationView *view)
const gchar *password = gtk_entry_get_text(GTK_ENTRY(priv->entry_password));
priv->state_changed = QObject::connect((*priv->accountInfo_)->accountModel,
&lrc::api::NewAccountModel::migrationEnded,
[=] (const std::string&, bool ok)
[=] (const QString&, bool ok)
{
gtk_widget_hide(priv->hbox_migrating_account_spinner);
gtk_widget_set_sensitive(GTK_WIDGET(priv->button_delete_account), true);
......@@ -215,23 +215,23 @@ build_migration_view(AccountMigrationView *view)
g_signal_connect_swapped(priv->button_delete_account, "clicked", G_CALLBACK(delete_account), view);
g_signal_connect_swapped(priv->entry_password, "activate", G_CALLBACK(migrate), view);
gtk_label_set_text(GTK_LABEL(priv->label_account_alias), (*priv->accountInfo_)->profileInfo.alias.c_str());
gtk_label_set_text(GTK_LABEL(priv->label_account_alias), qUtf8Printable((*priv->accountInfo_)->profileInfo.alias));
// display the ringID (without "ring:")
g_debug("MIGRATE FOR %s", (*priv->accountInfo_)->id.c_str());
std::string username = (*priv->accountInfo_)->registeredName;
g_debug("MIGRATE FOR %s", qUtf8Printable((*priv->accountInfo_)->id));
auto username = (*priv->accountInfo_)->registeredName;
try {
auto conf = (*priv->accountInfo_)->accountModel->getAccountConfig((*priv->accountInfo_)->id);
if (username.empty() && !conf.managerUsername.empty()) {
if (username.isEmpty() && !conf.managerUsername.isEmpty()) {
username = conf.managerUsername;
}
gtk_label_set_text(GTK_LABEL(priv->label_account_username), username.c_str());
if (username.empty()) {
gtk_label_set_text(GTK_LABEL(priv->label_account_username), qUtf8Printable(username));
if (username.isEmpty()) {
gtk_widget_hide(priv->username_row);
}
std::string manager = conf.managerUri;
gtk_label_set_text(GTK_LABEL(priv->label_account_manager), manager.c_str());
if (manager.empty()) {
auto manager = conf.managerUri;
gtk_label_set_text(GTK_LABEL(priv->label_account_manager), qUtf8Printable(manager));
if (manager.isEmpty()) {
gtk_widget_hide(priv->manager_row);
}
} catch (...) {
......@@ -244,8 +244,8 @@ build_migration_view(AccountMigrationView *view)
auto default_scaled = Interfaces::PixbufManipulator().scaleAndFrame(default_avatar.get(), QSize(AVATAR_WIDTH, AVATAR_HEIGHT));
auto photo = default_scaled;
auto photostr = (*priv->accountInfo_)->profileInfo.avatar;
if (!photostr.empty()) {
QByteArray byteArray(photostr.c_str(), photostr.length());
if (!photostr.isEmpty()) {
QByteArray byteArray = photostr.toUtf8();
QVariant avatar = Interfaces::PixbufManipulator().personPhoto(byteArray);
auto pixbuf_photo = Interfaces::PixbufManipulator().scaleAndFrame(avatar.value<std::shared_ptr<GdkPixbuf>>().get(), QSize(AVATAR_WIDTH, AVATAR_HEIGHT));
if (avatar.isValid()) {
......
......@@ -236,7 +236,7 @@ set_state(AvatarManipulation *self, AvatarManipulationState state)
auto photo = default_scaled;
if ((priv->accountInfo_ && (*priv->accountInfo_)) || priv->temporaryAvatar) {
auto photostr = priv->temporaryAvatar? priv->temporaryAvatar : (*priv->accountInfo_)->profileInfo.avatar;
QByteArray byteArray(photostr.c_str(), photostr.length());
QByteArray byteArray = photostr.toUtf8();
QVariant avatar = Interfaces::PixbufManipulator().personPhoto(byteArray);
if (avatar.isValid()) {
auto size = QSize(AVATAR_WIDTH, AVATAR_HEIGHT);
......@@ -368,7 +368,7 @@ set_avatar(AvatarManipulation *self)
/* save in profile */
if (priv->accountInfo_ && (*priv->accountInfo_)) {
try {
(*priv->accountInfo_)->accountModel->setAvatar((*priv->accountInfo_)->id, png_q_byte_array.toStdString());
(*priv->accountInfo_)->accountModel->setAvatar((*priv->accountInfo_)->id, png_q_byte_array);
} catch (std::out_of_range&) {
g_warning("Can't set avatar for unknown account");
}
......
......@@ -240,7 +240,7 @@ placecall_clicked(ChatView *self)
{
auto priv = CHAT_VIEW_GET_PRIVATE(self);
if (!priv->conversation_) return;
g_signal_emit(G_OBJECT(self), chat_view_signals[PLACE_CALL_CLICKED], 0, priv->conversation_->uid.c_str());
g_signal_emit(G_OBJECT(self), chat_view_signals[PLACE_CALL_CLICKED], 0, qUtf8Printable(priv->conversation_->uid));
}
static void
......@@ -248,7 +248,7 @@ place_audio_call_clicked(ChatView *self)
{
auto priv = CHAT_VIEW_GET_PRIVATE(self);
if (!priv->conversation_) return;
g_signal_emit(G_OBJECT(self), chat_view_signals[PLACE_AUDIO_CALL_CLICKED], 0, priv->conversation_->uid.c_str());
g_signal_emit(G_OBJECT(self), chat_view_signals[PLACE_AUDIO_CALL_CLICKED], 0, qUtf8Printable(priv->conversation_->uid));
}
static void
......@@ -256,7 +256,7 @@ add_to_conversations_clicked(ChatView *self)
{
auto priv = CHAT_VIEW_GET_PRIVATE(self);
if (!priv->conversation_) return;
g_signal_emit(G_OBJECT(self), chat_view_signals[ADD_CONVERSATION_CLICKED], 0, priv->conversation_->uid.c_str());
g_signal_emit(G_OBJECT(self), chat_view_signals[ADD_CONVERSATION_CLICKED], 0, qUtf8Printable(priv->conversation_->uid));
}
static void
......@@ -264,7 +264,8 @@ send_text_clicked(ChatView *self, const std::string& body)
{
auto priv = CHAT_VIEW_GET_PRIVATE(self);
if (!priv->conversation_) return;
g_signal_emit(G_OBJECT(self), chat_view_signals[SEND_TEXT_CLICKED], 0, priv->conversation_->uid.c_str(), body.c_str());
g_signal_emit(G_OBJECT(self), chat_view_signals[SEND_TEXT_CLICKED],
0, qUtf8Printable(priv->conversation_->uid), body.c_str());
}
static gchar*
......@@ -304,7 +305,7 @@ on_record_closed(GtkPopover*, ChatView *self)
auto* priv = CHAT_VIEW_GET_PRIVATE(self);
if (!priv->cpp->saveFileName_.empty()) {
priv->cpp->avModel_->stopLocalRecorder(priv->cpp->saveFileName_);
priv->cpp->avModel_->stopLocalRecorder(priv->cpp->saveFileName_.c_str());
if (!priv->cpp->saveFileName_.empty()) {
std::remove(priv->cpp->saveFileName_.c_str());
}
......@@ -391,7 +392,7 @@ chat_view_show_recorder(ChatView *self, int pt_x, int pt_y, bool is_video_record
if (is_video_record) {
auto deviceId = priv->cpp->avModel_->getDefaultDevice();
auto settings = priv->cpp->avModel_->getDeviceSettings(deviceId);
auto res = settings.size;
auto res = settings.size.toStdString();
if (res.find("x") == std::string::npos) return;
auto res_width = static_cast<double>(std::stoi(res.substr(0, res.find("x"))));
auto res_height = static_cast<double>(std::stoi(res.substr(res.find("x") + 1)));
......@@ -468,8 +469,8 @@ start_recorder(ChatView* self)
{
g_return_val_if_fail(IS_CHAT_VIEW(self), false);
auto* priv = CHAT_VIEW_GET_PRIVATE(self);
std::string file_name = priv->cpp->avModel_->startLocalRecorder(!priv->is_video_record);
if (file_name.empty()) {
QString file_name = priv->cpp->avModel_->startLocalRecorder(!priv->is_video_record);
if (file_name.isEmpty()) {
priv->startRecorderWhenReady = true;
g_warning("set_state: failed to start recording, wait preview");
return false;
......@@ -478,7 +479,7 @@ start_recorder(ChatView* self)
if (!priv->cpp->saveFileName_.empty()) {
std::remove(priv->cpp->saveFileName_.c_str());
}
priv->cpp->saveFileName_ = file_name;
priv->cpp->saveFileName_ = file_name.toStdString();
return true;
}
......@@ -533,7 +534,7 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
} else if (order.find("SEND:") == 0) {
auto toSend = order.substr(std::string("SEND:").size());
if ((*priv->accountInfo_)->profileInfo.type == lrc::api::profile::Type::RING) {
(*priv->accountInfo_)->conversationModel->sendMessage(priv->conversation_->uid, toSend);
(*priv->accountInfo_)->conversationModel->sendMessage(priv->conversation_->uid, toSend.c_str());
} else {
// For SIP accounts, we need to wait that the conversation is created to send text
send_text_clicked(self, toSend);
......@@ -563,17 +564,18 @@ webkit_chat_container_script_dialog(GtkWidget* webview, gchar *interaction, Chat
// get full path
std::string filename = current_value.empty()? default_download_dir.c_str() : download_directory_value;
if (!filename.empty() && filename.back() != '/') filename += "/";
auto wantedFilename = filename + info.displayName;
auto file_displayname = info.displayName.toStdString();
auto wantedFilename = filename + file_displayname;
auto duplicate = 0;
while (std::ifstream(wantedFilename).good()) {
++duplicate;
auto extensionIdx = info.displayName.find_last_of(".");
auto extensionIdx = file_displayname.find_last_of(".");
if (extensionIdx == std::string::npos)
wantedFilename = filename + info.displayName + " (" + std::to_string(duplicate) + ")";
wantedFilename = filename + file_displayname + " (" + std::to_string(duplicate) + ")";
else
wantedFilename = filename + info.displayName.substr(0, extensionIdx) + " (" + std::to_string(duplicate) + ")" + info.displayName.substr(extensionIdx);
wantedFilename = filename + file_displayname.substr(0, extensionIdx) + " (" + std::to_string(duplicate) + ")" + file_displayname.substr(extensionIdx);
}
model->acceptTransfer(priv->conversation_->uid, interactionId, wantedFilename);
model->acceptTransfer(priv->conversation_->uid, interactionId, wantedFilename.c_str());
} catch (...) {
// ignore
}
......@@ -772,7 +774,7 @@ load_participants_images(ChatView *self)
auto contactUri = priv->conversation_->participants.front();
try{
auto& contact = (*priv->accountInfo_)->contactModel->getContact(contactUri);
std::string avatar_str = contact.profileInfo.avatar;
std::string avatar_str = contact.profileInfo.avatar.toStdString();
if (avatar_str.empty()) {
auto var_photo = Interfaces::PixbufManipulator().conversationPhoto(
*priv->conversation_,
......@@ -786,7 +788,7 @@ load_participants_images(ChatView *self)
}
webkit_chat_container_set_sender_image(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
contactUri,
contactUri.toStdString(),
avatar_str
);
} catch (const std::out_of_range&) {
......@@ -794,7 +796,7 @@ load_participants_images(ChatView *self)
}
// For this account
std::string avatar_str = (*priv->accountInfo_)->profileInfo.avatar;
std::string avatar_str = (*priv->accountInfo_)->profileInfo.avatar.toStdString();
if (avatar_str.empty()) {
auto default_photo = QVariant::fromValue(Interfaces::PixbufManipulator().scaleAndFrame(
Interfaces::PixbufManipulator().generateAvatar("", "").get(),
......@@ -804,7 +806,7 @@ load_participants_images(ChatView *self)
}
webkit_chat_container_set_sender_image(
WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(*priv->accountInfo_)->profileInfo.uri,
(*priv->accountInfo_)->profileInfo.uri.toStdString(),
avatar_str
);
}
......@@ -848,14 +850,14 @@ webkit_chat_container_ready(ChatView* self)
priv->ready_ = true;
for (const auto& interaction: priv->cpp->interactionsBuffer_) {
if (interaction.conv == priv->conversation_->uid) {
if (interaction.conv == priv->conversation_->uid.toStdString()) {
print_interaction_to_buffer(self, interaction.id, interaction.info);
}
}
priv->update_interaction_connection = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::interactionStatusUpdated,
[self, priv](const std::string& uid, uint64_t msgId, lrc::api::interaction::Info msg) {
[self, priv](const QString& uid, uint64_t msgId, lrc::api::interaction::Info msg) {
if (!priv->conversation_) return;
if (uid == priv->conversation_->uid) {
update_interaction(self, msgId, msg);
......@@ -864,7 +866,7 @@ webkit_chat_container_ready(ChatView* self)
priv->interaction_removed = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::interactionRemoved,
[self, priv](const std::string& convUid, uint64_t interactionId) {
[self, priv](const QString& convUid, uint64_t interactionId) {
if (!priv->conversation_) return;
if (convUid == priv->conversation_->uid) {
remove_interaction(self, interactionId);
......@@ -876,11 +878,12 @@ webkit_chat_container_ready(ChatView* self)
try {
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(contactUri);
auto bestName = contactInfo.profileInfo.alias;
if (bestName.empty())
if (bestName.isEmpty())
bestName = contactInfo.registeredName;
if (bestName.empty())
if (bestName.isEmpty())
bestName = contactInfo.profileInfo.uri;
bestName.erase(std::remove(bestName.begin(), bestName.end(), '\r'), bestName.end());
bestName.remove('\r');
bestName.remove('\n');
} catch (const std::out_of_range&) {
// ContactModel::getContact() exception
}
......@@ -908,29 +911,28 @@ update_chatview_frame(ChatView* self)
// get alias and bestName
auto alias = contactInfo.profileInfo.alias;
auto bestName = contactInfo.registeredName;
if (bestName.empty())
if (bestName.isEmpty())
bestName = contactInfo.profileInfo.uri;
if (bestName == alias)
alias = "";
bestName.erase(std::remove(bestName.begin(), bestName.end(), '\r'), bestName.end());
alias.erase(std::remove(alias.begin(), alias.end(), '\r'), alias.end());
bestName.remove('\r');
alias.remove('\r');
// get temporary status
bool temp = contactInfo.profileInfo.type == lrc::api::profile::Type::TEMPORARY || contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING;
webkit_chat_update_chatview_frame(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(*priv->accountInfo_)->enabled,
contactInfo.isBanned, temp, alias.c_str(), bestName.c_str());
contactInfo.isBanned, temp, qUtf8Printable(alias), qUtf8Printable(bestName));
webkit_chat_container_set_invitation(WEBKIT_CHAT_CONTAINER(priv->webkit_chat_container),
(contactInfo.profileInfo.type == lrc::api::profile::Type::PENDING),
bestName,
contactInfo.profileInfo.uri);
bestName.toStdString(),
contactInfo.profileInfo.uri.toStdString());
// hide navbar if we are in call
try {
std::string callId;
if (priv->conversation_->confId.empty()) {
QString callId;
if (priv->conversation_->confId.isEmpty()) {
callId = priv->conversation_->callId;
} else {
callId = priv->conversation_->confId;
......@@ -941,7 +943,7 @@ update_chatview_frame(ChatView* self)
if (status != lrc::api::call::Status::ENDED &&
status != lrc::api::call::Status::INVALID &&
status != lrc::api::call::Status::TERMINATING) {
g_debug("call has status %s, hiding", lrc::api::call::to_string(status).c_str());
g_debug("call has status %s, hiding", qUtf8Printable(lrc::api::call::to_string(status)));
chat_view_set_header_visible(self, FALSE);
} else {
chat_view_set_header_visible(self, TRUE);
......@@ -981,7 +983,9 @@ on_webkit_drag_drop(GtkWidget*, gchar* data, ChatView* self)
}
if (auto model = (*priv->accountInfo_)->conversationModel.get()) {
model->sendFile(priv->conversation_->uid, data_str, g_path_get_basename(data_str.c_str()));
model->sendFile(priv->conversation_->uid,
data_str.c_str(),
g_path_get_basename(data_str.c_str()));
}
}
......@@ -998,7 +1002,7 @@ on_main_action_clicked(ChatView *self)
}
case RecordAction::STOP: {
if (!priv->cpp->saveFileName_.empty()) {
priv->cpp->avModel_->stopLocalRecorder(priv->cpp->saveFileName_);
priv->cpp->avModel_->stopLocalRecorder(priv->cpp->saveFileName_.c_str());
}
gtk_widget_show(GTK_WIDGET(priv->button_retry));
std::string rsc = !priv->useDarkTheme && !priv->is_video_record ?
......@@ -1012,7 +1016,9 @@ on_main_action_clicked(ChatView *self)
}
case RecordAction::SEND: {
if (auto model = (*priv->accountInfo_)->conversationModel.get()) {
model->sendFile(priv->conversation_->uid, priv->cpp->saveFileName_, g_path_get_basename(priv->cpp->saveFileName_.c_str()));
model->sendFile(priv->conversation_->uid,
priv->cpp->saveFileName_.c_str(),
g_path_get_basename(priv->cpp->saveFileName_.c_str()));
priv->cpp->saveFileName_ = "";
}
gtk_widget_destroy(priv->record_popover);
......@@ -1045,7 +1051,7 @@ init_video_widget(ChatView* self)
priv->local_renderer_connection = QObject::connect(
&*priv->cpp->avModel_,
&lrc::api::AVModel::rendererStarted,
[=](const std::string& id) {
[=](const QString& id) {
if (id != lrc::api::video::PREVIEW_RENDERER_ID
|| !priv->readyToRecord_)
return;
......@@ -1119,11 +1125,11 @@ build_chat_view(ChatView* self)
priv->new_interaction_connection = QObject::connect(
&*(*priv->accountInfo_)->conversationModel, &lrc::api::ConversationModel::newInteraction,
[self, priv](const std::string& uid, uint64_t interactionId, lrc::api::interaction::Info interaction) {
[self, priv](const QString& uid, uint64_t interactionId, lrc::api::interaction::Info interaction) {
if (!priv->conversation_) return;
if (!priv->ready_ && priv->cpp) {
priv->cpp->interactionsBuffer_.emplace_back(CppImpl::Interaction {
uid, interactionId, interaction});
uid.toStdString(), interactionId, interaction});
} else if (uid == priv->conversation_->uid) {
print_interaction_to_buffer(self, interactionId, interaction);
}
......
......@@ -188,11 +188,11 @@ update(GtkTreeSelection *selection, ConversationPopupMenu *self)
priv->row_ = idx[0];
try {
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(conversation.participants.front());
if (contactInfo.profileInfo.uri.empty()) return;
if (contactInfo.profileInfo.uri.isEmpty()) return;
// 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.empty() ? conversation.callId : conversation.confId;
auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
// Not in call
if (!contactInfo.isBanned && (*priv->accountInfo_)->enabled) {
......
......@@ -225,11 +225,11 @@ render_time(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
// 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.empty() ? conversation.callId : conversation.confId;
if (!callId.empty()) {
auto callId = conversation.confId.isEmpty() ? conversation.callId : conversation.confId;
if (!callId.isEmpty()) {
auto call = (*priv->accountInfo_)->callModel->getCall(callId);
if (call.status != lrc::api::call::Status::ENDED) {
g_object_set(G_OBJECT(cell), "markup", lrc::api::call::to_string(call.status).c_str(), NULL);
g_object_set(G_OBJECT(cell), "markup", qUtf8Printable(lrc::api::call::to_string(call.status)), NULL);
return;
}
}
......@@ -288,15 +288,15 @@ update_conversation(ConversationsView *self, const std::string& uid) {
conversation.interactions.at(conversation.lastMessageUid).body;
std::replace(lastMessage.begin(), lastMessage.end(), '\n', ' ');
auto alias = contactInfo.profileInfo.alias;
alias.erase(std::remove(alias.begin(), alias.end(), '\r'), alias.end());
alias.remove('\r');
// Update iter
gtk_list_store_set (GTK_LIST_STORE(model), &iter,
0 /* col # */ , conversation.uid.c_str() /* celldata */,
1 /* col # */ , alias.c_str() /* celldata */,
2 /* col # */ , contactInfo.profileInfo.uri.c_str() /* celldata */,
3 /* col # */ , contactInfo.registeredName.c_str() /* celldata */,
4 /* col # */ , contactInfo.profileInfo.avatar.c_str() /* celldata */,
5 /* col # */ , lastMessage.c_str() /* celldata */,
0 /* col # */ , qUtf8Printable(conversation.uid) /* celldata */,
1 /* col # */ , qUtf8Printable(alias) /* celldata */,
2 /* col # */ , qUtf8Printable(contactInfo.profileInfo.uri) /* celldata */,
3 /* col # */ , qUtf8Printable(contactInfo.registeredName) /* celldata */,
4 /* col # */ , qUtf8Printable(contactInfo.profileInfo.avatar) /* celldata */,
5 /* col # */ , qUtf8Printable(lastMessage) /* celldata */,
-1 /* end */);
g_free(ringId);
return;
......@@ -335,14 +335,14 @@ create_and_fill_model(ConversationsView *self)
std::replace(lastMessage.begin(), lastMessage.end(), '\n', ' ');
gtk_list_store_append (store, &iter);
auto alias = contactInfo.profileInfo.alias;
alias.erase(std::remove(alias.begin(), alias.end(), '\r'), alias.end());
alias.remove('\r');
gtk_list_store_set (store, &iter,
0 /* col # */ , conversation.uid.c_str() /* celldata */,
1 /* col # */ , alias.c_str() /* celldata */,
2 /* col # */ , contactInfo.profileInfo.uri.c_str() /* celldata */,
3 /* col # */ , contactInfo.registeredName.c_str() /* celldata */,
4 /* col # */ , contactInfo.profileInfo.avatar.c_str() /* celldata */,
5 /* col # */ , lastMessage.c_str() /* celldata */,
0 /* col # */ , qUtf8Printable(conversation.uid) /* celldata */,
1 /* col # */ , qUtf8Printable(alias) /* celldata */,
2 /* col # */ , qUtf8Printable(contactInfo.profileInfo.uri) /* celldata */,
3 /* col # */ , qUtf8Printable(contactInfo.registeredName) /* celldata */,
4 /* col # */ , qUtf8Printable(contactInfo.profileInfo.avatar) /* celldata */,
5 /* col # */ , qUtf8Printable(lastMessage) /* celldata */,
-1 /* end */);
} catch (const std::out_of_range&) {
// ContactModel::getContact() exception
......@@ -399,7 +399,7 @@ select_conversation(GtkTreeSelection *selection, ConversationsView *self)
gtk_tree_model_get(model, &iter,
0, &conversationUid,
-1);
(*priv->accountInfo_)->conversationModel->selectConversation(std::string(conversationUid));
(*priv->accountInfo_)->conversationModel->selectConversation(QString(conversationUid));
}
static void
......@@ -632,8 +632,8 @@ build_conversations_view(ConversationsView *self)
priv->conversationUpdatedConnection_ = QObject::connect(
&*(*priv->accountInfo_)->conversationModel,
&lrc::api::ConversationModel::conversationUpdated,
[self] (const std::string& uid) {
update_conversation(self, uid);
[self] (const QString& uid) {
update_conversation(self, uid.toStdString());
});
priv->filterChangedConnection_ = QObject::connect(
......@@ -649,7 +649,7 @@ build_conversations_view(ConversationsView *self)
priv->callChangedConnection_ = QObject::connect(
&*(*priv->accountInfo_)->callModel,
&lrc::api::NewCallModel::callStatusChanged,
[self, priv] (const std::string&) {
[self, priv] (const QString&) {
// retrieve currently selected conversation
GtkTreeIter iter;
GtkTreeModel *model = nullptr;
......
This diff is collapsed.
......@@ -115,7 +115,7 @@ CppImpl::CppImpl(GeneralSettingsView& widget, lrc::api::AVModel& avModel)
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_file_chooser_set_filename(
GTK_FILE_CHOOSER(widgets->filechooserbutton_record_path),
avModel_->getRecordPath().c_str());
qUtf8Printable(avModel_->getRecordPath()));
gtk_adjustment_set_value(
GTK_ADJUSTMENT(widgets->adjustment_record_quality),
avModel_->getRecordQuality());
......
......@@ -228,7 +228,7 @@ update_state(IncomingCallView *view)
if (!(*priv->accountInfo_)->callModel->hasCall(callId)) return;
auto call = (*priv->accountInfo_)->callModel->getCall(callId);
gtk_label_set_text(GTK_LABEL(priv->label_status), lrc::api::call::to_string(call.status).c_str());
gtk_label_set_text(GTK_LABEL(priv->label_status), qUtf8Printable(lrc::api::call::to_string(call.status)));
if (call.status == lrc::api::call::Status::INCOMING_RINGING)
gtk_widget_show(priv->button_accept_incoming);
......@@ -264,11 +264,11 @@ update_name_and_photo(IncomingCallView *view)
auto contactInfo = (*priv->accountInfo_)->contactModel->getContact(priv->conversation_->participants.front());
auto name = contactInfo.profileInfo.alias;
gtk_label_set_text(GTK_LABEL(priv->label_name), name.c_str());
gtk_label_set_text(GTK_LABEL(priv->label_name), qUtf8Printable(name));
auto bestId = contactInfo.registeredName;
if (name != bestId) {
gtk_label_set_text(GTK_LABEL(priv->label_bestId), bestId.c_str());
gtk_label_set_text(GTK_LABEL(priv->label_bestId), qUtf8Printable(bestId));
gtk_widget_show(priv->label_bestId);
}
} catch (const std::out_of_range&) {
......@@ -288,7 +288,7 @@ set_call_info(IncomingCallView *view) {
priv->state_change_connection = QObject::connect(
&*(*priv->accountInfo_)->callModel,
&lrc::api::NewCallModel::callStatusChanged,
[view, priv] (const std::string& callId) {
[view, priv] (const QString& callId) {
if (callId == priv->conversation_->callId) {
update_state(view);
update_name_and_photo(view);
......
This diff is collapsed.
......@@ -119,7 +119,7 @@ CppImpl::CppImpl(MediaSettingsView& widget, lrc::api::AVModel& avModel)
if (manager == currentManager) {
activeIdx = i;
}
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_manager), nullptr, manager.c_str());
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_manager), nullptr, qUtf8Printable(manager));
i++;
}
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->combobox_manager), activeIdx);
......@@ -149,8 +149,8 @@ CppImpl::drawAudioDevices()
if (output == currentRingtone) {
activeRingtone = i;
}
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_ringtone), nullptr, output.c_str());
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_output), nullptr, output.c_str());
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_ringtone), nullptr, qUtf8Printable(output));
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_output), nullptr, qUtf8Printable(output));
i++;
}
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->combobox_ringtone), activeRingtone);
......@@ -164,7 +164,7 @@ CppImpl::drawAudioDevices()
if (input == currentInput) {
activeInput = i;
}
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_input), nullptr, input.c_str());
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->combobox_input), nullptr, qUtf8Printable(input));
i++;
}