Fix some compiler warnings
This commit is contained in:
parent
edbc8f794d
commit
2e0357877c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 });
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -129,12 +129,12 @@ public class ChatInputController : Object {
|
|||
}
|
||||
return;
|
||||
case "/nick":
|
||||
stream_interactor.get_module(MucManager.IDENTITY).change_nick(conversation, token[1]);
|
||||
stream_interactor.get_module(MucManager.IDENTITY).change_nick.begin(conversation, token[1]);
|
||||
return;
|
||||
case "/ping":
|
||||
Xmpp.XmppStream? stream = stream_interactor.get_stream(conversation.account);
|
||||
try {
|
||||
stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, conversation.counterpart.with_resource(token[1]), null);
|
||||
stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping.begin(stream, conversation.counterpart.with_resource(token[1]), null);
|
||||
} catch (Xmpp.InvalidJidError e) {
|
||||
warning("Could not ping invalid Jid: %s", e.message);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ public class Dialog : Gtk.Dialog {
|
|||
|
||||
title = conversation.type_ == Conversation.Type.GROUPCHAT ? _("Conference Details") : _("Contact Details");
|
||||
if (Util.use_csd()) {
|
||||
(get_header_bar() as HeaderBar).set_subtitle(Util.get_conversation_display_name(stream_interactor, conversation));
|
||||
// TODO get_header_bar directly returns a HeaderBar in vala > 0.48
|
||||
((HeaderBar) get_header_bar()).set_subtitle(Util.get_conversation_display_name(stream_interactor, conversation));
|
||||
}
|
||||
setup_top();
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
|
|||
was_value = scrolled.vadjustment.value;
|
||||
if (!reloading_mutex.trylock()) return;
|
||||
if (content_items.size > 0) {
|
||||
Gee.List<ContentMetaItem> items = content_populator.populate_before(conversation, (content_items.first() as ContentMetaItem).content_item, 20);
|
||||
Gee.List<ContentMetaItem> items = content_populator.populate_before(conversation, ((ContentMetaItem) content_items.first()).content_item, 20);
|
||||
foreach (ContentMetaItem item in items) {
|
||||
do_insert_item(item);
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
|
|||
private void load_later_messages() {
|
||||
if (!reloading_mutex.trylock()) return;
|
||||
if (content_items.size > 0 && !at_current_content) {
|
||||
Gee.List<ContentMetaItem> items = content_populator.populate_after(conversation, (content_items.last() as ContentMetaItem).content_item, 20);
|
||||
Gee.List<ContentMetaItem> items = content_populator.populate_after(conversation, ((ContentMetaItem) content_items.last()).content_item, 20);
|
||||
if (items.size == 0) {
|
||||
at_current_content = true;
|
||||
}
|
||||
|
|
|
@ -176,10 +176,14 @@ public class ConversationViewController : Object {
|
|||
if (clipboard.wait_is_image_available()) {
|
||||
clipboard.request_image((_, pixbuf) => {
|
||||
File file = File.new_for_path(Path.build_filename(FileManager.get_storage_dir(), Xmpp.random_uuid() + ".png"));
|
||||
DataOutputStream fos = new DataOutputStream(file.create(FileCreateFlags.REPLACE_DESTINATION));
|
||||
try {
|
||||
FileOutputStream fos = file.create(FileCreateFlags.REPLACE_DESTINATION);
|
||||
pixbuf.save_to_stream_async.begin(fos, "png", null, () => {
|
||||
open_send_file_overlay(file);
|
||||
});
|
||||
} catch (Error e) {
|
||||
warning("Could not create file to store pasted image in %s, %s", file.get_path(), e.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -191,8 +195,12 @@ public class ConversationViewController : Object {
|
|||
string[] uris = selection_data.get_uris();
|
||||
// For now we only process the first dragged file
|
||||
if (uris.length >= 1) {
|
||||
try {
|
||||
string file_path = Filename.from_uri(uris[0]);
|
||||
open_send_file_overlay(File.new_for_path(file_path));
|
||||
} catch (ConvertError e) {
|
||||
warning("Could not handle dragged file %s, %s", uris[0], e.message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -55,12 +55,11 @@ public class Notifications : Object {
|
|||
string text = "";
|
||||
switch (content_item.type_) {
|
||||
case MessageItem.TYPE:
|
||||
Message message = (content_item as MessageItem).message;
|
||||
Message message = ((MessageItem) content_item).message;
|
||||
text = message.body;
|
||||
break;
|
||||
case FileItem.TYPE:
|
||||
FileItem file_item = content_item as FileItem;
|
||||
FileTransfer transfer = file_item.file_transfer;
|
||||
FileTransfer transfer = ((FileItem) content_item).file_transfer;
|
||||
|
||||
bool file_is_image = transfer.mime_type != null && transfer.mime_type.has_prefix("image");
|
||||
if (transfer.direction == Message.DIRECTION_SENT) {
|
||||
|
|
|
@ -24,7 +24,8 @@ class AccountComboBox : ComboBox {
|
|||
do {
|
||||
Value val;
|
||||
list_store.get_value(iter, 1, out val);
|
||||
if ((val as Account).equals(value)) {
|
||||
Account? account = val as Account;
|
||||
if (account != null && account.equals(value)) {
|
||||
active = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ public string summarize_whitespaces_to_space(string s) {
|
|||
}
|
||||
|
||||
public bool use_csd() {
|
||||
return (GLib.Application.get_default() as Application).use_csd();
|
||||
return ((Application) GLib.Application.get_default()).use_csd();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -148,21 +148,6 @@ class ScalingImage : Misc {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
private static Gdk.Pixbuf crop_corners(Gdk.Pixbuf pixbuf, double radius = 3) {
|
||||
Cairo.Context ctx = new Cairo.Context(new Cairo.ImageSurface(Cairo.Format.ARGB32, pixbuf.width, pixbuf.height));
|
||||
Gdk.cairo_set_source_pixbuf(ctx, pixbuf, 0, 0);
|
||||
double degrees = Math.PI / 180.0;
|
||||
ctx.new_sub_path();
|
||||
ctx.arc(pixbuf.width - radius, radius, radius, -90 * degrees, 0 * degrees);
|
||||
ctx.arc(pixbuf.width - radius, pixbuf.height - radius, radius, 0 * degrees, 90 * degrees);
|
||||
ctx.arc(radius, pixbuf.height - radius, radius, 90 * degrees, 180 * degrees);
|
||||
ctx.arc(radius, radius, radius, 180 * degrees, 270 * degrees);
|
||||
ctx.close_path();
|
||||
ctx.clip();
|
||||
ctx.paint();
|
||||
return Gdk.pixbuf_get_from_surface(ctx.get_target(), 0, 0, pixbuf.width, pixbuf.height);
|
||||
}
|
||||
|
||||
public override void get_preferred_width(out int minimum_width, out int natural_width) {
|
||||
minimum_width = int.max(0, min_width);
|
||||
double exact_width = -1, exact_height = -1;
|
||||
|
|
|
@ -454,11 +454,11 @@ namespace GPG {
|
|||
|
||||
|
||||
[CCode (cname = "gpgme_data_new_from_mem")]
|
||||
public static GPGError.Error new_from_memory(out Data d, uint8[] buffer, bool copy);
|
||||
public static GPGError.Error new_from_memory(out Data d, char[] buffer, bool copy);
|
||||
|
||||
public static Data create_from_memory(uint8[] buffer, bool copy) throws GLib.Error {
|
||||
Data data;
|
||||
throw_if_error(new_from_memory(out data, buffer, copy));
|
||||
throw_if_error(new_from_memory(out data, (char[]) buffer, copy));
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class Plugin : RootInterface, Object {
|
|||
foreach(Dino.Entities.Account account in this.app.stream_interactor.get_accounts()) {
|
||||
if(account.id == variant.get_int32()) {
|
||||
ContactDetailsDialog dialog = new ContactDetailsDialog(this, account, account.bare_jid);
|
||||
dialog.set_transient_for((this.app as Gtk.Application).get_active_window());
|
||||
dialog.set_transient_for(((Gtk.Application) this.app).get_active_window());
|
||||
dialog.present();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ContactDetailsDialog : Gtk.Dialog {
|
|||
this.jid = jid;
|
||||
|
||||
if (Environment.get_variable("GTK_CSD") != "0") {
|
||||
(get_header_bar() as HeaderBar).set_subtitle(jid.bare_jid.to_string());
|
||||
((HeaderBar) get_header_bar()).set_subtitle(jid.bare_jid.to_string());
|
||||
}
|
||||
|
||||
keys_listbox.row_activated.connect(on_key_entry_clicked);
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
namespace Xmpp.Xep.DateTimeProfiles {
|
||||
|
||||
public DateTime? parse_string(string time_string) {
|
||||
TimeVal time_val = TimeVal();
|
||||
if (time_val.from_iso8601(time_string)) {
|
||||
return new DateTime.from_unix_utc(time_val.tv_sec);
|
||||
}
|
||||
return null;
|
||||
return new DateTime.from_iso8601(time_string, null);
|
||||
}
|
||||
|
||||
|
||||
public string to_datetime(DateTime time) {
|
||||
return time.to_utc().format("%Y-%m-%dT%H:%M:%SZ");
|
||||
return time.to_utc().format_iso8601().to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue