aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-10-27 15:31:39 +0100
committerfiaxh <git@lightrise.org>2020-10-27 16:05:30 +0100
commit2e0357877cf3e8e391d3f8f02970defa93c710eb (patch)
tree4478a0deebbedf00934c7a7d6324180c4158bb38 /libdino/src
parentedbc8f794d42cc30bfbe6602becb43c3500e02a2 (diff)
downloaddino-2e0357877cf3e8e391d3f8f02970defa93c710eb.tar.gz
dino-2e0357877cf3e8e391d3f8f02970defa93c710eb.zip
Fix some compiler warnings
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/service/avatar_manager.vala34
-rw-r--r--libdino/src/service/database.vala11
-rw-r--r--libdino/src/service/entity_capabilities_storage.vala2
-rw-r--r--libdino/src/service/entity_info.vala2
-rw-r--r--libdino/src/service/jingle_file_transfers.vala3
-rw-r--r--libdino/src/service/module_manager.vala4
-rw-r--r--libdino/src/service/notification_events.vala6
7 files changed, 17 insertions, 45 deletions
diff --git a/libdino/src/service/avatar_manager.vala b/libdino/src/service/avatar_manager.vala
index 4d86588f..b308aa2b 100644
--- a/libdino/src/service/avatar_manager.vala
+++ b/libdino/src/service/avatar_manager.vala
@@ -45,28 +45,6 @@ public class AvatarManager : StreamInteractionModule, Object {
});
}
- private async Pixbuf? get_avatar_by_hash(string hash) {
- if (cached_pixbuf.has_key(hash)) {
- return cached_pixbuf[hash];
- }
- if (pending_pixbuf.has_key(hash)) {
- pending_pixbuf[hash].add(new SourceFuncWrapper(get_avatar_by_hash.callback));
- yield;
- return cached_pixbuf[hash];
- }
- pending_pixbuf[hash] = new ArrayList<SourceFuncWrapper>();
- Pixbuf? image = yield get_image(hash);
- if (image != null) {
- cached_pixbuf[hash] = image;
- } else {
- db.avatar.delete().with(db.avatar.hash, "=", hash).perform();
- }
- foreach (SourceFuncWrapper sfw in pending_pixbuf[hash]) {
- sfw.sfun();
- }
- return image;
- }
-
private string? get_avatar_hash(Account account, Jid jid_) {
Jid jid = jid_;
if (!stream_interactor.get_module(MucManager.IDENTITY).is_groupchat_occupant(jid_, account)) {
@@ -86,18 +64,6 @@ public class AvatarManager : StreamInteractionModule, Object {
return hash != null && cached_pixbuf.has_key(hash);
}
- public async bool has_avatar_stored(Account account, Jid jid) {
- string? hash = get_avatar_hash(account, jid);
- if (hash == null) return false;
- if (cached_pixbuf.has_key(hash)) return true;
- try {
- if ((yield File.new_for_path(Path.build_filename(folder, hash)).query_info_async(FileAttribute.STANDARD_NAME, FileQueryInfoFlags.NONE)) != null) return true;
- } catch (IOError ignored) {
- return false;
- }
- return false;
- }
-
public bool has_avatar(Account account, Jid jid) {
return get_avatar_hash(account, jid) != null;
}
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index e6c03bf6..6384fa78 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -293,9 +293,14 @@ public class Database : Qlite.Database {
mam_catchup = new MamCatchupTable(this);
settings = new SettingsTable(this);
init({ account, jid, entity, content_item, message, message_correction, real_jid, file_transfer, conversation, avatar, entity_identity, entity_feature, roster, mam_catchup, settings });
- exec("PRAGMA journal_mode = WAL");
- exec("PRAGMA synchronous = NORMAL");
- exec("PRAGMA secure_delete = ON");
+
+ try {
+ exec("PRAGMA journal_mode = WAL");
+ exec("PRAGMA synchronous = NORMAL");
+ exec("PRAGMA secure_delete = ON");
+ } catch (Error e) {
+ error("Failed to set database properties: %s", e.message);
+ }
}
public override void migrate(long oldVersion) {
diff --git a/libdino/src/service/entity_capabilities_storage.vala b/libdino/src/service/entity_capabilities_storage.vala
index e716101a..c6d0bbbd 100644
--- a/libdino/src/service/entity_capabilities_storage.vala
+++ b/libdino/src/service/entity_capabilities_storage.vala
@@ -16,7 +16,7 @@ public class EntityCapabilitiesStorage : Xep.EntityCapabilities.Storage, Object
}
public void store_features(string entity, Gee.List<string> features) {
- if (features_cache.contains(entity)) return;
+ if (features_cache.has_key(entity)) return;
foreach (string feature in features) {
db.entity_feature.insert()
diff --git a/libdino/src/service/entity_info.vala b/libdino/src/service/entity_info.vala
index 7eed2583..c0c55a40 100644
--- a/libdino/src/service/entity_info.vala
+++ b/libdino/src/service/entity_info.vala
@@ -37,7 +37,7 @@ public class EntityInfo : StreamInteractionModule, Object {
stream.get_module(ServiceDiscovery.Module.IDENTITY).cache = cache;
string? hash = EntityCapabilities.get_server_caps_hash(stream);
- entity_caps_hashes[new Jid(account.domainpart)] = hash;
+ entity_caps_hashes[account.bare_jid.domain_jid] = hash;
});
stream_interactor.module_manager.initialize_account_modules.connect(initialize_modules);
}
diff --git a/libdino/src/service/jingle_file_transfers.vala b/libdino/src/service/jingle_file_transfers.vala
index 3b2ca29b..a96c716a 100644
--- a/libdino/src/service/jingle_file_transfers.vala
+++ b/libdino/src/service/jingle_file_transfers.vala
@@ -85,7 +85,8 @@ public class JingleFileProvider : FileProvider, Object {
public Encryption get_encryption(FileTransfer file_transfer, FileReceiveData receive_data, FileMeta file_meta) {
Xmpp.Xep.JingleFileTransfer.FileTransfer? jingle_file_transfer = file_transfers[file_transfer.info];
if (jingle_file_transfer == null) {
- throw new FileReceiveError.DOWNLOAD_FAILED("Transfer data not available anymore");
+ return Encryption.NONE;
+ warning("Could not determine jingle encryption - transfer data not available anymore");
}
foreach (JingleFileEncryptionHelper helper in JingleFileHelperRegistry.instance.encryption_helpers.values) {
var encryption = helper.get_encryption(jingle_file_transfer);
diff --git a/libdino/src/service/module_manager.vala b/libdino/src/service/module_manager.vala
index c0bc229e..2fcef581 100644
--- a/libdino/src/service/module_manager.vala
+++ b/libdino/src/service/module_manager.vala
@@ -34,9 +34,9 @@ public class ModuleManager {
foreach (XmppStreamModule module in module_map[account]) {
if (module.get_id() == Bind.Module.IDENTITY.id) {
- (module as Bind.Module).requested_resource = resource ?? account.resourcepart;
+ ((Bind.Module) module).requested_resource = resource ?? account.resourcepart;
} else if (module.get_id() == Sasl.Module.IDENTITY.id) {
- (module as Sasl.Module).password = account.password;
+ ((Sasl.Module) module).password = account.password;
}
}
return modules;
diff --git a/libdino/src/service/notification_events.vala b/libdino/src/service/notification_events.vala
index 5e81ff89..19d61d0f 100644
--- a/libdino/src/service/notification_events.vala
+++ b/libdino/src/service/notification_events.vala
@@ -49,11 +49,11 @@ public class NotificationEvents : StreamInteractionModule, Object {
switch (content_item.type_) {
case MessageItem.TYPE:
- Message message = (content_item as MessageItem).message;
+ Message message = ((MessageItem) content_item).message;
if (message.direction == Message.DIRECTION_SENT) return false;
break;
case FileItem.TYPE:
- FileTransfer file_transfer = (content_item as FileItem).file_transfer;
+ FileTransfer file_transfer = ((FileItem) content_item).file_transfer;
// Don't notify on file transfers in a groupchat set to "mention only"
if (notify == Conversation.NotifySetting.HIGHLIGHT) return false;
if (file_transfer.direction == FileTransfer.DIRECTION_SENT) return false;
@@ -64,7 +64,7 @@ public class NotificationEvents : StreamInteractionModule, Object {
Jid? nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
if (nick == null) return false;
- Entities.Message message = (content_item as MessageItem).message;
+ Entities.Message message = ((MessageItem) content_item).message;
return Regex.match_simple("\\b" + Regex.escape_string(nick.resourcepart) + "\\b", message.body, RegexCompileFlags.CASELESS);
}
return true;