Check FileTransfer's mime_type for null (unknown) when handeling it
fixes #479
This commit is contained in:
parent
420942873a
commit
446e86d4ad
|
@ -150,10 +150,11 @@ public class ConversationRow : ListBoxRow {
|
||||||
nick_label.label = transfer.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
|
nick_label.label = transfer.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool file_is_image = transfer.mime_type != null && transfer.mime_type.has_prefix("image");
|
||||||
if (transfer.direction == Message.DIRECTION_SENT) {
|
if (transfer.direction == Message.DIRECTION_SENT) {
|
||||||
message_label.label = "<i>" + (transfer.mime_type.has_prefix("image") ? _("Image sent") : _("File sent") ) + "</i>";
|
message_label.label = "<i>" + (file_is_image ? _("Image sent") : _("File sent") ) + "</i>";
|
||||||
} else {
|
} else {
|
||||||
message_label.label = "<i>" +(transfer.mime_type.has_prefix("image") ? _("Image received") : _("File received") ) + "</i>";
|
message_label.label = "<i>" + (file_is_image ? _("Image received") : _("File received") ) + "</i>";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class FileItemWidgetGenerator : WidgetGenerator, Object {
|
||||||
|
|
||||||
private Widget getDefaultWidget(FileTransfer file_transfer) {
|
private Widget getDefaultWidget(FileTransfer file_transfer) {
|
||||||
Box main_box = new Box(Orientation.HORIZONTAL, 4) { halign=Align.START, visible=true };
|
Box main_box = new Box(Orientation.HORIZONTAL, 4) { halign=Align.START, visible=true };
|
||||||
string? icon_name = ContentType.get_generic_icon_name(file_transfer.mime_type);
|
string? icon_name = file_transfer.mime_type != null ? ContentType.get_generic_icon_name(file_transfer.mime_type) : null;
|
||||||
Image content_type_image = new Image.from_icon_name(icon_name, IconSize.DND) { visible=true };
|
Image content_type_image = new Image.from_icon_name(icon_name, IconSize.DND) { visible=true };
|
||||||
main_box.add(content_type_image);
|
main_box.add(content_type_image);
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,11 @@ public class Notifications : Object {
|
||||||
FileItem file_item = content_item as FileItem;
|
FileItem file_item = content_item as FileItem;
|
||||||
FileTransfer transfer = file_item.file_transfer;
|
FileTransfer transfer = file_item.file_transfer;
|
||||||
|
|
||||||
|
bool file_is_image = transfer.mime_type != null && transfer.mime_type.has_prefix("image");
|
||||||
if (transfer.direction == Message.DIRECTION_SENT) {
|
if (transfer.direction == Message.DIRECTION_SENT) {
|
||||||
text = transfer.mime_type.has_prefix("image") ? _("Image sent") : _("File sent");
|
text = file_is_image ? _("Image sent") : _("File sent");
|
||||||
} else {
|
} else {
|
||||||
text = transfer.mime_type.has_prefix("image") ? _("Image received") : _("File received");
|
text = file_is_image ? _("Image received") : _("File received");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ public class FileProvider : Dino.FileProvider, Object {
|
||||||
file_transfer.local_time = message.local_time;
|
file_transfer.local_time = message.local_time;
|
||||||
file_transfer.direction = message.direction;
|
file_transfer.direction = message.direction;
|
||||||
file_transfer.file_name = message.body.substring(message.body.last_index_of("/") + 1);
|
file_transfer.file_name = message.body.substring(message.body.last_index_of("/") + 1);
|
||||||
file_transfer.mime_type = null;
|
|
||||||
file_transfer.size = -1;
|
file_transfer.size = -1;
|
||||||
file_transfer.state = FileTransfer.State.NOT_STARTED;
|
file_transfer.state = FileTransfer.State.NOT_STARTED;
|
||||||
file_transfer.provider = 0;
|
file_transfer.provider = 0;
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class FileProvider : Dino.FileProvider, Object {
|
||||||
file_transfer.local_time = message.local_time;
|
file_transfer.local_time = message.local_time;
|
||||||
file_transfer.direction = message.direction;
|
file_transfer.direction = message.direction;
|
||||||
file_transfer.file_name = url_without_hash.substring(url_without_hash.last_index_of("/") + 1);
|
file_transfer.file_name = url_without_hash.substring(url_without_hash.last_index_of("/") + 1);
|
||||||
file_transfer.mime_type = null;
|
|
||||||
file_transfer.size = -1;
|
file_transfer.size = -1;
|
||||||
file_transfer.state = FileTransfer.State.NOT_STARTED;
|
file_transfer.state = FileTransfer.State.NOT_STARTED;
|
||||||
file_transfer.provider = 0;
|
file_transfer.provider = 0;
|
||||||
|
|
Loading…
Reference in a new issue