aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/CMakeLists.txt2
-rw-r--r--libdino/src/service/avatar_manager.vala4
-rw-r--r--libdino/src/service/connection_manager.vala64
-rw-r--r--main/src/main.vala2
-rw-r--r--main/src/ui/conversation_summary/content_item_widget_factory.vala2
-rw-r--r--plugins/http-files/src/manager.vala2
-rw-r--r--plugins/omemo/CMakeLists.txt2
-rw-r--r--plugins/omemo/src/manager.vala10
-rw-r--r--plugins/omemo/src/pre_key_store.vala2
-rw-r--r--plugins/omemo/src/session_store.vala2
-rw-r--r--plugins/omemo/src/signed_pre_key_store.vala2
-rw-r--r--plugins/omemo/src/stream_module.vala8
-rw-r--r--plugins/omemo/src/trust_manager.vala4
-rw-r--r--plugins/openpgp/src/stream_module.vala2
-rw-r--r--qlite/src/row.vala2
-rw-r--r--xmpp-vala/src/core/xmpp_stream.vala6
16 files changed, 52 insertions, 64 deletions
diff --git a/libdino/CMakeLists.txt b/libdino/CMakeLists.txt
index f45d08f5..6d37ef15 100644
--- a/libdino/CMakeLists.txt
+++ b/libdino/CMakeLists.txt
@@ -78,7 +78,7 @@ DEPENDS
${CMAKE_BINARY_DIR}/exports/dino_i18n.h
)
-add_definitions(${VALA_CFLAGS} -DDINO_SYSTEM_PLUGIN_DIR="${PLUGIN_INSTALL_DIR}" -DDINO_SYSTEM_LIBDIR_NAME="${LIBDIR_NAME}")
+add_definitions(${VALA_CFLAGS} -DDINO_SYSTEM_PLUGIN_DIR="${PLUGIN_INSTALL_DIR}" -DDINO_SYSTEM_LIBDIR_NAME="${LIBDIR_NAME}" -DG_LOG_DOMAIN="libdino")
add_library(libdino SHARED ${LIBDINO_VALA_C} ${CMAKE_BINARY_DIR}/exports/dino_i18n.h)
add_dependencies(libdino dino-vapi)
target_link_libraries(libdino xmpp-vala qlite ${LIBDINO_PACKAGES} m)
diff --git a/libdino/src/service/avatar_manager.vala b/libdino/src/service/avatar_manager.vala
index 40115345..9e75a9dd 100644
--- a/libdino/src/service/avatar_manager.vala
+++ b/libdino/src/service/avatar_manager.vala
@@ -91,7 +91,7 @@ public class AvatarManager : StreamInteractionModule, Object {
on_user_avatar_received(account, account.bare_jid, Base64.encode(buffer));
}
} catch (Error e) {
- print("error " + e.message + "\n");
+ warning(e.message);
}
}
@@ -138,4 +138,4 @@ public class AvatarManager : StreamInteractionModule, Object {
}
}
-} \ No newline at end of file
+}
diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala
index 464302cb..e81b9b99 100644
--- a/libdino/src/service/connection_manager.vala
+++ b/libdino/src/service/connection_manager.vala
@@ -44,7 +44,6 @@ public class ConnectionManager : Object {
public Source source;
public string? identifier;
public Reconnect reconnect_recomendation { get; set; default=Reconnect.NOW; }
- public bool resource_rejected = false;
public ConnectionError(Source source, string? identifier) {
this.source = source;
@@ -110,14 +109,13 @@ public class ConnectionManager : Object {
return connection_todo;
}
- public XmppStream? connect_account(Account account) {
+ public void connect_account(Account account) {
if (!connection_todo.contains(account)) connection_todo.add(account);
if (!connections.has_key(account)) {
- return connect_(account);
+ connect_(account);
} else {
check_reconnect(account);
}
- return null;
}
public void make_offline_all() {
@@ -139,7 +137,7 @@ public class ConnectionManager : Object {
try {
connections[account].stream.disconnect();
} catch (Error e) {
- warning(@"Error disconnecting stream $(e.message)\n");
+ debug("Error disconnecting stream: %s", e.message);
}
connection_todo.remove(account);
if (connections.has_key(account)) {
@@ -148,7 +146,7 @@ public class ConnectionManager : Object {
}
}
- private XmppStream? connect_(Account account, string? resource = null) {
+ private void connect_(Account account, string? resource = null) {
if (connections.has_key(account)) connections[account].stream.detach_modules();
connection_errors.unset(account);
if (resource == null) resource = account.resourcepart;
@@ -158,7 +156,7 @@ public class ConnectionManager : Object {
stream.add_module(module);
}
stream.log = new XmppLog(account.bare_jid.to_string(), log_options);
- print("[%s] New connection with resource %s: %p\n".printf(account.bare_jid.to_string(), resource, stream));
+ debug("[%s] New connection with resource %s: %p", account.bare_jid.to_string(), resource, stream);
Connection connection = new Connection(stream, new DateTime.now_utc());
connections[account] = connection;
@@ -177,47 +175,35 @@ public class ConnectionManager : Object {
});
connect_async.begin(account, stream);
stream_opened(account, stream);
-
- return stream;
}
private async void connect_async(Account account, XmppStream stream) {
try {
yield stream.connect(account.domainpart);
} catch (Error e) {
- print(@"[$(account.bare_jid)] Error: $(e.message)\n");
+ debug("[%s %p] Error: %s", account.bare_jid.to_string(), stream, e.message);
change_connection_state(account, ConnectionState.DISCONNECTED);
if (!connection_todo.contains(account)) {
return;
}
StreamError.Flag? flag = stream.get_flag(StreamError.Flag.IDENTITY);
if (flag != null) {
- set_connection_error(account, new ConnectionError(ConnectionError.Source.STREAM_ERROR, flag.error_type) { resource_rejected=flag.resource_rejected });
- }
+ warning(@"[%s %p] Stream Error: %s", account.bare_jid.to_string(), stream, flag.error_type);
+ set_connection_error(account, new ConnectionError(ConnectionError.Source.STREAM_ERROR, flag.error_type));
- ConnectionError? error = connection_errors[account];
- int wait_sec = 5;
- if (error == null) {
- wait_sec = 3;
- } else if (error.source == ConnectionError.Source.STREAM_ERROR) {
- print(@"[$(account.bare_jid)] Stream Error: $(error.identifier)\n");
- if (error.resource_rejected) {
+ if (flag.resource_rejected) {
connect_(account, account.resourcepart + "-" + random_uuid());
return;
}
- switch (error.reconnect_recomendation) {
- case ConnectionError.Reconnect.NOW:
- wait_sec = 5; break;
- case ConnectionError.Reconnect.LATER:
- wait_sec = 60; break;
- case ConnectionError.Reconnect.NEVER:
- return;
- }
- } else if (error.source == ConnectionError.Source.SASL) {
+ }
+
+ ConnectionError? error = connection_errors[account];
+ if (error != null && error.source == ConnectionError.Source.SASL) {
return;
}
- print(@"[$(account.bare_jid)] Check reconnect in $wait_sec sec\n");
- Timeout.add_seconds(wait_sec, () => {
+
+ debug("[%s] Check reconnect in 5 sec", account.bare_jid.to_string());
+ Timeout.add_seconds(5, () => {
check_reconnect(account);
return false;
});
@@ -236,8 +222,8 @@ public class ConnectionManager : Object {
XmppStream stream = connections[account].stream;
stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.bare_jid.domain_jid, () => {
- if (connections[account].stream != stream) return;
acked = true;
+ if (connections[account].stream != stream) return;
change_connection_state(account, ConnectionState.CONNECTED);
});
@@ -247,11 +233,13 @@ public class ConnectionManager : Object {
if (connections[account].last_activity != last_activity_was) return false;
// Reconnect. Nothing gets through the stream.
- print(@"[$(account.bare_jid)] Ping timeouted. Reconnecting\n");
+ debug("[%s %p] Ping timeouted. Reconnecting", account.bare_jid.to_string(), stream);
change_connection_state(account, ConnectionState.DISCONNECTED);
try {
connections[account].stream.disconnect();
- } catch (Error e) { }
+ } catch (Error e) {
+ debug("Error disconnecting stream: %s", e.message);
+ }
connect_(account);
return false;
});
@@ -269,10 +257,10 @@ public class ConnectionManager : Object {
private void on_network_changed() {
if (network_is_online()) {
- print("Network reported online\n");
+ debug("NetworkMonitor: Network reported online");
check_reconnects();
} else {
- print("Network reported offline\n");
+ debug("NetworkMonitor: Network reported offline");
foreach (Account account in connection_todo) {
change_connection_state(account, ConnectionState.DISCONNECTED);
}
@@ -284,17 +272,17 @@ public class ConnectionManager : Object {
change_connection_state(account, ConnectionState.DISCONNECTED);
}
if (suspend) {
- print("Device suspended\n");
+ debug("Login1: Device suspended");
foreach (Account account in connection_todo) {
try {
make_offline(account);
connections[account].stream.disconnect();
} catch (Error e) {
- warning(@"Error disconnecting stream $(e.message)\n");
+ debug("Error disconnecting stream %p: %s", connections[account].stream, e.message);
}
}
} else {
- print("Device un-suspend\n");
+ debug("Login1: Device un-suspend");
check_reconnects();
}
}
diff --git a/main/src/main.vala b/main/src/main.vala
index 46b3affd..6274dcdd 100644
--- a/main/src/main.vala
+++ b/main/src/main.vala
@@ -22,7 +22,7 @@ void main(string[] args) {
app.run(args);
loader.shutdown();
} catch (Error e) {
- print(@"Fatal error: $(e.message)\n");
+ warning(@"Fatal error: $(e.message)");
}
}
diff --git a/main/src/ui/conversation_summary/content_item_widget_factory.vala b/main/src/ui/conversation_summary/content_item_widget_factory.vala
index 0bd763ec..b784c91a 100644
--- a/main/src/ui/conversation_summary/content_item_widget_factory.vala
+++ b/main/src/ui/conversation_summary/content_item_widget_factory.vala
@@ -166,7 +166,7 @@ public class FileItemWidgetGenerator : WidgetGenerator, Object {
try{
AppInfo.launch_default_for_uri(file_transfer.get_file().get_uri(), null);
} catch (Error err) {
- print("Tried to open file://" + file_transfer.get_file().get_path() + " " + err.message + "\n");
+ info("Could not to open file://%s: %s", file_transfer.get_file().get_path(), err.message);
}
});
diff --git a/plugins/http-files/src/manager.vala b/plugins/http-files/src/manager.vala
index 96490bb1..2f702be3 100644
--- a/plugins/http-files/src/manager.vala
+++ b/plugins/http-files/src/manager.vala
@@ -83,7 +83,7 @@ public class Manager : StreamInteractionModule, FileSender, Object {
}
},
(stream, error_str) => {
- print(@"Failed getting upload url + $error_str\n");
+ warning("Failed getting upload url: %s", error_str);
file_transfer.state = FileTransfer.State.FAILED;
}
);
diff --git a/plugins/omemo/CMakeLists.txt b/plugins/omemo/CMakeLists.txt
index 92d5cd51..fe6bb079 100644
--- a/plugins/omemo/CMakeLists.txt
+++ b/plugins/omemo/CMakeLists.txt
@@ -66,7 +66,7 @@ OPTIONS
--vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi
)
-add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\")
+add_definitions(${VALA_CFLAGS} -DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\" -DLOCALE_INSTALL_DIR=\"${LOCALE_INSTALL_DIR}\" -DG_LOG_DOMAIN="OMEMO")
add_library(omemo SHARED ${OMEMO_VALA_C} ${OMEMO_GRESOURCES_TARGET})
add_dependencies(omemo ${GETTEXT_PACKAGE}-translations)
target_link_libraries(omemo libdino signal-protocol-vala ${OMEMO_PACKAGES})
diff --git a/plugins/omemo/src/manager.vala b/plugins/omemo/src/manager.vala
index d0df6c8e..db64c3ee 100644
--- a/plugins/omemo/src/manager.vala
+++ b/plugins/omemo/src/manager.vala
@@ -134,10 +134,10 @@ public class Manager : StreamInteractionModule, Object {
//Encryption failed - need to fetch more information
if (!state.will_send_now) {
if (message.marked == Entities.Message.Marked.WONTSEND) {
- if (Plugin.DEBUG) print(@"OMEMO: message was not sent: $state\n");
+ debug("message was not sent: %s", state.to_string());
message_states.unset(message);
} else {
- if (Plugin.DEBUG) print(@"OMEMO: message will be delayed: $state\n");
+ debug("message will be delayed: %s", state.to_string());
if (state.waiting_own_sessions > 0) {
module.fetch_bundles((!)stream, conversation.account.bare_jid, trust_manager.get_trusted_devices(conversation.account, conversation.account.bare_jid));
@@ -175,7 +175,7 @@ public class Manager : StreamInteractionModule, Object {
}
private void on_device_list_loaded(Account account, Jid jid, ArrayList<int32> device_list) {
- if (Plugin.DEBUG) print(@"OMEMO: received device list for $(account.bare_jid) from $jid\n");
+ debug("received device list for %s from %s", account.bare_jid.to_string(), jid.to_string());
XmppStream? stream = stream_interactor.get_stream(account);
if (stream == null) {
@@ -199,7 +199,7 @@ public class Manager : StreamInteractionModule, Object {
inc++;
}
if (inc > 0) {
- if (Plugin.DEBUG) print(@"OMEMO: new bundles $inc/$(device_list.size) for $jid\n");
+ debug("new bundles %i/%i for %s", inc, device_list.size, jid.to_string());
}
//Create an entry for the jid in the account table if one does not exist already
@@ -343,7 +343,7 @@ public class Manager : StreamInteractionModule, Object {
store.pre_key_store = new BackedPreKeyStore(db, identity_id);
store.session_store = new BackedSessionStore(db, identity_id);
} else {
- print(@"OMEMO: store for $(account.bare_jid) is not persisted!");
+ warning("store for %s is not persisted!", account.bare_jid.to_string());
}
// Generated new device ID, ensure this gets added to the devicelist
diff --git a/plugins/omemo/src/pre_key_store.vala b/plugins/omemo/src/pre_key_store.vala
index 93ec2dfe..716fd32f 100644
--- a/plugins/omemo/src/pre_key_store.vala
+++ b/plugins/omemo/src/pre_key_store.vala
@@ -19,7 +19,7 @@ private class BackedPreKeyStore : SimplePreKeyStore {
store_pre_key(row[db.pre_key.pre_key_id], Base64.decode(row[db.pre_key.record_base64]));
}
} catch (Error e) {
- print(@"OMEMO: Error while initializing pre key store: $(e.message)\n");
+ warning("Error while initializing pre key store: %s", e.message);
}
pre_key_stored.connect(on_pre_key_stored);
diff --git a/plugins/omemo/src/session_store.vala b/plugins/omemo/src/session_store.vala
index 25b4d719..654591d1 100644
--- a/plugins/omemo/src/session_store.vala
+++ b/plugins/omemo/src/session_store.vala
@@ -21,7 +21,7 @@ private class BackedSessionStore : SimpleSessionStore {
addr.device_id = 0;
}
} catch (Error e) {
- print(@"OMEMO: Error while initializing session store: $(e.message)\n");
+ print("Error while initializing session store: %s", e.message);
}
session_stored.connect(on_session_stored);
diff --git a/plugins/omemo/src/signed_pre_key_store.vala b/plugins/omemo/src/signed_pre_key_store.vala
index d96ded1f..8ff54a93 100644
--- a/plugins/omemo/src/signed_pre_key_store.vala
+++ b/plugins/omemo/src/signed_pre_key_store.vala
@@ -19,7 +19,7 @@ private class BackedSignedPreKeyStore : SimpleSignedPreKeyStore {
store_signed_pre_key(row[db.signed_pre_key.signed_pre_key_id], Base64.decode(row[db.signed_pre_key.record_base64]));
}
} catch (Error e) {
- print(@"OMEMO: Error while initializing signed pre key store: $(e.message)\n");
+ print("Error while initializing signed pre key store: %s", e.message);
}
signed_pre_key_stored.connect(on_signed_pre_key_stored);
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala
index 6ee42771..30f8c04c 100644
--- a/plugins/omemo/src/stream_module.vala
+++ b/plugins/omemo/src/stream_module.vala
@@ -38,7 +38,7 @@ public class StreamModule : XmppStreamModule {
public void request_user_devicelist(XmppStream stream, Jid jid) {
if (active_devicelist_requests.add(jid)) {
- if (Plugin.DEBUG) print(@"OMEMO: requesting device list for $jid\n");
+ debug("requesting device list for %s", jid.to_string());
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node));
}
}
@@ -56,7 +56,7 @@ public class StreamModule : XmppStreamModule {
}
}
if (!am_on_devicelist) {
- if (Plugin.DEBUG) print(@"OMEMO: Not on device list, adding id\n");
+ debug(@"Not on device list, adding id");
node.put_node(new StanzaNode.build("device", NS_URI).put_attribute("id", store.local_registration_id.to_string()));
stream.get_module(Pubsub.Module.IDENTITY).publish(stream, jid, NODE_DEVICELIST, NODE_DEVICELIST, id, node);
}
@@ -90,7 +90,7 @@ public class StreamModule : XmppStreamModule {
public void fetch_bundle(XmppStream stream, Jid jid, int device_id) {
if (active_bundle_requests.add(jid.bare_jid.to_string() + @":$device_id")) {
- if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $(jid.bare_jid.to_string()):$device_id\n");
+ debug(@"Asking for bundle from %s: %i", jid.bare_jid.to_string(), device_id);
stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid.bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
on_other_bundle_result(stream, jid, device_id, id, node);
});
@@ -233,7 +233,7 @@ public class StreamModule : XmppStreamModule {
publish_bundles(stream, (!)signed_pre_key_record, identity_key_pair, pre_key_records, (int32) store.local_registration_id);
}
} catch (Error e) {
- if (Plugin.DEBUG) print(@"Unexpected error while publishing bundle: $(e.message)\n");
+ warning(@"Unexpected error while publishing bundle: $(e.message)\n");
}
stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$(store.local_registration_id)");
}
diff --git a/plugins/omemo/src/trust_manager.vala b/plugins/omemo/src/trust_manager.vala
index 4ec141f0..d57adc35 100644
--- a/plugins/omemo/src/trust_manager.vala
+++ b/plugins/omemo/src/trust_manager.vala
@@ -159,7 +159,7 @@ public class TrustManager {
message.body = "[This message is OMEMO encrypted]";
status.encrypted = true;
} catch (Error e) {
- if (Plugin.DEBUG) print(@"OMEMO: Signal error while encrypting message: $(e.message)\n");
+ warning(@"Signal error while encrypting message: $(e.message)\n");
}
return status;
}
@@ -327,7 +327,7 @@ public class TrustManager {
break;
}
} catch (Error e) {
- if (Plugin.DEBUG) print(@"OMEMO: Signal error while decrypting message: $(e.message)\n");
+ warning(@"Signal error while decrypting message: $(e.message)\n");
}
}
}
diff --git a/plugins/openpgp/src/stream_module.vala b/plugins/openpgp/src/stream_module.vala
index f7c24b80..447ed5fd 100644
--- a/plugins/openpgp/src/stream_module.vala
+++ b/plugins/openpgp/src/stream_module.vala
@@ -24,7 +24,7 @@ namespace Dino.Plugins.OpenPgp {
if (own_key_id != null) {
try {
own_key = GPGHelper.get_private_key(own_key_id);
- if (own_key == null) print("PRIV KEY NULL\n");
+ if (own_key == null) warning("Can't get PGP private key");
} catch (Error e) { }
if (own_key != null) {
signed_status = gpg_sign("", own_key);
diff --git a/qlite/src/row.vala b/qlite/src/row.vala
index d3807f41..4671db20 100644
--- a/qlite/src/row.vala
+++ b/qlite/src/row.vala
@@ -108,7 +108,7 @@ public class RowIterator {
int r = stmt.step();
if (r == Sqlite.ROW) return true;
if (r == Sqlite.DONE) return false;
- print(@"SQLite error: $(db.errcode()) - $(db.errmsg())\n");
+ warning(@"SQLite error: $(db.errcode()) - $(db.errmsg())");
return false;
}
diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala
index 98c89716..aff0b216 100644
--- a/xmpp-vala/src/core/xmpp_stream.vala
+++ b/xmpp-vala/src/core/xmpp_stream.vala
@@ -67,7 +67,7 @@ public class XmppStream {
}
reset_stream((!)stream);
} catch (Error e) {
- stderr.printf("CONNECTION LOST?\n");
+ debug("[%p] Could not connect to server", this);
throw new IOStreamError.CONNECT(e.message);
}
yield loop();
@@ -153,7 +153,7 @@ public class XmppStream {
public XmppStream add_module(XmppStreamModule module) {
foreach (XmppStreamModule m in modules) {
if (m.get_ns() == module.get_ns() && m.get_id() == module.get_id()) {
- print("[%p] Adding already added module: %s\n".printf(this, module.get_id()));
+ warning("[%p] Adding already added module: %s\n", this, module.get_id());
return this;
}
}
@@ -221,7 +221,7 @@ public class XmppStream {
features = node;
received_features_node(this);
} else if (node.ns_uri == NS_URI && node.name == "stream" && node.pseudo) {
- print("disconnect\n");
+ debug("[%p] Server closed stream", this);
disconnect();
return;
} else if (node.ns_uri == JABBER_URI) {