Fix connecting to jingle file provider multiple times

This commit is contained in:
fiaxh 2022-12-18 21:14:43 +01:00 committed by Marvin W
parent 38584475a5
commit 156f75895e
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -64,7 +64,7 @@ public class JingleFileProvider : FileProvider, Object {
public JingleFileProvider(StreamInteractor stream_interactor) { public JingleFileProvider(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
stream_interactor.stream_negotiated.connect(on_stream_negotiated); stream_interactor.account_added.connect(on_account_added);
} }
public FileMeta get_file_meta(FileTransfer file_transfer) throws FileReceiveError { public FileMeta get_file_meta(FileTransfer file_transfer) throws FileReceiveError {
@ -114,15 +114,14 @@ public class JingleFileProvider : FileProvider, Object {
return 1; return 1;
} }
private void on_stream_negotiated(Account account, XmppStream stream) { private void on_account_added(Account account) {
XmppStream stream = stream_interactor.get_stream(account);
stream_interactor.module_manager.get_module(account, Xmpp.Xep.JingleFileTransfer.Module.IDENTITY).file_incoming.connect((stream, jingle_file_transfer) => { stream_interactor.module_manager.get_module(account, Xmpp.Xep.JingleFileTransfer.Module.IDENTITY).file_incoming.connect((stream, jingle_file_transfer) => {
Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jingle_file_transfer.peer.bare_jid, account); Conversation? conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jingle_file_transfer.peer.bare_jid, account);
if (conversation == null) { if (conversation == null) return;
// TODO(hrxi): What to do?
return;
}
string id = random_uuid();
string id = random_uuid();
file_transfers[id] = jingle_file_transfer; file_transfers[id] = jingle_file_transfer;
FileMeta file_meta = new FileMeta(); FileMeta file_meta = new FileMeta();