Check XmppStream against null
Most of the calls to stream_interactor.get_stream(account) were already doing null checks, but there were still some missing.
This commit is contained in:
parent
2c445501a4
commit
e1fd11775c
|
@ -144,7 +144,7 @@ public class AvatarManager : StreamInteractionModule, Object {
|
|||
}
|
||||
uint8[] buffer;
|
||||
pixbuf.save_to_buffer(out buffer, "png");
|
||||
XmppStream stream = stream_interactor.get_stream(account);
|
||||
XmppStream? stream = stream_interactor.get_stream(account);
|
||||
if (stream != null) {
|
||||
Xmpp.Xep.UserAvatars.publish_png(stream, buffer, pixbuf.width, pixbuf.height);
|
||||
}
|
||||
|
|
|
@ -21,22 +21,26 @@ public class BlockingManager : StreamInteractionModule, Object {
|
|||
}
|
||||
|
||||
public bool is_blocked(Account account, Jid jid) {
|
||||
XmppStream stream = stream_interactor.get_stream(account);
|
||||
XmppStream? stream = stream_interactor.get_stream(account);
|
||||
return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_blocked(stream, jid.to_string());
|
||||
}
|
||||
|
||||
public void block(Account account, Jid jid) {
|
||||
XmppStream stream = stream_interactor.get_stream(account);
|
||||
stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, { jid.to_string() });
|
||||
XmppStream? stream = stream_interactor.get_stream(account);
|
||||
if (stream != null) {
|
||||
stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).block(stream, { jid.to_string() });
|
||||
}
|
||||
}
|
||||
|
||||
public void unblock(Account account, Jid jid) {
|
||||
XmppStream stream = stream_interactor.get_stream(account);
|
||||
stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, { jid.to_string() });
|
||||
XmppStream? stream = stream_interactor.get_stream(account);
|
||||
if (stream != null) {
|
||||
stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).unblock(stream, { jid.to_string() });
|
||||
}
|
||||
}
|
||||
|
||||
public bool is_supported(Account account) {
|
||||
XmppStream stream = stream_interactor.get_stream(account);
|
||||
XmppStream? stream = stream_interactor.get_stream(account);
|
||||
return stream != null && stream.get_module(Xmpp.Xep.BlockingCommand.Module.IDENTITY).is_supported(stream);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class Dino.CallState : Object {
|
|||
call.state = Call.State.DECLINED;
|
||||
|
||||
if (use_cim) {
|
||||
XmppStream stream = stream_interactor.get_stream(call.account);
|
||||
XmppStream? stream = stream_interactor.get_stream(call.account);
|
||||
if (stream == null) return;
|
||||
stream.get_module(Xep.CallInvites.Module.IDENTITY).send_reject(stream, cim_counterpart, cim_call_id, cim_message_type);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class Dino.CallState : Object {
|
|||
peers_cpy.add_all(peers.values);
|
||||
|
||||
if (group_call != null) {
|
||||
XmppStream stream = stream_interactor.get_stream(call.account);
|
||||
XmppStream? stream = stream_interactor.get_stream(call.account);
|
||||
if (stream != null) {
|
||||
stream.get_module(Xep.Muc.Module.IDENTITY).exit(stream, group_call.muc_jid);
|
||||
}
|
||||
|
|
|
@ -366,7 +366,10 @@ public class Dino.HistorySync {
|
|||
* prev_page_result: null if this is the first page request
|
||||
**/
|
||||
private async PageRequestResult get_mam_page(Account account, Xmpp.MessageArchiveManagement.V2.MamQueryParams query_params, PageRequestResult? prev_page_result, Cancellable? cancellable = null) {
|
||||
XmppStream stream = stream_interactor.get_stream(account);
|
||||
XmppStream? stream = stream_interactor.get_stream(account);
|
||||
if (stream == null) {
|
||||
return new PageRequestResult.with_result(PageResult.Error);
|
||||
}
|
||||
Xmpp.MessageArchiveManagement.QueryResult query_result = null;
|
||||
if (prev_page_result == null) {
|
||||
query_result = yield Xmpp.MessageArchiveManagement.V2.query_archive(stream, query_params, cancellable);
|
||||
|
@ -592,5 +595,9 @@ public class Dino.HistorySync {
|
|||
this.query_result = query_result;
|
||||
this.stanzas = stanzas;
|
||||
}
|
||||
|
||||
public PageRequestResult.with_result(PageResult page_result) {
|
||||
this.page_result = page_result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,11 @@ namespace Xmpp.MessageArchiveManagement.V2 {
|
|||
}
|
||||
}
|
||||
|
||||
private StanzaNode create_base_query(XmppStream stream, MamQueryParams mam_params) {
|
||||
private StanzaNode create_base_query(XmppStream? stream, MamQueryParams mam_params) {
|
||||
if (stream == null) {
|
||||
return new StanzaNode();
|
||||
}
|
||||
|
||||
var fields = new ArrayList<DataForms.DataForm.Field>();
|
||||
|
||||
if (mam_params.with != null) {
|
||||
|
@ -61,7 +65,12 @@ namespace Xmpp.MessageArchiveManagement.V2 {
|
|||
return MessageArchiveManagement.create_base_query(stream, MessageArchiveManagement.NS_URI_2, mam_params.query_id, fields);
|
||||
}
|
||||
|
||||
public async QueryResult query_archive(XmppStream stream, MamQueryParams mam_params, Cancellable? cancellable = null) {
|
||||
public async QueryResult query_archive(XmppStream? stream, MamQueryParams mam_params, Cancellable? cancellable = null) {
|
||||
if (stream == null) {
|
||||
var result = new QueryResult();
|
||||
result.error = true;
|
||||
return result;
|
||||
}
|
||||
var query_node = create_base_query(stream, mam_params);
|
||||
if (!mam_params.use_ns2_extended) {
|
||||
query_node.put_node(ResultSetManagement.create_set_rsm_node_before(mam_params.end_id));
|
||||
|
|
|
@ -53,7 +53,11 @@ public class Module : XmppStreamModule {
|
|||
}
|
||||
}
|
||||
|
||||
internal StanzaNode create_base_query(XmppStream stream, string ns, string? queryid, Gee.List<DataForms.DataForm.Field> fields) {
|
||||
internal StanzaNode create_base_query(XmppStream? stream, string ns, string? queryid, Gee.List<DataForms.DataForm.Field> fields) {
|
||||
if (stream == null) {
|
||||
return new StanzaNode();
|
||||
}
|
||||
|
||||
DataForms.DataForm data_form = new DataForms.DataForm();
|
||||
|
||||
DataForms.DataForm.HiddenField form_type_field = new DataForms.DataForm.HiddenField() { var="FORM_TYPE" };
|
||||
|
@ -156,7 +160,11 @@ public class MessageFlag : Xmpp.MessageFlag {
|
|||
}
|
||||
|
||||
private static string NS_VER(XmppStream stream) {
|
||||
return stream.get_flag(Flag.IDENTITY).ns_ver;
|
||||
var? flag = stream.get_flag(Flag.IDENTITY);
|
||||
if (flag == null) {
|
||||
return "";
|
||||
}
|
||||
return flag.ns_ver;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue