1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00
profanity/tests/unittests/xmpp/stub_xmpp.c

583 lines
9.4 KiB
C
Raw Permalink Normal View History

2014-12-23 16:42:01 -05:00
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
2014-12-23 14:26:45 -05:00
2014-12-23 16:42:01 -05:00
#include "xmpp/xmpp.h"
2014-12-23 14:26:45 -05:00
// connection functions
2020-07-07 08:18:57 -04:00
void
session_init(void)
{
}
void
session_init_activity(void)
{
}
void
session_check_autoaway(void)
{
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
jabber_conn_status_t
session_connect_with_details(const char* const jid,
const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy,
const char* const auth_policy)
2014-12-23 14:26:45 -05:00
{
2014-12-24 16:34:11 -05:00
check_expected(jid);
check_expected(passwd);
check_expected(altdomain);
check_expected(port);
2019-05-08 15:52:16 -04:00
return mock_type(jabber_conn_status_t);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
jabber_conn_status_t
session_connect_with_account(const ProfAccount* const account)
2014-12-23 14:26:45 -05:00
{
2014-12-24 16:34:11 -05:00
check_expected(account);
2019-05-08 15:52:16 -04:00
return mock_type(jabber_conn_status_t);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
void
session_disconnect(void)
{
}
void
session_shutdown(void)
2014-12-23 14:26:45 -05:00
{
2020-07-07 08:18:57 -04:00
}
void
session_process_events(void)
{
}
const char*
connection_get_fulljid(void)
{
return mock_ptr_type(char*);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
char*
connection_get_barejid(void)
2020-05-28 10:09:32 -04:00
{
2020-07-07 08:18:57 -04:00
return mock_ptr_type(char*);
2020-05-28 10:09:32 -04:00
}
char*
connection_get_user(void)
{
return mock_ptr_type(char*);
}
2020-07-07 08:18:57 -04:00
const char*
connection_get_domain(void)
{
return NULL;
}
2020-07-07 08:18:57 -04:00
gboolean
connection_is_secured(void)
2016-05-05 19:53:03 -04:00
{
return 1;
}
TLSCertificate*
2016-05-05 20:47:19 -04:00
connection_get_tls_peer_cert(void)
2016-05-05 19:53:03 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
char*
connection_create_uuid(void)
2015-10-12 18:44:03 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
void
connection_free_uuid(char* uuid)
{
}
2015-10-12 18:44:03 -04:00
2020-07-07 08:18:57 -04:00
jabber_conn_status_t
connection_get_status(void)
2014-12-23 14:26:45 -05:00
{
2019-05-08 15:52:16 -04:00
return mock_type(jabber_conn_status_t);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
char*
connection_get_presence_msg(void)
2014-12-23 14:26:45 -05:00
{
return mock_ptr_type(char*);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
char*
session_get_account_name(void)
2014-12-23 14:26:45 -05:00
{
return mock_ptr_type(char*);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
GList*
session_get_available_resources(void)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
void
connection_set_presence_msg(const char* const message)
{
}
2016-03-23 18:57:03 -04:00
gboolean
2020-07-07 08:18:57 -04:00
connection_send_stanza(const char* const stanza)
2016-03-23 18:57:03 -04:00
{
return TRUE;
}
2016-05-01 14:39:39 -04:00
gboolean
2020-07-07 08:18:57 -04:00
connection_supports(const char* const feature)
2016-05-01 14:39:39 -04:00
{
return FALSE;
}
2020-07-07 08:18:57 -04:00
const char*
connection_get_profanity_identifier(void)
{
return "profident";
}
2021-10-13 15:19:54 -04:00
jabber_conn_status_t
connection_register(const char* const altdomain, int port, const char* const tls_policy,
2021-10-13 15:32:44 -04:00
const char* const username, const char* const password)
2021-10-13 15:19:54 -04:00
{
check_expected(altdomain);
check_expected(port);
check_expected(tls_policy);
check_expected(username);
check_expected(password);
return mock_type(jabber_conn_status_t);
}
2014-12-23 14:26:45 -05:00
// message functions
2020-07-07 08:18:57 -04:00
char*
message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id)
2014-12-24 18:32:32 -05:00
{
check_expected(barejid);
check_expected(msg);
return NULL;
2014-12-24 18:32:32 -05:00
}
2020-07-07 08:18:57 -04:00
char*
message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id)
{
check_expected(barejid);
check_expected(msg);
return NULL;
}
2020-07-07 08:18:57 -04:00
char*
message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id)
2015-06-20 20:48:25 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
char*
message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id)
2020-06-29 15:21:16 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
char*
message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url)
2020-03-28 07:05:33 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
char*
message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id)
{
return NULL;
}
2020-03-28 07:05:33 -04:00
2020-07-07 08:18:57 -04:00
void
message_send_groupchat_subject(const char* const roomjid, const char* const subject)
{
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
void
message_send_inactive(const char* const barejid)
{
}
void
message_send_composing(const char* const barejid)
{
}
void
message_send_paused(const char* const barejid)
{
}
void
message_send_gone(const char* const barejid)
{
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
void
message_send_invite(const char* const room, const char* const contact,
const char* const reason)
{
}
2014-12-23 14:26:45 -05:00
void
message_request_voice(const char* const roomjid)
{
}
2020-07-07 08:18:57 -04:00
bool
message_is_sent_by_us(const ProfMessage* const message, bool checkOID)
{
2019-10-18 08:53:06 -04:00
return TRUE;
}
2014-12-23 14:26:45 -05:00
// presence functions
2020-07-07 08:18:57 -04:00
void
presence_subscription(const char* const jid, const jabber_subscr_t action)
{
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
GList*
presence_get_subscription_requests(void)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
gint
presence_sub_request_count(void)
2014-12-23 14:26:45 -05:00
{
return 0;
}
2020-07-07 08:18:57 -04:00
void
presence_reset_sub_request_search(void)
{
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
char*
presence_sub_request_find(const char* const search_str, gboolean previous, void* context)
2014-12-23 14:26:45 -05:00
{
2020-07-07 08:18:57 -04:00
return NULL;
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
void
presence_join_room(const char* const room, const char* const nick, const char* const passwd)
2014-12-24 17:36:48 -05:00
{
check_expected(room);
check_expected(nick);
check_expected(passwd);
}
2020-07-07 08:18:57 -04:00
void
presence_change_room_nick(const char* const room, const char* const nick)
{
}
void
presence_leave_chat_room(const char* const room_jid)
{
}
2014-12-24 12:35:02 -05:00
2020-07-07 08:18:57 -04:00
void
presence_send(resource_presence_t status, int idle, char* signed_status)
2014-12-24 12:35:02 -05:00
{
check_expected(status);
check_expected(idle);
check_expected(signed_status);
2014-12-24 12:35:02 -05:00
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
gboolean
presence_sub_request_exists(const char* const bare_jid)
2014-12-23 14:26:45 -05:00
{
return FALSE;
}
// iq functions
2020-07-07 08:18:57 -04:00
void iq_disable_carbons(){};
void iq_enable_carbons(){};
void
iq_send_software_version(const char* const fulljid)
{
}
2014-12-24 18:38:23 -05:00
2020-07-07 08:18:57 -04:00
void
iq_room_list_request(gchar* conferencejid, gchar* filter)
2014-12-24 18:38:23 -05:00
{
check_expected(conferencejid);
2018-01-27 18:51:03 -05:00
check_expected(filter);
2014-12-24 18:38:23 -05:00
}
2020-07-07 08:18:57 -04:00
void
iq_disco_info_request(gchar* jid)
{
}
void
iq_disco_items_request(gchar* jid)
{
}
void
iq_set_autoping(int seconds)
{
}
void
iq_http_upload_request(HTTPUpload* upload)
{
}
void
iq_confirm_instant_room(const char* const room_jid)
{
}
void
iq_destroy_room(const char* const room_jid)
{
}
void
iq_request_room_config_form(const char* const room_jid)
{
}
void
iq_submit_room_config(ProfConfWin* confwin)
{
}
void
iq_room_config_cancel(ProfConfWin* confwin)
{
}
void
iq_send_ping(const char* const target)
{
}
void
iq_send_caps_request(const char* const to, const char* const id,
const char* const node, const char* const ver)
{
}
void
iq_send_caps_request_for_jid(const char* const to, const char* const id,
const char* const node, const char* const ver)
{
}
void
iq_send_caps_request_legacy(const char* const to, const char* const id,
const char* const node, const char* const ver)
{
}
void
iq_room_info_request(const char* const room, gboolean display)
{
}
void
iq_room_affiliation_list(const char* const room, char* affiliation, bool show)
{
}
void
iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation,
const char* const reason)
{
}
void
iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason)
{
}
void
iq_room_role_set(const char* const room, const char* const nick, char* role,
const char* const reason)
{
}
void
iq_room_role_list(const char* const room, char* role)
{
}
void
iq_last_activity_request(gchar* jid)
{
}
void
iq_autoping_timer_cancel(void)
{
}
void
iq_autoping_check(void)
{
}
void
iq_rooms_cache_clear(void)
{
}
void
iq_command_list(const char* const target)
{
}
void
iq_command_exec(const char* const target, const char* const command)
{
}
void
iq_register_change_password(const char* const user, const char* const password)
{
}
2014-12-23 14:26:45 -05:00
void
iq_muc_register_nick(const char* const roomjid)
{
}
2014-12-23 14:26:45 -05:00
// caps functions
2020-07-07 08:18:57 -04:00
void
caps_add_feature(char* feature)
{
}
2020-07-07 08:18:57 -04:00
void
caps_remove_feature(char* feature)
{
}
2020-07-07 08:18:57 -04:00
EntityCapabilities*
caps_lookup(const char* const jid)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
void
caps_close(void)
{
}
2020-07-07 08:18:57 -04:00
void
caps_destroy(EntityCapabilities* caps)
{
}
2020-07-07 08:18:57 -04:00
void
caps_reset_ver(void)
{
}
2020-07-07 08:18:57 -04:00
gboolean
caps_jid_has_feature(const char* const jid, const char* const feature)
{
return FALSE;
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
gboolean
bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name)
2014-12-23 14:26:45 -05:00
{
2014-12-24 15:41:28 -05:00
check_expected(jid);
check_expected(nick);
check_expected(password);
check_expected(autojoin_str);
2019-05-08 15:52:16 -04:00
return mock_type(gboolean);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
gboolean
bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name)
2014-12-23 14:26:45 -05:00
{
return FALSE;
}
2020-07-07 08:18:57 -04:00
gboolean
bookmark_remove(const char* jid)
2014-12-23 14:26:45 -05:00
{
2014-12-24 15:41:28 -05:00
check_expected(jid);
2019-05-08 15:52:16 -04:00
return mock_type(gboolean);
2014-12-23 14:26:45 -05:00
}
2020-07-07 08:18:57 -04:00
gboolean
bookmark_join(const char* jid)
2014-12-23 14:26:45 -05:00
{
return FALSE;
}
2020-07-07 08:18:57 -04:00
GList*
bookmark_get_list(void)
2014-12-23 14:26:45 -05:00
{
2020-07-07 08:18:57 -04:00
return mock_ptr_type(GList*);
2014-12-23 14:26:45 -05:00
}
Bookmark*
bookmark_get_by_jid(const char* jid)
{
return NULL;
}
2020-07-07 08:18:57 -04:00
char*
bookmark_find(const char* const search_str, gboolean previous, void* context)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
void
bookmark_autocomplete_reset(void)
{
}
2014-12-23 14:26:45 -05:00
2020-07-07 08:18:57 -04:00
void
roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups)
2014-12-24 18:59:26 -05:00
{
check_expected(barejid);
check_expected(new_name);
check_expected(groups);
}
2020-07-07 08:18:57 -04:00
gboolean
bookmark_exists(const char* const room)
{
return FALSE;
}
2020-07-07 08:18:57 -04:00
void
roster_send_add_to_group(const char* const group, PContact contact)
{
}
void
roster_send_remove_from_group(const char* const group, PContact contact)
{
}
2014-12-24 18:59:26 -05:00
2020-07-07 08:18:57 -04:00
void
roster_send_add_new(const char* const barejid, const char* const name)
2014-12-24 18:59:26 -05:00
{
check_expected(barejid);
check_expected(name);
}
2020-07-07 08:18:57 -04:00
void
roster_send_remove(const char* const barejid)
2014-12-24 18:59:26 -05:00
{
check_expected(barejid);
}
2016-05-01 14:39:39 -04:00
2020-07-07 08:18:57 -04:00
GList*
blocked_list(void)
2016-05-01 14:39:39 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
gboolean
2021-07-01 04:38:38 -04:00
blocked_add(char* jid, blocked_report reportkind, const char* const message)
2016-05-01 14:39:39 -04:00
{
return TRUE;
}
2020-07-07 08:18:57 -04:00
gboolean
blocked_remove(char* jid)
2016-05-01 14:39:39 -04:00
{
return TRUE;
}
2020-07-07 08:18:57 -04:00
char*
blocked_ac_find(const char* const search_str, gboolean previous, void* context)
2016-05-01 14:39:39 -04:00
{
return NULL;
}
2020-07-07 08:18:57 -04:00
void
blocked_ac_reset(void)
{
}