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

332 lines
8.3 KiB
C
Raw 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
2016-05-05 19:53:03 -04:00
void session_init(void) {}
2016-07-24 11:06:19 -04:00
void session_init_activity(void) {}
void session_check_autoaway(void) {}
2014-12-23 14:26:45 -05:00
2016-05-05 19:53:03 -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)
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
}
2016-05-05 19:53:03 -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
}
2016-05-05 19:53:03 -04:00
void session_disconnect(void) {}
void session_shutdown(void) {}
void session_process_events(void) {}
2016-05-05 20:12:54 -04:00
const char * connection_get_fulljid(void)
2014-12-23 14:26:45 -05:00
{
return mock_ptr_type(char *);
2014-12-23 14:26:45 -05:00
}
2020-05-28 10:09:32 -04:00
char* connection_get_barejid(void)
{
return mock_ptr_type(char *);
}
const char * connection_get_domain(void)
{
return NULL;
}
2016-05-05 21:18:31 -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;
}
2016-05-05 20:16:13 -04:00
char* connection_create_uuid(void)
2015-10-12 18:44:03 -04:00
{
return NULL;
}
2016-05-05 20:16:13 -04:00
void connection_free_uuid(char * uuid) {}
2015-10-12 18:44:03 -04:00
2016-05-05 18:51:49 -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
}
2016-05-05 18:51:49 -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
}
2016-05-05 19:53:03 -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
}
2016-05-05 19:53:03 -04:00
GList * session_get_available_resources(void)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
void connection_set_presence_msg(const char *const message) {}
2016-03-23 18:57:03 -04:00
gboolean
2016-05-05 20:51:58 -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
2016-05-07 18:28:16 -04:00
connection_supports(const char *const feature)
2016-05-01 14:39:39 -04:00
{
return FALSE;
}
const char* connection_get_profanity_identifier(void) {
return "profident";
}
2014-12-23 14:26:45 -05:00
// message functions
2020-02-13 03:17:52 -05: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-02-13 03:17:52 -05: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-02-13 03:17:52 -05: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-03-28 07:05:33 -04:00
char* message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url)
{
return NULL;
}
2020-02-13 03:17:52 -05: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
2014-12-23 14:26:45 -05:00
void message_send_groupchat_subject(const char * const roomjid, const char * const subject) {}
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) {}
void message_send_invite(const char * const room, const char * const contact,
const char * const reason) {}
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
void presence_subscription(const char * const jid, const jabber_subscr_t action) {}
GList* presence_get_subscription_requests(void)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
gint presence_sub_request_count(void)
{
return 0;
}
void presence_reset_sub_request_search(void) {}
char * presence_sub_request_find(const char * const search_str, gboolean previous, void *context)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
2016-04-30 20:27:28 -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);
}
2014-12-23 14:26:45 -05: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
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
gboolean presence_sub_request_exists(const char * const bare_jid)
{
return FALSE;
}
// iq functions
2015-02-02 05:10:05 -05:00
void iq_disable_carbons() {};
void iq_enable_carbons() {};
2014-12-23 14:26:45 -05:00
void iq_send_software_version(const char * const fulljid) {}
2014-12-24 18:38:23 -05:00
2018-01-27 18:51:03 -05: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
}
2014-12-23 14:26:45 -05:00
void iq_disco_info_request(gchar *jid) {}
void iq_disco_items_request(gchar *jid) {}
void iq_set_autoping(int seconds) {}
2016-04-11 14:13:18 -04:00
void iq_http_upload_request(HTTPUpload *upload) {}
2014-12-23 14:26:45 -05:00
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) {}
2018-05-30 13:25:06 -04:00
void iq_submit_room_config(ProfConfWin *confwin) {}
void iq_room_config_cancel(ProfConfWin *confwin) {}
2014-12-23 14:26:45 -05:00
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) {}
2014-12-23 14:26:45 -05:00
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) {}
2015-12-30 20:48:04 -05:00
void iq_autoping_check(void) {}
2018-02-05 15:01:54 -05:00
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) {}
2014-12-23 14:26:45 -05:00
// caps functions
void caps_add_feature(char *feature) {}
void caps_remove_feature(char *feature) {}
EntityCapabilities* caps_lookup(const char * const jid)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
void caps_close(void) {}
void caps_destroy(EntityCapabilities *caps) {}
void caps_reset_ver(void) {}
gboolean caps_jid_has_feature(const char *const jid, const char *const feature)
{
return FALSE;
}
2014-12-23 14:26:45 -05:00
2020-05-22 08:36:36 -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-05-22 08:36:36 -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;
}
gboolean bookmark_remove(const char *jid)
{
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
}
gboolean bookmark_join(const char *jid)
{
return FALSE;
}
2016-08-21 10:25:49 -04:00
GList * bookmark_get_list(void)
2014-12-23 14:26:45 -05:00
{
return mock_ptr_type(GList *);
2014-12-23 14:26:45 -05:00
}
char * bookmark_find(const char * const search_str, gboolean previous, void *context)
2014-12-23 14:26:45 -05:00
{
return NULL;
}
void bookmark_autocomplete_reset(void) {}
2014-12-24 18:59:26 -05:00
void roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups)
{
check_expected(barejid);
check_expected(new_name);
check_expected(groups);
}
gboolean bookmark_exists(const char *const room)
{
return FALSE;
}
2014-12-23 14:26:45 -05: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
void roster_send_add_new(const char * const barejid, const char * const name)
{
check_expected(barejid);
check_expected(name);
}
void roster_send_remove(const char * const barejid)
{
check_expected(barejid);
}
2016-05-01 14:39:39 -04:00
GList* blocked_list(void)
{
return NULL;
}
gboolean blocked_add(char *jid)
{
return TRUE;
}
gboolean blocked_remove(char *jid)
{
return TRUE;
}
char* blocked_ac_find(const char *const search_str, gboolean previous, void *context)
2016-05-01 14:39:39 -04:00
{
return NULL;
}
void blocked_ac_reset(void) {}