1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-08 19:34:14 -04:00
profanity/tests/xmpp/mock_xmpp.c

225 lines
7.9 KiB
C
Raw Normal View History

2013-12-14 11:17:53 -05:00
/*
* mock_xmpp.c
2013-12-14 11:17:53 -05:00
*
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <glib.h>
#include <setjmp.h>
#include <cmocka.h>
#include "xmpp/xmpp.h"
// connection functions
static void _jabber_init(const int disable_tls) {}
void (*jabber_init)(const int disable_tls) = _jabber_init;
2013-12-14 11:17:53 -05:00
static jabber_conn_status_t _jabber_connect_with_details(const char * const jid,
2013-12-14 11:17:53 -05:00
const char * const passwd, const char * const altdomain)
{
return JABBER_DISCONNECTED;
2013-12-14 11:17:53 -05:00
}
jabber_conn_status_t (*jabber_connect_with_details)(const char * const,
const char * const, const char * const) = _jabber_connect_with_details;
2013-12-14 11:17:53 -05:00
static jabber_conn_status_t _jabber_connect_with_account(const ProfAccount * const account)
2013-12-14 11:17:53 -05:00
{
return JABBER_DISCONNECTED;
2013-12-14 11:17:53 -05:00
}
jabber_conn_status_t (*jabber_connect_with_account)(const ProfAccount * const) = _jabber_connect_with_account;
2013-12-14 11:17:53 -05:00
static void _jabber_disconnect(void) {}
void (*jabber_disconnect)(void) = _jabber_disconnect;
static void _jabber_shutdown(void) {}
void (*jabber_shutdown)(void) = _jabber_shutdown;
static void _jabber_process_events(void) {}
void (*jabber_process_events)(void) = _jabber_process_events;
static const char * _jabber_get_fulljid(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
const char * (*jabber_get_fulljid)(void) = _jabber_get_fulljid;
static const char * _jabber_get_domain(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
const char * (*jabber_get_domain)(void) = _jabber_get_domain;
2013-12-14 11:17:53 -05:00
static jabber_conn_status_t _jabber_get_connection_status(void)
2013-12-14 11:17:53 -05:00
{
return JABBER_DISCONNECTED;
2013-12-14 11:17:53 -05:00
}
jabber_conn_status_t (*jabber_get_connection_status)(void) = _jabber_get_connection_status;
2013-12-14 11:17:53 -05:00
static char * _jabber_get_presence_message(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
char * (*jabber_get_presence_message)(void) = _jabber_get_presence_message;
static void _jabber_set_autoping(int seconds) {}
void (*jabber_set_autoping)(int) = _jabber_set_autoping;
2013-12-14 11:17:53 -05:00
static char * _jabber_get_account_name(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
char * (*jabber_get_account_name)(void) = _jabber_get_account_name;
2013-12-14 11:17:53 -05:00
static GList * _jabber_get_available_resources(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
GList * (*jabber_get_available_resources)(void) = _jabber_get_available_resources;
2013-12-14 11:17:53 -05:00
// message functions
static void _message_send(const char * const msg, const char * const recipient) {}
void (*message_send)(const char * const, const char * const) = _message_send;
static void _message_send_groupchat(const char * const msg, const char * const recipient) {}
void (*message_send_groupchat)(const char * const, const char * const) = _message_send_groupchat;
static void _message_send_inactive(const char * const recipient) {}
void (*message_send_inactive)(const char * const) = _message_send_inactive;
static void _message_send_composing(const char * const recipient) {}
void (*message_send_composing)(const char * const) = _message_send_composing;
static void _message_send_paused(const char * const recipient) {}
void (*message_send_paused)(const char * const) = _message_send_paused;
static void _message_send_gone(const char * const recipient) {}
void (*message_send_gone)(const char * const) = _message_send_gone;
static void _message_send_invite(const char * const room, const char * const contact,
2013-12-14 11:17:53 -05:00
const char * const reason) {}
void (*message_send_invite)(const char * const, const char * const,
const char * const) = _message_send_invite;
static void _message_send_duck(const char * const query) {}
void (*message_send_duck)(const char * const) = _message_send_duck;
2013-12-14 11:17:53 -05:00
// presence functions
static void _presence_subscription(const char * const jid, const jabber_subscr_t action) {}
void (*presence_subscription)(const char * const, const jabber_subscr_t) = _presence_subscription;
2013-12-14 11:17:53 -05:00
static GSList* _presence_get_subscription_requests(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
GSList* (*presence_get_subscription_requests)(void) = _presence_get_subscription_requests;
2013-12-14 11:17:53 -05:00
static gint _presence_sub_request_count(void)
2013-12-14 11:17:53 -05:00
{
return 0;
2013-12-14 11:17:53 -05:00
}
gint (*presence_sub_request_count)(void) = _presence_sub_request_count;
2013-12-14 11:17:53 -05:00
static void _presence_reset_sub_request_search(void) {}
void (*presence_reset_sub_request_search)(void) = _presence_reset_sub_request_search;
2013-12-14 11:17:53 -05:00
static char * _presence_sub_request_find(char * search_str)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
char * (*presence_sub_request_find)(char *) = _presence_sub_request_find;
2013-12-14 11:17:53 -05:00
static void _presence_join_room(Jid *jid) {}
void (*presence_join_room)(Jid *) = _presence_join_room;
static void _presence_change_room_nick(const char * const room, const char * const nick) {}
void (*presence_change_room_nick)(const char * const, const char * const) = _presence_change_room_nick;
static void _presence_leave_chat_room(const char * const room_jid) {}
void (*presence_leave_chat_room)(const char * const) = _presence_leave_chat_room;
static void _presence_update(resource_presence_t status, const char * const msg,
2013-12-14 11:17:53 -05:00
int idle) {}
void (*presence_update)(resource_presence_t, const char * const,
int) = _presence_update;
static gboolean _presence_sub_request_exists(const char * const bare_jid)
2013-12-14 11:17:53 -05:00
{
return FALSE;
2013-12-14 11:17:53 -05:00
}
gboolean (*presence_sub_request_exists)(const char * const bare_jid) = _presence_sub_request_exists;
2013-12-14 11:17:53 -05:00
// iq functions
static void _iq_send_software_version(const char * const fulljid) {}
void (*iq_send_software_version)(const char * const) = _iq_send_software_version;
static void _iq_room_list_request(gchar *conferencejid) {}
void (*iq_room_list_request)(gchar *) = _iq_room_list_request;
static void _iq_disco_info_request(gchar *jid) {}
void (*iq_disco_info_request)(gchar *) = _iq_disco_info_request;
static void _iq_disco_items_request(gchar *jid) {}
void (*iq_disco_items_request)(gchar *) = _iq_disco_items_request;
2013-12-14 11:17:53 -05:00
// caps functions
static Capabilities* _caps_get(const char * const caps_str)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
Capabilities* (*caps_get)(const char * const) = _caps_get;
static void _caps_close(void) {}
void (*caps_close)(void) = _caps_close;
2013-12-14 11:17:53 -05:00
static void _bookmark_add(const char *jid, const char *nick, gboolean autojoin) {}
void (*bookmark_add)(const char *, const char *, gboolean) = _bookmark_add;
2013-12-14 11:17:53 -05:00
static void _bookmark_remove(const char *jid, gboolean autojoin) {}
void (*bookmark_remove)(const char *, gboolean) = _bookmark_remove;
2013-12-14 11:17:53 -05:00
static const GList* _bookmark_get_list(void)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
const GList* (*bookmark_get_list)(void) = _bookmark_get_list;
2013-12-14 11:17:53 -05:00
static char* _bookmark_find(char *search_str)
2013-12-14 11:17:53 -05:00
{
return NULL;
2013-12-14 11:17:53 -05:00
}
char* (*bookmark_find)(char *) = _bookmark_find;
static void _bookmark_autocomplete_reset(void) {}
void (*bookmark_autocomplete_reset)(void) = _bookmark_autocomplete_reset;
static void _roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) {}
void (*roster_send_name_change)(const char * const, const char * const, GSList *) = _roster_send_name_change;
static void _roster_send_add_to_group(const char * const group, PContact contact) {}
void (*roster_send_add_to_group)(const char * const, PContact) = _roster_send_add_to_group;
static void _roster_send_remove_from_group(const char * const group, PContact contact) {}
void (*roster_send_remove_from_group)(const char * const, PContact) = _roster_send_remove_from_group;
2013-12-14 11:17:53 -05:00
static void _roster_add_new(const char * const barejid, const char * const name) {}
void (*roster_add_new)(const char * const, const char * const) = _roster_add_new;
2013-12-14 11:17:53 -05:00
static void _roster_send_remove(const char * const barejid) {}
void (*roster_send_remove)(const char * const) = _roster_send_remove;