aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/service/database.vala6
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala6
-rw-r--r--main/src/ui/global_search.vala22
-rw-r--r--main/src/ui/unified_window_controller.vala12
-rw-r--r--main/src/ui/util/helper.vala8
-rw-r--r--plugins/signal-protocol/vapi/signal-protocol-public.vapi10
-rw-r--r--xmpp-vala/src/util.vala34
7 files changed, 40 insertions, 58 deletions
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index 604fcdcc..60f1b52c 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -259,8 +259,7 @@ public class Database : Qlite.Database {
message.type=conversation.type+1 and
(message.counterpart_resource=conversation.resource or message.type != 3)""");
} catch (Error e) {
- stderr.printf("Failed to upgrade to database version 8: %s\n", e.message);
- Process.exit(-1);
+ error("Failed to upgrade to database version 8: %s", e.message);
}
}
if (oldVersion < 9) {
@@ -277,8 +276,7 @@ public class Database : Qlite.Database {
message.body in (select info from file_transfer where info not null) or
message.id in (select info from file_transfer where info not null)""");
} catch (Error e) {
- stderr.printf("Failed to upgrade to database version 8: %s\n", e.message);
- Process.exit(-1);
+ error("Failed to upgrade to database version 9: %s", e.message);
}
}
}
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index 46f6c1a8..6ffefc94 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -136,11 +136,7 @@ public class ConversationSelectorRow : ListBoxRow {
nick_label.label = last_message.direction == Message.DIRECTION_SENT ? _("Me") + ": " : "";
}
- try {
- message_label.label = Markup.escape_text((/\s+/).replace_literal(last_message.body, -1, 0, " "));
- } catch (RegexError e) {
- assert_not_reached();
- }
+ message_label.label = Util.summarize_whitespaces_to_space(last_message.body);
break;
case FileItem.TYPE:
FileItem file_item = last_content_item as FileItem;
diff --git a/main/src/ui/global_search.vala b/main/src/ui/global_search.vala
index db7dbc0f..74e96999 100644
--- a/main/src/ui/global_search.vala
+++ b/main/src/ui/global_search.vala
@@ -205,8 +205,8 @@ public class GlobalSearch : Overlay {
regex_str += ")";
// Color the keywords
- int elongated_by = 0;
try {
+ int elongated_by = 0;
Regex highlight_regex = new Regex(regex_str);
MatchInfo match_info;
string markup_text_bak = markup_text.down();
@@ -218,19 +218,19 @@ public class GlobalSearch : Overlay {
elongated_by += "<span bgcolor=\"yellow\">".length + "</span>".length;
}
markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string
-
- label.label = markup_text;
- grid.attach(label, 1, 1, 1, 1);
-
- Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
- button.clicked.connect(() => {
- selected_item(item);
- });
- button.add(grid);
- return button;
} catch (RegexError e) {
assert_not_reached();
}
+
+ label.label = markup_text;
+ grid.attach(label, 1, 1, 1, 1);
+
+ Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
+ button.clicked.connect(() => {
+ selected_item(item);
+ });
+ button.add(grid);
+ return button;
}
private Grid get_context_message_widget(MessageItem item) {
diff --git a/main/src/ui/unified_window_controller.vala b/main/src/ui/unified_window_controller.vala
index 21725574..2fd8eb0d 100644
--- a/main/src/ui/unified_window_controller.vala
+++ b/main/src/ui/unified_window_controller.vala
@@ -153,19 +153,11 @@ public class UnifiedWindowController : Object {
private void update_conversation_topic(string? subtitle = null) {
if (subtitle != null) {
- try {
- conversation_topic = (/\s+/).replace_literal(subtitle, -1, 0, " ");
- } catch (RegexError e) {
- assert_not_reached();
- }
+ conversation_topic = Util.summarize_whitespaces_to_space(subtitle);
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
string? subject = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account);
if (subject != null) {
- try {
- conversation_topic = (/\s+/).replace_literal(subject, -1, 0, " ");
- } catch (RegexError e) {
- assert_not_reached();
- }
+ conversation_topic = Util.summarize_whitespaces_to_space(subject);
} else {
conversation_topic = null;
}
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index c3353fb6..4e5fbb41 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -272,6 +272,14 @@ public int get_only_emoji_count(string markup_text) {
return emoji_no;
}
+public string summarize_whitespaces_to_space(string s) {
+ try {
+ return (/\s+/).replace_literal(s, -1, 0, " ");
+ } catch (RegexError e) {
+ assert_not_reached();
+ }
+}
+
public bool use_csd() {
return (GLib.Application.get_default() as Application).use_csd();
}
diff --git a/plugins/signal-protocol/vapi/signal-protocol-public.vapi b/plugins/signal-protocol/vapi/signal-protocol-public.vapi
index 1952beb1..40e85c7f 100644
--- a/plugins/signal-protocol/vapi/signal-protocol-public.vapi
+++ b/plugins/signal-protocol/vapi/signal-protocol-public.vapi
@@ -220,9 +220,8 @@ namespace Signal {
[CCode (cname = "ec_public_key_serialize_")]
public uint8[] serialize() {
Buffer buffer;
- try {
- throw_by_code(serialize_(out buffer));
- } catch (GLib.Error e) {
+ int code = serialize_(out buffer);
+ if (code < 0 && code > MIN_ERROR_CODE) {
// Can only throw for invalid arguments or out of memory.
GLib.assert_not_reached();
}
@@ -240,9 +239,8 @@ namespace Signal {
[CCode (cname = "ec_private_key_serialize_")]
public uint8[] serialize() throws GLib.Error {
Buffer buffer;
- try {
- throw_by_code(serialize_(out buffer));
- } catch (GLib.Error e) {
+ int code = serialize_(out buffer);
+ if (code < 0 && code > MIN_ERROR_CODE) {
// Can only throw for invalid arguments or out of memory.
GLib.assert_not_reached();
}
diff --git a/xmpp-vala/src/util.vala b/xmpp-vala/src/util.vala
index 34a05b7a..6c0d0c9b 100644
--- a/xmpp-vala/src/util.vala
+++ b/xmpp-vala/src/util.vala
@@ -1,27 +1,17 @@
namespace Xmpp.Util {
-// Parse a number from a hexadecimal representation.
-//
-// Skips any whitespace at the start of the string, parses as many valid
-// characters as hexadecimal digits as possible (possibly zero) and returns
-// them as an integer value.
-//
-// ```
-// // 0x0
-// print("0x%lx\n", from_hex(""));
-//
-// // 0x123abc
-// print("0x%lx\n", from_hex("123abc"));
-//
-// // 0x0
-// print("0x%lx\n", from_hex("0x123abc"));
-//
-// // 0xa
-// print("0x%lx\n", from_hex("A quick brown fox jumps over the lazy dog."));
-//
-// // 0xfeed
-// print("0x%lx\n", from_hex(" FEED ME "));
-// ```
+ /**
+ * Parse a number from a hexadecimal representation.
+ *
+ * Skips any whitespace at the start of the string, parses as many valid
+ * characters as hexadecimal digits as possible (possibly zero) and returns
+ * them as an integer value.
+ *
+ * ```
+ * // 0xa
+ * print("0x%lx\n", from_hex("A quick brown fox jumps over the lazy dog."));
+ * ```
+ */
public long from_hex(string numeral) {
long result = 0;