aboutsummaryrefslogtreecommitdiff
path: root/libdino/src
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src')
-rw-r--r--libdino/src/plugin/interfaces.vala6
-rw-r--r--libdino/src/plugin/loader.vala4
-rw-r--r--libdino/src/service/connection_manager.vala1
-rw-r--r--libdino/src/service/database.vala4
-rw-r--r--libdino/src/service/file_manager.vala36
5 files changed, 28 insertions, 23 deletions
diff --git a/libdino/src/plugin/interfaces.vala b/libdino/src/plugin/interfaces.vala
index 655ef13a..852aa596 100644
--- a/libdino/src/plugin/interfaces.vala
+++ b/libdino/src/plugin/interfaces.vala
@@ -64,7 +64,7 @@ public interface TextCommand : Object {
public interface ConversationTitlebarEntry : Object {
public abstract string id { get; }
public abstract double order { get; }
- public abstract ConversationTitlebarWidget get_widget(WidgetType type);
+ public abstract ConversationTitlebarWidget? get_widget(WidgetType type);
}
public interface ConversationTitlebarWidget : Object {
@@ -94,7 +94,7 @@ public abstract class MetaConversationItem : Object {
public abstract bool requires_avatar { get; set; }
public abstract bool requires_header { get; set; }
- public abstract Object get_widget(WidgetType type);
+ public abstract Object? get_widget(WidgetType type);
}
public interface ConversationItemCollection : Object {
@@ -110,7 +110,7 @@ public interface MessageDisplayProvider : Object {
}
public interface FileWidget : Object {
- public abstract Object get_widget(WidgetType type);
+ public abstract Object? get_widget(WidgetType type);
}
public interface FileDisplayProvider : Object {
diff --git a/libdino/src/plugin/loader.vala b/libdino/src/plugin/loader.vala
index 43876b92..102bf3f9 100644
--- a/libdino/src/plugin/loader.vala
+++ b/libdino/src/plugin/loader.vala
@@ -26,7 +26,7 @@ public class Loader : Object {
this.search_paths = app.search_path_generator.get_plugin_paths();
}
- public void loadAll() {
+ public void loadAll() throws Error {
if (Module.supported() == false) {
throw new Error(-1, 0, "Plugins are not supported");
}
@@ -95,4 +95,4 @@ public class Loader : Object {
}
}
-} \ No newline at end of file
+}
diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala
index 3f945f4c..60cd335a 100644
--- a/libdino/src/service/connection_manager.vala
+++ b/libdino/src/service/connection_manager.vala
@@ -59,7 +59,6 @@ public class ConnectionManager {
private class RecMutexWrap {
public RecMutex mutex = RecMutex();
- public void lock() { mutex.lock(); }
public void unlock() { mutex.unlock(); }
public bool trylock() { return mutex.trylock(); }
}
diff --git a/libdino/src/service/database.vala b/libdino/src/service/database.vala
index aaceede1..6b75b800 100644
--- a/libdino/src/service/database.vala
+++ b/libdino/src/service/database.vala
@@ -199,7 +199,9 @@ public class Database : Qlite.Database {
roster = new RosterTable(this);
settings = new SettingsTable(this);
init({ account, jid, message, real_jid, file_transfer, conversation, avatar, entity_feature, roster, settings });
- exec("PRAGMA synchronous=0");
+ try {
+ exec("PRAGMA synchronous=0");
+ } catch (Error e) { }
}
public override void migrate(long oldVersion) {
diff --git a/libdino/src/service/file_manager.vala b/libdino/src/service/file_manager.vala
index 92ca7506..571bbaab 100644
--- a/libdino/src/service/file_manager.vala
+++ b/libdino/src/service/file_manager.vala
@@ -35,9 +35,6 @@ public class FileManager : StreamInteractionModule, Object {
}
public void send_file(string uri, Conversation conversation) {
- File file = File.new_for_path(uri);
- FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
-
FileTransfer file_transfer = new FileTransfer();
file_transfer.account = conversation.account;
file_transfer.counterpart = conversation.counterpart;
@@ -46,11 +43,16 @@ public class FileManager : StreamInteractionModule, Object {
file_transfer.time = new DateTime.now_utc();
file_transfer.local_time = new DateTime.now_utc();
file_transfer.encryption = Encryption.NONE;
- file_transfer.file_name = file_info.get_display_name();
- file_transfer.input_stream = file.read();
-
- file_transfer.mime_type = file_info.get_content_type();
- file_transfer.size = (int)file_info.get_size();
+ try {
+ File file = File.new_for_path(uri);
+ FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
+ file_transfer.file_name = file_info.get_display_name();
+ file_transfer.mime_type = file_info.get_content_type();
+ file_transfer.size = (int)file_info.get_size();
+ file_transfer.input_stream = file.read();
+ } catch (Error e) {
+ file_transfer.state = FileTransfer.State.FAILED;
+ }
save_file(file_transfer);
file_transfer.persist(db);
@@ -90,7 +92,7 @@ public class FileManager : StreamInteractionModule, Object {
File file = File.new_for_path(Path.build_filename(get_storage_dir(), file_transfer.path ?? file_transfer.file_name));
try {
file_transfer.input_stream = file.read();
- } catch (IOError e) { }
+ } catch (Error e) { }
ret.insert(0, file_transfer);
}
return ret;
@@ -123,27 +125,29 @@ public class FileManager : StreamInteractionModule, Object {
}
save_file(file_transfer);
- File file = File.new_for_path(file_transfer.get_uri());
- FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
- file_transfer.mime_type = file_info.get_content_type();
+ try {
+ File file = File.new_for_path(file_transfer.get_uri());
+ FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE);
+ file_transfer.mime_type = file_info.get_content_type();
+ } catch (Error e) { }
file_transfer.persist(db);
received_file(file_transfer);
}
private void save_file(FileTransfer file_transfer) {
- string filename = Random.next_int().to_string("%x") + "_" + file_transfer.file_name;
- File file = File.new_for_path(Path.build_filename(get_storage_dir(), filename));
try {
+ string filename = Random.next_int().to_string("%x") + "_" + file_transfer.file_name;
+ File file = File.new_for_path(Path.build_filename(get_storage_dir(), filename));
OutputStream os = file.create(FileCreateFlags.REPLACE_DESTINATION);
os.splice(file_transfer.input_stream, 0);
os.close();
file_transfer.state = FileTransfer.State.COMPLETE;
+ file_transfer.path = filename;
+ file_transfer.input_stream = file.read();
} catch (Error e) {
file_transfer.state = FileTransfer.State.FAILED;
}
- file_transfer.path = filename;
- file_transfer.input_stream = file.read();
}
}