diff options
Diffstat (limited to 'tests')
71 files changed, 0 insertions, 10899 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 09a4989..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -SUBDIRS = $(CHECKTWISTED) suppressions lib dbus - -EXTRA_DIST = logs - -noinst_PROGRAMS = \ - test-tpl-conf \ - $(NULL) - -TESTS = $(noinst_PROGRAMS) - -LDADD = \ - $(top_builddir)/telepathy-logger/libtelepathy-logger-1.la \ - $(TPL_LIBS) - -AM_CFLAGS = \ - $(ERROR_CFLAGS) \ - $(TPL_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(NULL) - -TESTS_ENVIRONMENT = \ - G_DEBUG=fatal-warnings,fatal-criticals \ - TPL_TEST_MODE=true \ - TEST_LOG_DIR=@abs_top_srcdir@/tests/logs \ - $(top_srcdir)/tools/test-wrapper.sh \ - $(NULL) - -check-valgrind: $(TESTS) - G_SLICE=always-malloc \ - G_DEBUG=gc-friendly \ - $(MAKE) \ - TESTS_ENVIRONMENT="$(TESTS_ENVIRONMENT) \ - libtool --mode=execute valgrind \ - --leak-check=full \ - --show-reachable=no \ - --gen-suppressions=all \ - --num-callers=20 \ - --suppressions=@abs_top_srcdir@/tests/suppressions/tpl.supp \ - --error-exitcode=1" \ - check-TESTS - -check_c_sources = \ - $(dbus_test_sources) \ - test-tpl-conf.c \ - $(NULL) - -include $(top_srcdir)/tools/check-coding-style.mk -check-local: check-coding-style diff --git a/tests/README b/tests/README deleted file mode 100644 index b402ba5..0000000 --- a/tests/README +++ /dev/null @@ -1,48 +0,0 @@ -To run all tests: - - make check - -or with coverage info: - - ./configure --enable-compiler-coverage - make lcov-check - -== C tests == - -To run all C tests (assuming the current directory is $top_srcdir): - - make -C tests check-TESTS - -To run an individual test: - - make -C tests check-TESTS TESTS=test-handles - -To run tests under Valgrind: - - make -C tests check-valgrind - -To run an individual test under Valgrind: - - make -C tests check-valgrind TESTS=test-handles - -To debug an individual test you can set one of the following env variable: - - * TPL_TEST_VALGRIND : to run Gabble inside valgrind. The report is - added to tools/tpl-testing.log. - export TPL_TEST_VALGRIND=1 - - * TPL_TEST_REFDBG : to run Gabble inside refdbg. The report is written - to tools/refdbg.log. You can change TPL_WRAPPER to use an alternative - refdbg and change REFDBG_OPTIONS to set your own parameters. Example: - export TPL_TEST_REFDBG=1 - export TPL_WRAPPER="/path/to/refdbg" - export REFDBG_OPTIONS="btnum=16" - - * TPL_WRAPPER="nemiver" : to run Gabble inside the graphical debugger - nemiver. You'll be able to set up breakpoints; then hit the "continue" - button to launch Gabble. - - * TPL_TEST_STRACE : to run Gabble inside strace. The report is written - to tools/strace.log. - export TPL_TEST_STRACE=1 - diff --git a/tests/constants.h b/tests/constants.h deleted file mode 100644 index 7eb4b9e..0000000 --- a/tests/constants.h +++ /dev/null @@ -1,2 +0,0 @@ -#define ACCOUNT_PATH "/im.telepathy1/Account/gabble/jabber/cosimo_2ealfarano_40collabora_2eco_2euk0" -#define ID "echo@test.collabora.co.uk" diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am deleted file mode 100644 index 36c39d0..0000000 --- a/tests/dbus/Makefile.am +++ /dev/null @@ -1,84 +0,0 @@ -noinst_PROGRAMS = \ - test-entity \ - test-log-manager \ - test-tpl-log-store-pidgin \ - test-tpl-log-iter-pidgin \ - test-tpl-log-store-sqlite \ - test-tpl-log-store-xml \ - test-tpl-log-iter-xml \ - test-tpl-log-walker \ - test-tpl-observer \ - $(NULL) - -TESTS = $(noinst_PROGRAMS) - -LDADD = \ - $(top_builddir)/tests/lib/libtp-logger-tests.la \ - $(top_builddir)/telepathy-logger/libtelepathy-logger-1.la \ - $(TPL_LIBS) \ - $(NULL) - -test_entity_LDADD = \ - $(top_builddir)/tests/lib/libtp-logger-tests.la \ - $(LDADD) \ - $(NULL) - -check_c_sources = *.c -include $(top_srcdir)/tools/check-coding-style.mk -check-local: check-coding-style - -AM_CFLAGS = \ - $(ERROR_CFLAGS) \ - $(TPL_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/tests - $(NULL) - -TESTS_ENVIRONMENT = \ - abs_top_builddir=@abs_top_builddir@ \ - TPL_TEST_MODE=true \ - TPL_TEST_LOG_DIR=@abs_top_srcdir@/tests/logs \ - GSETTINGS_SCHEMA_DIR=@abs_srcdir@/data \ - XDG_DATA_HOME=@abs_top_builddir@/tests/logs \ - XDG_DATA_DIRS=@abs_srcdir@ \ - G_SLICE=debug-blocks \ - TPL_DEBUG=all \ - G_DEBUG=fatal_warnings,fatal_criticals$(maybe_gc_friendly) \ - $(top_srcdir)/tools/test-wrapper.sh \ - sh $(top_srcdir)/tools/with-session-bus.sh \ - --config-file=dbus-1/session.conf -- \ - $(EXTRA_TESTS_ENVIRONMENT) - -EXTRA_TESTS_ENVIRONMENT = - -check-valgrind: - $(MAKE) check-TESTS \ - maybe_gc_friendly=,gc-friendly \ - TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" - -include $(top_srcdir)/tools/valgrind.mk - -VALGRIND_TESTS_ENVIRONMENT = \ - $(TESTS_ENVIRONMENT) \ - env G_SLICE=always-malloc CHECK_VERBOSE=1 \ - $(top_builddir)/libtool --mode=execute \ - $(VALGRIND) --suppressions=$(top_srcdir)/tests/suppressions/tpl.supp $(VALGRIND_FLAGS) - -BUILT_SOURCES = \ - dbus-1/session.conf \ - $(NULL) - -CLEANFILES = $(BUILT_SOURCES) - -distclean-local: - rm -f capture-*.log - rm -rf _gen - -EXTRA_DIST = \ - dbus-1/session.conf.in \ - $(NULL) - -dbus-1/%.conf: $(srcdir)/dbus-1/%.conf.in - $(AM_V_at)$(mkdir_p) dbus-1 - $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ diff --git a/tests/dbus/dbus-1/session.conf.in b/tests/dbus/dbus-1/session.conf.in deleted file mode 100644 index b934b1d..0000000 --- a/tests/dbus/dbus-1/session.conf.in +++ /dev/null @@ -1,30 +0,0 @@ -<!-- Copied from telepathy-gabble (which doubtless copied it from somewhere - else) and modified. - This configuration file controls the per-user-login-session message bus. - Add a session-local.conf and edit that rather than changing this - file directly. --> - -<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> -<busconfig> - <!-- Our well-known bus type, don't change this --> - <type>session</type> - - <listen>unix:tmpdir=/tmp</listen> - - <servicedir>@abs_top_builddir@/tests/dbus/dbus-1/services/</servicedir> - - <policy context="default"> - <!-- Allow everything to be sent --> - <allow send_destination="*" eavesdrop="true"/> - <!-- Allow everything to be received --> - <allow eavesdrop="true"/> - <!-- Allow anyone to own anything --> - <allow own="*"/> - </policy> - - <!-- This is included last so local configuration can override what's - in this standard file --> - - -</busconfig> diff --git a/tests/dbus/test-entity.c b/tests/dbus/test-entity.c deleted file mode 100644 index b345b5e..0000000 --- a/tests/dbus/test-entity.c +++ /dev/null @@ -1,171 +0,0 @@ -#include "config.h" - -#include <glib.h> -#include <glib/gprintf.h> -#include <telepathy-logger/entity.h> -#include <telepathy-logger/entity-internal.h> - -#include "lib/util.h" -#include "lib/contacts-conn.h" - -static void -test_entity_instantiation (void) -{ - TplEntity *entity; - - entity = tpl_entity_new ("my-identifier", TPL_ENTITY_CONTACT, - "my-alias", "my-token"); - - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "my-identifier"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_CONTACT); - g_assert_cmpstr (tpl_entity_get_alias (entity), ==, "my-alias"); - g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, "my-token"); - - g_object_unref (entity); - - /* Check that identifier is copied in absence of ID */ - entity = tpl_entity_new ("my-identifier", TPL_ENTITY_CONTACT, - NULL, NULL); - - g_assert_cmpstr (tpl_entity_get_alias (entity), ==, "my-identifier"); - g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, ""); - - g_object_unref (entity); -} - -static void -test_entity_instantiation_from_room_id (void) -{ - TplEntity *entity; - - entity = tpl_entity_new_from_room_id ("my-room-id"); - - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "my-room-id"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_ROOM); - g_assert_cmpstr (tpl_entity_get_alias (entity), ==, "my-room-id"); - g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, ""); - - g_object_unref (entity); -} - -typedef struct { - TpContact *contact; - GMainLoop *loop; -} Result; - -static void -ensure_contact_cb (GObject *source, - GAsyncResult *op_result, - gpointer user_data) -{ - Result *result = user_data; - GError *error = NULL; - - result->contact = tp_client_factory_ensure_contact_by_id_finish ( - TP_CLIENT_FACTORY (source), op_result, &error); - - g_assert_no_error (error); - g_assert (TP_IS_CONTACT (result->contact)); - - g_main_loop_quit (result->loop); -} - -static void -test_entity_instantiation_from_tp_contact (void) -{ - TpBaseConnection *base_connection; - TpConnection *client_connection; - TpTestsContactsConnection *connection; - TpHandleRepoIface *repo; - TpHandle handles[2]; - const char *alias[] = {"Alice in Wonderland", "Bob the builder"}; - const char *avatar_tokens[] = {"alice-token", NULL}; - Result result; - TplEntity *entity; - TpContact *alice, *bob; - TpClientFactory *factory; - - tp_tests_create_and_connect_conn (TP_TESTS_TYPE_CONTACTS_CONNECTION, - "me@test.com", &base_connection, &client_connection); - - connection = TP_TESTS_CONTACTS_CONNECTION (base_connection); - - repo = tp_base_connection_get_handles (base_connection, - TP_HANDLE_TYPE_CONTACT); - - handles[0] = tp_handle_ensure (repo, "alice", NULL, NULL); - g_assert (handles[0] != 0); - - handles[1] = tp_handle_ensure (repo, "bob", NULL, NULL); - g_assert (handles[1] != 0); - - tp_tests_contacts_connection_change_aliases (connection, 2, handles, - alias); - tp_tests_contacts_connection_change_avatar_tokens (connection, 2, handles, - avatar_tokens); - - factory = tp_proxy_get_factory (client_connection); - tp_client_factory_add_contact_features_varargs (factory, - TP_CONTACT_FEATURE_ALIAS, - TP_CONTACT_FEATURE_AVATAR_TOKEN, - 0); - - result.loop = g_main_loop_new (NULL, FALSE); - - tp_client_factory_ensure_contact_by_id_async (factory, - client_connection, "alice", ensure_contact_cb, &result); - g_main_loop_run (result.loop); - alice = result.contact; - - tp_client_factory_ensure_contact_by_id_async (factory, - client_connection, "bob", ensure_contact_cb, &result); - g_main_loop_run (result.loop); - bob = result.contact; - - entity = tpl_entity_new_from_tp_contact (alice, TPL_ENTITY_SELF); - - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "alice"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_SELF); - g_assert_cmpstr (tpl_entity_get_alias (entity), ==, alias[0]); - g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, avatar_tokens[0]); - g_object_unref (entity); - - entity = tpl_entity_new_from_tp_contact (bob, TPL_ENTITY_CONTACT); - - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "bob"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_CONTACT); - g_assert_cmpstr (tpl_entity_get_alias (entity), ==, alias[1]); - g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, ""); - g_object_unref (entity); - - g_object_unref (alice); - g_object_unref (bob); - g_main_loop_unref (result.loop); - - tp_base_connection_change_status (base_connection, - TP_CONNECTION_STATUS_DISCONNECTED, - TP_CONNECTION_STATUS_REASON_REQUESTED); - tp_base_connection_finish_shutdown (base_connection); - - g_object_unref (base_connection); - g_object_unref (client_connection); -} - -int main (int argc, - char **argv) -{ - g_test_init (&argc, &argv, NULL); - - g_type_init (); - - g_test_add_func ("/entity/instantiation", - test_entity_instantiation); - - g_test_add_func ("/entity/instantiation-from-room-id", - test_entity_instantiation_from_room_id); - - g_test_add_func ("/entity/instantiation-from-tp-contact", - test_entity_instantiation_from_tp_contact); - - return g_test_run (); -} diff --git a/tests/dbus/test-log-manager.c b/tests/dbus/test-log-manager.c deleted file mode 100644 index 6bd7b66..0000000 --- a/tests/dbus/test-log-manager.c +++ /dev/null @@ -1,807 +0,0 @@ -#include "config.h" - -#include "telepathy-logger/log-manager.c" - -#include "lib/util.h" -#include "lib/simple-account.h" -#include "lib/simple-account-manager.h" -#include "lib/logger-test-helper.h" - -#include "telepathy-logger/debug-internal.h" -#include "telepathy-logger/log-manager-internal.h" -#include "telepathy-logger/log-store-internal.h" -#include <telepathy-logger/text-event.h> -#include <telepathy-logger/client-factory-internal.h> - -#include <telepathy-glib/telepathy-glib.h> - -/* it was defined in telepathy-logger/log-manager.c */ -#undef DEBUG_FLAG -#define DEBUG_FLAG TPL_DEBUG_TESTSUITE - -#define ACCOUNT_PATH_JABBER TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk" -#define MY_ID "user@collabora.co.uk" -#define ID "user2@collabora.co.uk" - -typedef struct -{ - GMainLoop *main_loop; - - TpDBusDaemon *dbus; - TpAccount *account; - TpTestsSimpleAccount *account_service; - TpClientFactory *factory; - - GList *ret; - - gchar *tmp_basedir; - - TplLogManager *manager; -} TestCaseFixture; - - - -#ifdef ENABLE_DEBUG -static TpDebugSender *debug_sender = NULL; -static gboolean stamp_logs = FALSE; - - -static void -log_to_debug_sender (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *string) -{ - GTimeVal now; - - g_return_if_fail (TP_IS_DEBUG_SENDER (debug_sender)); - - g_get_current_time (&now); - - tp_debug_sender_add_message (debug_sender, &now, log_domain, log_level, - string); -} - - -static void -log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - if (stamp_logs) - { - GTimeVal now; - gchar now_str[32]; - gchar *tmp; - struct tm tm; - - g_get_current_time (&now); - localtime_r (&(now.tv_sec), &tm); - strftime (now_str, 32, "%Y-%m-%d %H:%M:%S", &tm); - tmp = g_strdup_printf ("%s.%06ld: %s", - now_str, now.tv_usec, message); - - g_log_default_handler (log_domain, log_level, tmp, NULL); - - g_free (tmp); - } - else - { - g_log_default_handler (log_domain, log_level, message, NULL); - } - - log_to_debug_sender (log_domain, log_level, message); -} -#endif /* ENABLE_DEBUG */ - - -static void -teardown_service (TestCaseFixture* fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - g_assert (user_data != NULL); - - if (fixture->account != NULL) - { - /* FIXME is it useful in this suite */ - tp_tests_proxy_run_until_dbus_queue_processed (fixture->account); - - g_object_unref (fixture->account); - fixture->account = NULL; - } - - tp_dbus_daemon_unregister_object (fixture->dbus, fixture->account_service); - g_object_unref (fixture->account_service); - fixture->account_service = NULL; - - tp_dbus_daemon_release_name (fixture->dbus, TP_ACCOUNT_MANAGER_BUS_NAME, - &error); - g_assert_no_error (error); - - g_object_unref (fixture->dbus); - fixture->dbus = NULL; - - g_clear_object (&fixture->factory); -} - -static void -teardown (TestCaseFixture* fixture, - gconstpointer user_data) -{ - if (fixture->tmp_basedir != NULL) - { - gchar *command = g_strdup_printf ("rm -rf %s", fixture->tmp_basedir); - - if (system (command) == -1) - g_warning ("Failed to cleanup tempory test log dir: %s", - fixture->tmp_basedir); - - g_free (fixture->tmp_basedir); - } - - g_object_unref (fixture->manager); - fixture->manager = NULL; - - if (user_data != NULL) - teardown_service (fixture, user_data); - - g_main_loop_unref (fixture->main_loop); - fixture->main_loop = NULL; -} - - -static void -account_prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tp_proxy_prepare_finish (source, result, &error); - g_assert_no_error (error); - - g_main_loop_quit (fixture->main_loop); -} - - -static void -setup_service (TestCaseFixture* fixture, - gconstpointer user_data) -{ - GQuark account_features[] = { TP_ACCOUNT_FEATURE_CORE, 0 }; - const gchar *account_path; - GValue *boxed_params; - GHashTable *params = (GHashTable *) user_data; - GError *error = NULL; - - g_assert (params != NULL); - - fixture->dbus = tp_tests_dbus_daemon_dup_or_die (); - g_assert (fixture->dbus != NULL); - - tp_dbus_daemon_request_name (fixture->dbus, - TP_ACCOUNT_MANAGER_BUS_NAME, FALSE, &error); - g_assert_no_error (error); - - /* Create service-side Account object with the passed parameters */ - fixture->account_service = g_object_new (TP_TESTS_TYPE_SIMPLE_ACCOUNT, - NULL); - g_assert (fixture->account_service != NULL); - - /* account-path will be set-up as parameter as well, this is not an issue */ - account_path = g_value_get_string ( - (const GValue *) g_hash_table_lookup (params, "account-path")); - g_assert (account_path != NULL); - - boxed_params = tp_g_value_slice_new_boxed (TP_HASH_TYPE_STRING_VARIANT_MAP, - params); - g_object_set_property (G_OBJECT (fixture->account_service), - "parameters", boxed_params); - - tp_dbus_daemon_register_object (fixture->dbus, account_path, - fixture->account_service); - - fixture->factory = _tpl_client_factory_dup (fixture->dbus); - - fixture->account = tp_client_factory_ensure_account (fixture->factory, - account_path, NULL, NULL); - g_assert (fixture->account != NULL); - - tp_proxy_prepare_async (fixture->account, account_features, - account_prepare_cb, fixture); - g_main_loop_run (fixture->main_loop); - - g_assert (tp_proxy_is_prepared (fixture->account, TP_ACCOUNT_FEATURE_CORE)); - - tp_g_value_slice_free (boxed_params); -} - - -static void -setup (TestCaseFixture* fixture, - gconstpointer user_data) -{ - DEBUG ("setting up"); - - fixture->main_loop = g_main_loop_new (NULL, FALSE); - g_assert (fixture->main_loop != NULL); - - fixture->manager = tpl_log_manager_dup_singleton (); - - if (user_data != NULL) - setup_service (fixture, user_data); - - DEBUG ("set up finished"); -} - -static void -setup_for_writing (TestCaseFixture *fixture, - gconstpointer user_data) -{ - gchar *readonly_dir; - gchar *writable_dir; - - readonly_dir = g_build_path (G_DIR_SEPARATOR_S, - g_getenv ("TPL_TEST_LOG_DIR"), "TpLogger", "logs", NULL); - - writable_dir = g_build_path (G_DIR_SEPARATOR_S, - g_get_tmp_dir (), "logger-test-logs", NULL); - - tp_tests_copy_dir (readonly_dir, writable_dir); - fixture->tmp_basedir = writable_dir; - g_setenv ("TPL_TEST_LOG_DIR", writable_dir, TRUE); - g_free (readonly_dir); - - setup (fixture, user_data); -} - -static void -setup_debug (void) -{ - tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); - -#ifdef ENABLE_DEBUG - _tpl_debug_set_flags_from_env (); - - stamp_logs = (g_getenv ("TPL_TIMING") != NULL); - debug_sender = tp_debug_sender_dup (); - - g_log_set_default_handler (log_handler, NULL); -#endif /* ENABLE_DEBUG */ -} - - -static void -test_exists (TestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *entity; - TplEntity *no_entity; - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - no_entity = tpl_entity_new ("unknown", TPL_ENTITY_CONTACT, NULL, NULL); - - g_assert (tpl_log_manager_exists (fixture->manager, fixture->account, - entity, TPL_EVENT_MASK_ANY)); - - g_assert (!tpl_log_manager_exists (fixture->manager, fixture->account, - no_entity, TPL_EVENT_MASK_ANY)); - - g_object_unref (entity); - g_object_unref (no_entity); -} - - -static void -get_dates_async_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (object), - result, &fixture->ret, &error); - - g_assert_no_error (error); - g_main_loop_quit (fixture->main_loop); -} - -static void -test_get_dates (TestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *loc; - TplEntity *entity; - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - - tpl_log_manager_get_dates_async (fixture->manager, - fixture->account, entity, TPL_EVENT_MASK_ANY, - get_dates_async_cb, fixture); - g_main_loop_run (fixture->main_loop); - - g_object_unref (entity); - - /* it includes 1 date from libpurple logs, 5 from TpLogger. Empathy - * log-store date are the same of the TpLogger store, and wont' be present, - * being duplicates */ - g_assert_cmpint (g_list_length (fixture->ret), ==, 6); - - /* we do not want duplicates, dates are suppose to be ordered */ - fixture->ret = g_list_sort (fixture->ret, (GCompareFunc) g_date_compare); - for (loc = fixture->ret; loc != NULL; loc = g_list_next (loc)) - if (loc->next) - g_assert (g_date_compare (loc->data, loc->next->data) != 0); - - g_list_foreach (fixture->ret, (GFunc) g_date_free, NULL); - g_list_free (fixture->ret); -} - - -static void -get_events_for_date_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_manager_get_events_for_date_finish (TPL_LOG_MANAGER (object), - result, &fixture->ret, &error); - - g_assert_no_error (error); - g_main_loop_quit (fixture->main_loop); -} - - -static void -test_get_events_for_date (TestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *entity; - GDate *date; - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - date = g_date_new_dmy (13, 1, 2010); - - tpl_log_manager_get_events_for_date_async (fixture->manager, - fixture->account, - entity, - TPL_EVENT_MASK_TEXT, - date, - get_events_for_date_cb, - fixture); - g_main_loop_run (fixture->main_loop); - - g_object_unref (entity); - g_date_free (date); - - /* We got 6 events in old Empathy and 6 in new TpLogger storage */ - g_assert_cmpint (g_list_length (fixture->ret), ==, 12); - - g_list_foreach (fixture->ret, (GFunc) g_object_unref, NULL); - g_list_free (fixture->ret); -} - -static void -test_get_events_for_date_account_unprepared (TestCaseFixture *fixture, - gconstpointer user_data) -{ - GHashTable *params = (GHashTable *) user_data; - TplEntity *entity; - GDate *date; - TpAccount *account; - const gchar *account_path; - - g_clear_object (&fixture->account); - - account_path = g_value_get_string ( - (const GValue *) g_hash_table_lookup (params, "account-path")); - - account = tp_client_factory_ensure_account (fixture->factory, - account_path, NULL, NULL); - g_assert (!tp_proxy_is_prepared (account, TP_ACCOUNT_FEATURE_CORE)); - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - date = g_date_new_dmy (13, 1, 2010); - - tpl_log_manager_get_events_for_date_async (fixture->manager, - account, - entity, - TPL_EVENT_MASK_TEXT, - date, - get_events_for_date_cb, - fixture); - g_main_loop_run (fixture->main_loop); - - g_object_unref (entity); - g_date_free (date); - - /* We got 6 events in old Empathy and 6 in new TpLogger storage */ - g_assert_cmpint (g_list_length (fixture->ret), ==, 12); - - g_list_foreach (fixture->ret, (GFunc) g_object_unref, NULL); - g_list_free (fixture->ret); - g_object_unref (account); -} - -static void -get_filtered_events_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_manager_get_filtered_events_finish (TPL_LOG_MANAGER (object), - result, &fixture->ret, &error); - - g_assert_no_error (error); - g_main_loop_quit (fixture->main_loop); -} - - -static gboolean -events_filter (TplEvent *event, - gpointer user_data) -{ - gboolean keep; - GDateTime *timestamp; - GDate *date = user_data; - - timestamp = g_date_time_new_from_unix_utc (tpl_event_get_timestamp (event)); - - keep = g_date_time_get_year (timestamp) == g_date_get_year (date) - && g_date_time_get_month (timestamp) == (gint) g_date_get_month (date) - && g_date_time_get_day_of_month (timestamp) == g_date_get_day (date); - - g_date_time_unref (timestamp); - - return keep; -} - - -static void -test_get_filtered_events (TestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *entity; - GDate *date; - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - date = g_date_new_dmy (13, 1, 2010); - - tpl_log_manager_get_filtered_events_async (fixture->manager, - fixture->account, - entity, - TPL_EVENT_MASK_TEXT, - 11, - events_filter, - date, - get_filtered_events_cb, - fixture); - g_main_loop_run (fixture->main_loop); - - g_object_unref (entity); - g_date_free (date); - - /* We got 6 events in old Empathy and 6 in new TpLogger storage, - * but we limited to 11 */ - g_assert_cmpint (g_list_length (fixture->ret), ==, 11); - - g_list_foreach (fixture->ret, (GFunc) g_object_unref, NULL); - g_list_free (fixture->ret); -} - - -static void -get_entities_37288_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_manager_get_entities_finish (TPL_LOG_MANAGER (object), result, - NULL, &error); - - g_assert_no_error (error); - g_main_loop_quit (fixture->main_loop); -} - - -static void -get_entities_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_manager_get_entities_finish (TPL_LOG_MANAGER (object), result, - &fixture->ret, &error); - - g_assert_no_error (error); - g_main_loop_quit (fixture->main_loop); -} - - -static void -test_get_entities (TestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *loc; - - tpl_log_manager_get_entities_async (fixture->manager, fixture->account, - get_entities_cb, fixture); - g_main_loop_run (fixture->main_loop); - - g_assert_cmpint (g_list_length (fixture->ret), ==, 5); - - /* we do not want duplicates */ - fixture->ret = g_list_sort (fixture->ret, (GCompareFunc) _tpl_entity_compare); - for (loc = fixture->ret; loc != NULL; loc = g_list_next (loc)) - if (loc->next) - g_assert (_tpl_entity_compare (loc->data, loc->next->data) != 0); - - g_list_foreach (fixture->ret, (GFunc) g_object_unref, NULL); - g_list_free (fixture->ret); - - /* Check that the GSimpleAsyncResult res_gpointer's GDestroyNotify func - * is the appropriate one. - * Reproduces: https://bugs.freedesktop.org/show_bug.cgi?id=37288 */ - tpl_log_manager_get_entities_async (fixture->manager, fixture->account, - get_entities_37288_cb, fixture); - g_main_loop_run (fixture->main_loop); -} - - -static void -search_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_manager_search_finish (TPL_LOG_MANAGER (object), - result, &fixture->ret, &error); - - g_assert_no_error (error); - g_main_loop_quit (fixture->main_loop); -} - - -static void -test_search (TestCaseFixture *fixture, - gconstpointer user_data) -{ - tpl_log_manager_search_async (fixture->manager, - "user2@collabora.co.uk", - TPL_EVENT_MASK_TEXT, - search_cb, - fixture); - g_main_loop_run (fixture->main_loop); - - /* We got 4 events in old Empathy, 4 in new TpLogger and - * 2 in Pidgin storage */ - g_assert_cmpint (g_list_length (fixture->ret), ==, 10); - - tpl_log_manager_search_free (fixture->ret); - fixture->ret = NULL; -} - -static gboolean -check_ignored_messages (TestCaseFixture *fixture, - TplTextEvent *event, - gboolean should_exist) -{ - TplEntity *entity; - GList *iter; - GDate *date; - - g_object_get (event, "sender", &entity, NULL); - date = g_date_new_dmy (1, 1, 1970); - tpl_log_manager_get_events_for_date_async ( - fixture->manager, - fixture->account, - entity, - TPL_EVENT_MASK_ANY, - date, - get_events_for_date_cb, - fixture); - g_main_loop_run (fixture->main_loop); - - for (iter = fixture->ret; iter; iter = g_list_next (iter)) { - TplEvent *found_event = iter->data; - gchar *result_token, *ref_token; - gboolean exists; - - g_object_get (G_OBJECT (found_event), "message-token", &result_token, NULL); - g_object_get (G_OBJECT (event), "message-token", &ref_token, NULL); - exists = (g_strcmp0 (result_token, ref_token) == 0); - - if (should_exist != exists) { - g_list_free_full (fixture->ret, g_object_unref); - return FALSE; - } - } - - g_list_free_full (fixture->ret, g_object_unref); - - return TRUE; -} - -static void -test_ignorelist (TestCaseFixture *fixture, - gconstpointer user_data) -{ - TplTextEvent *event1, *event2; - TplEntity *receiver, *sender; - TplConf *conf; - gboolean passed; - - receiver = tpl_entity_new ("ignoreduser1@collabora.co.uk", TPL_ENTITY_CONTACT, "Me", "no-avatar"); - sender = tpl_entity_new ("ignoreduser2@collabora.co.uk", TPL_ENTITY_CONTACT, "Someone Else", "no-avatar"); - - event1 = g_object_new (TPL_TYPE_TEXT_EVENT, - "account", fixture->account, - "channel-path", "im.telepathy1.channel.path", - "receiver", receiver, - "sender", sender, - "timestamp", (gint64) 1, - "message-token", "1234", - "supersedes-token", "5678", - "edit-timestamp", 0, - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "Test 1", - NULL); - - event2 = g_object_new (TPL_TYPE_TEXT_EVENT, - "account", fixture->account, - "channel-path", "im.telepathy1.channel.path", - "receiver", sender, - "sender", receiver, - "timestamp", (gint64) 2, - "message-token", "5678", - "supersedes-token", "9012", - "edit-timestamp", 0, - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "Test 2", - NULL); - - conf = _tpl_conf_dup (); - - /* Ignore messages from both */ - tpl_log_manager_disable_for_entity (fixture->manager, fixture->account, receiver); - tpl_log_manager_disable_for_entity (fixture->manager, fixture->account, sender); - g_assert (tpl_log_manager_is_disabled_for_entity (fixture->manager, fixture->account, receiver)); - g_assert (tpl_log_manager_is_disabled_for_entity (fixture->manager, fixture->account, sender)); - - _tpl_log_manager_add_event (fixture->manager, TPL_EVENT (event1), NULL); - _tpl_log_manager_add_event (fixture->manager, TPL_EVENT (event2), NULL); - - passed = check_ignored_messages (fixture, event1, FALSE); - if (!passed) { - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, sender); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, receiver); - g_assert (passed); - } - - passed = check_ignored_messages (fixture, event2, FALSE); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, sender); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, receiver); - if (!passed) { - g_assert (passed); - } - - /* Ignore message only from ignoreduser1 */ - tpl_log_manager_enable_for_entity (fixture->manager, fixture->account, sender); - g_assert (!tpl_log_manager_is_disabled_for_entity (fixture->manager, fixture->account, sender)); - g_assert (tpl_log_manager_is_disabled_for_entity (fixture->manager, fixture->account, receiver)); - _tpl_log_manager_add_event (fixture->manager, TPL_EVENT (event1), NULL); - _tpl_log_manager_add_event (fixture->manager, TPL_EVENT (event2), NULL); - - passed = check_ignored_messages (fixture, event1, FALSE); - if (!passed) { - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, sender); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, receiver); - g_assert (passed); - } - - passed = check_ignored_messages (fixture, event2, TRUE); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, sender); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, receiver); - if (!passed) { - g_assert (passed); - } - - /* Don't ignore any message */ - tpl_log_manager_enable_for_entity (fixture->manager, fixture->account, receiver); - g_assert (!tpl_log_manager_is_disabled_for_entity (fixture->manager, fixture->account, sender)); - g_assert (!tpl_log_manager_is_disabled_for_entity (fixture->manager, fixture->account, receiver)); - _tpl_log_manager_add_event (fixture->manager, TPL_EVENT (event1), NULL); - - passed = check_ignored_messages (fixture, event1, TRUE); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, sender); - _tpl_log_manager_clear_entity (fixture->manager, fixture->account, receiver); - if (!passed) { - g_assert (passed); - } - - g_object_unref (conf); - g_object_unref (event1); - g_object_unref (event2); - g_object_unref (sender); - g_object_unref (receiver); -} - -int -main (int argc, char **argv) -{ - GHashTable *params = NULL; - GList *l = NULL; - int retval; - - g_type_init (); - - setup_debug (); - - /* no account tests */ - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - - /* account related tests */ - params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - g_assert (params != NULL); - - l = g_list_prepend (l, params); - - g_hash_table_insert (params, "account", - tp_g_value_slice_new_static_string (MY_ID)); - g_hash_table_insert (params, "account-path", - tp_g_value_slice_new_static_string (ACCOUNT_PATH_JABBER)); - - g_test_add ("/log-manager/exists", - TestCaseFixture, params, - setup, test_exists, teardown); - - g_test_add ("/log-manager/get-dates", - TestCaseFixture, params, - setup, test_get_dates, teardown); - - g_test_add ("/log-manager/get-events-for-date", - TestCaseFixture, params, - setup, test_get_events_for_date, teardown); - - g_test_add ("/log-manager/get-events-for-date-account-unprepared", - TestCaseFixture, params, - setup, test_get_events_for_date_account_unprepared, teardown); - - g_test_add ("/log-manager/get-filtered-events", - TestCaseFixture, params, - setup, test_get_filtered_events, teardown); - - g_test_add ("/log-manager/get-entities", - TestCaseFixture, params, - setup, test_get_entities, teardown); - - g_test_add ("/log-manager/search", - TestCaseFixture, params, - setup, test_search, teardown); - - g_test_add ("/log-manager/ignorelist", - TestCaseFixture, params, - setup_for_writing, test_ignorelist, teardown); - - retval = g_test_run (); - - g_list_foreach (l, (GFunc) g_hash_table_unref, NULL); - - return retval; -} diff --git a/tests/dbus/test-tpl-log-iter-pidgin.c b/tests/dbus/test-tpl-log-iter-pidgin.c deleted file mode 100644 index 11e1b5e..0000000 --- a/tests/dbus/test-tpl-log-iter-pidgin.c +++ /dev/null @@ -1,849 +0,0 @@ -#include "config.h" - -#include "lib/simple-account.h" -#include "lib/util.h" - -#include "telepathy-logger/debug-internal.h" -#include "telepathy-logger/log-iter-internal.h" -#include "telepathy-logger/log-iter-pidgin-internal.h" -#include "telepathy-logger/log-store-pidgin-internal.h" -#include "telepathy-logger/text-event.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> -#include <glib.h> - -#define DEBUG_FLAG TPL_DEBUG_TESTSUITE - - -typedef struct -{ - GMainLoop *main_loop; - TplLogStore *store; - TpAccount *account; - TpDBusDaemon *bus; - TpClientFactory *factory; - TpTestsSimpleAccount *account_service; -} PidginTestCaseFixture; - - -static void -account_prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - PidginTestCaseFixture *fixture = user_data; - GError *error = NULL; - - tp_proxy_prepare_finish (source, result, &error); - g_assert_no_error (error); - - g_main_loop_quit (fixture->main_loop); -} - - -static void -setup (PidginTestCaseFixture* fixture, - gconstpointer user_data) -{ - GArray *features; - GError *error = NULL; - GHashTable *params = (GHashTable *) user_data; - GValue *boxed_params; - const gchar *account_path; - - fixture->main_loop = g_main_loop_new (NULL, FALSE); - g_assert (fixture->main_loop != NULL); - - fixture->store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, - "testmode", TRUE, - NULL); - - fixture->bus = tp_tests_dbus_daemon_dup_or_die (); - g_assert (fixture->bus != NULL); - - tp_dbus_daemon_request_name (fixture->bus, - TP_ACCOUNT_MANAGER_BUS_NAME, - FALSE, - &error); - g_assert_no_error (error); - - /* Create service-side Account object with the passed parameters */ - fixture->account_service = g_object_new (TP_TESTS_TYPE_SIMPLE_ACCOUNT, - NULL); - g_assert (fixture->account_service != NULL); - - /* account-path will be set-up as parameter as well, this is not an issue */ - account_path = tp_asv_get_string (params, "account-path"); - g_assert (account_path != NULL); - - boxed_params = tp_g_value_slice_new_boxed (TP_HASH_TYPE_STRING_VARIANT_MAP, - params); - g_object_set_property (G_OBJECT (fixture->account_service), - "parameters", - boxed_params); - tp_g_value_slice_free (boxed_params); - - tp_dbus_daemon_register_object (fixture->bus, - account_path, - fixture->account_service); - - fixture->factory = tp_client_factory_new (fixture->bus); - g_assert (fixture->factory != NULL); - - fixture->account = tp_client_factory_ensure_account (fixture->factory, - tp_asv_get_string (params, "account-path"), - params, - &error); - g_assert_no_error (error); - g_assert (fixture->account != NULL); - - features = tp_client_factory_dup_account_features (fixture->factory, - fixture->account); - - tp_proxy_prepare_async (fixture->account, - (GQuark *) features->data, - account_prepare_cb, - fixture); - g_free (features->data); - g_array_free (features, FALSE); - - g_main_loop_run (fixture->main_loop); - - tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); - -#ifdef ENABLE_DEBUG - _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ -} - - -static void -teardown (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - tp_dbus_daemon_release_name (fixture->bus, - TP_ACCOUNT_MANAGER_BUS_NAME, - &error); - g_assert_no_error (error); - - g_clear_object (&fixture->account); - g_clear_object (&fixture->factory); - - tp_dbus_daemon_unregister_object (fixture->bus, fixture->account_service); - g_clear_object (&fixture->account_service); - - g_clear_object (&fixture->bus); - g_clear_object (&fixture->store); - g_main_loop_unref (fixture->main_loop); -} - - -static void -test_get_events (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *room; - TplLogIter *iter; - GList *events; - GError *error = NULL; - const gchar *message; - gint64 timestamp; - - room = tpl_entity_new_from_room_id ("#telepathy"); - - iter = tpl_log_iter_pidgin_new (fixture->store, fixture->account, room, - TPL_EVENT_MASK_ANY); - - events = tpl_log_iter_get_events (iter, 5, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291133254); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "tbh it's not necessarily too niche to have in telepathy-spec"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 3); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291133097); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "I think that's better than modifying the client libraries"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291133035); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "oh right I thought by "alongside" you meant in o.fd.T.AM"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 7, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 7); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291132904); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "you're just moving the incompatibility into the client libraries"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291132892); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "if the libraries hide those accounts by default, that's no more " - "compatible than changing the D-Bus API"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291132838); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "alternative possibly less-beating-worthy proposals include just " - "adding the flag to the account and then modifying tp-{glib,qt4,...} " - "to hide 'em by default"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131885); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "wjt: hrm, can you disco remote servers for their jud and does gabble " - "do that if needed or does it rely on the given server being the jud?"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 4, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 4); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131667); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "one of whose possible values is the dreaded NetworkError"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 5, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131614); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "nod"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 3); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131587); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "ejabberd isn't even telling me why it's disconnecting some " - "test accounts"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "Heh"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 7, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 7); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131502); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "if the server provides <text/>, use that; otherwise, use a " - "locally-supplied debug string"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131493); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "MattJ: what language is the <text> in btw?"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131480); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "hey"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131383); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "Good :)"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 5, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131350); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "that's mostly fixed though"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 3); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131335); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "\\o\\ /o/"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131288); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "Good that a proper register interface is getting higher on the todo " - "list"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 7, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 7); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130982); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "no biscuit."); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130967); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "no gitorious merge request."); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130885); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "pessi: Hi, I fixed some bugs in ring: " - "http://git.collabora.co.uk/?p=user/jonny/telepathy-ring.git;a=" - "shortlog;h=refs/heads/trivia"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130110); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "i guess the collabora xmpp server does privacy list-based " - "invisibility, so it's only doing what i asked"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 4, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 4); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130015); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "MattJ: so about that xep-0186 support? ;-)"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 5, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291129872); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "Oh, i noticed that our iq request queue somethings fill up and then " - "doesn't seem to get unstuck"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 3); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291129805); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "huh"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291128926); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "kkszysiu, heya; i seem to remember you were hacking on a " - "im-via-web-using-telepathy stuff? how's that going? i'd be " - "interested in doing something along the same lines"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 7, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 7); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291126346); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "invisible's a good idea. we do implement xmpp ping"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291126340); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "oh yeah, dwd implemented google:queue in M-Link"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291126290); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "not sure if we implement this one"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 8, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 8); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291123078); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "those who like contact lists: " - "https://bugs.freedesktop.org/show_bug.cgi?id=31997"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - g_object_unref (iter); - g_object_unref (room); -} - - -static void -test_rewind (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *room; - TplLogIter *iter; - GList *events; - GError *error = NULL; - const gchar *message; - gint64 timestamp; - - room = tpl_entity_new_from_room_id ("#telepathy"); - - iter = tpl_log_iter_pidgin_new (fixture->store, fixture->account, room, - TPL_EVENT_MASK_ANY); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 0, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 5, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291133254); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "tbh it's not necessarily too niche to have in telepathy-spec"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 5, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291133254); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "tbh it's not necessarily too niche to have in telepathy-spec"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 20, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 20); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291132137); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "wjt: we should probably cope with both cases.. i wonder if jud server " - "correctly indicate in a disco response that they're the jud " - "server"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 7, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 17, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 17); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131655); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "the primary thing to present is a D-Bus error code which UIs are " - "expected to localize"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 7, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 13, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 13); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131595); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "There are vague errors like "bad-request" or " - ""not-authorized" where Prosody usually gives more specific " - "information about why the error occured"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 17, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 33, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 33); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131445); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "dear ejabberd, why are you not showing your xep 55 in your disco " - "response"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 5, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131401); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "the UI doesn't show it though"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 25, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 10, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131537); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "well, s/you/this channel/"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 25, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 25); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291131335); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "\\o\\ /o/"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 3, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 15, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 15); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130885); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "pessi: Hi, I fixed some bugs in ring: " - "http://git.collabora.co.uk/?p=user/jonny/telepathy-ring.git;a=" - "shortlog;h=refs/heads/trivia"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 1, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291130210); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "wjt, how can you test if you are actually invisible? The account " - "presence is always sync with your real status?"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 7, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 20, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 20); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291129805); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "huh"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 23, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 20, &error); - events = events; - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 20); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291129872); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "Oh, i noticed that our iq request queue somethings fill up and then " - "doesn't seem to get unstuck"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 3, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 20, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 20); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291126206); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "invisible is a good one"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 3, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 9, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 9); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1291123078); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, - ==, - "those who like contact lists: " - "https://bugs.freedesktop.org/show_bug.cgi?id=31997"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - g_object_unref (iter); - g_object_unref (room); -} - - -gint -main (gint argc, gchar **argv) -{ - GHashTable *params; - gint retval; - - g_type_init (); - - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - - params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - g_assert (params != NULL); - - g_hash_table_insert (params, "account", - tp_g_value_slice_new_static_string ("user")); - g_hash_table_insert (params, "server", - tp_g_value_slice_new_static_string ("irc.freenode.net")); - g_hash_table_insert (params, "account-path", - tp_g_value_slice_new_static_string ( - TP_ACCOUNT_OBJECT_PATH_BASE "foo/irc/baz")); - - g_test_add ("/log-iter-xml/get-events", - PidginTestCaseFixture, params, - setup, test_get_events, teardown); - - g_test_add ("/log-iter-xml/rewind", - PidginTestCaseFixture, params, - setup, test_rewind, teardown); - - retval = g_test_run (); - - g_hash_table_unref (params); - - return retval; -} diff --git a/tests/dbus/test-tpl-log-iter-xml.c b/tests/dbus/test-tpl-log-iter-xml.c deleted file mode 100644 index 9053f7d..0000000 --- a/tests/dbus/test-tpl-log-iter-xml.c +++ /dev/null @@ -1,446 +0,0 @@ -#include "config.h" - -#include "lib/logger-test-helper.h" -#include "lib/util.h" - -#include "telepathy-logger/call-event.h" -#include "telepathy-logger/debug-internal.h" -#include "telepathy-logger/log-iter-internal.h" -#include "telepathy-logger/log-iter-xml-internal.h" -#include "telepathy-logger/log-store-xml-internal.h" -#include "telepathy-logger/text-event.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> -#include <glib.h> - -#define DEBUG_FLAG TPL_DEBUG_TESTSUITE - - -typedef struct -{ - GMainLoop *main_loop; - TplLogStore *store; - TpAccount *account; - TpDBusDaemon *bus; - TpClientFactory *factory; - TpTestsSimpleAccount *account_service; -} XmlTestCaseFixture; - - -static void -setup (XmlTestCaseFixture* fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - fixture->main_loop = g_main_loop_new (NULL, FALSE); - - fixture->store = g_object_new (TPL_TYPE_LOG_STORE_XML, - "testmode", TRUE, - NULL); - - fixture->bus = tp_tests_dbus_daemon_dup_or_die (); - g_assert (fixture->bus != NULL); - - tp_dbus_daemon_request_name (fixture->bus, - TP_ACCOUNT_MANAGER_BUS_NAME, - FALSE, - &error); - g_assert_no_error (error); - - fixture->factory = tp_client_factory_new (fixture->bus); - g_assert (fixture->factory != NULL); - - tpl_test_create_and_prepare_account (fixture->bus, fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk", - &fixture->account, &fixture->account_service); - - tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); - -#ifdef ENABLE_DEBUG - _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ -} - - -static void -teardown (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - tp_dbus_daemon_release_name (fixture->bus, TP_ACCOUNT_MANAGER_BUS_NAME, - &error); - g_assert_no_error (error); - - tpl_test_release_account (fixture->bus, fixture->account, - fixture->account_service); - - g_clear_object (&fixture->factory); - g_clear_object (&fixture->bus); - g_clear_object (&fixture->store); -} - - -static void -test_get_events (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *user2, *user4; - TplLogIter *iter; - GList *events; - GError *error = NULL; - GTimeSpan duration; - const gchar *message; - gint64 timestamp; - - user2 = tpl_entity_new ("user2@collabora.co.uk", TPL_ENTITY_CONTACT, - "User2", ""); - - user4 = tpl_entity_new ("user4@collabora.co.uk", TPL_ENTITY_CONTACT, - "User4", ""); - - /* Text events spanning multiple days */ - iter = tpl_log_iter_xml_new (fixture->store, fixture->account, user2, - TPL_EVENT_MASK_ANY); - - events = tpl_log_iter_get_events (iter, 5, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "4"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 3); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425572); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "3"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "5"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 7, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 7); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266414451); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "1"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266335850); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "bar"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266335556); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "1"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263405178); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "5"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 4, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 4); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404877); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "1"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - g_object_unref (iter); - - /* A mix of call and text events */ - iter = tpl_log_iter_xml_new (fixture->store, fixture->account, user4, - TPL_EVENT_MASK_ANY); - - events = tpl_log_iter_get_events (iter, 4, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 4); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404881); - duration = tpl_call_event_get_duration (TPL_CALL_EVENT (events->data)); - g_assert_cmpint (duration, ==, 1); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404881); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "8"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 1); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404877); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "7"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - g_object_unref (iter); - - g_object_unref (user2); - g_object_unref (user4); -} - - -static void -test_rewind (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *user2, *user4; - TplLogIter *iter; - GList *events; - GError *error = NULL; - GTimeSpan duration; - const gchar *message; - gint64 timestamp; - - user2 = tpl_entity_new ("user2@collabora.co.uk", TPL_ENTITY_CONTACT, - "User2", ""); - - user4 = tpl_entity_new ("user4@collabora.co.uk", TPL_ENTITY_CONTACT, - "User4", ""); - - /* Text events spanning multiple days */ - iter = tpl_log_iter_xml_new (fixture->store, fixture->account, user2, - TPL_EVENT_MASK_ANY); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 0, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 5, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "4"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "5"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 3, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 5, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "3"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 1, &error); - g_assert_no_error (error); - - tpl_log_iter_rewind (iter, 9, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266425566); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "3"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266329628); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "123"); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 13, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1266335803); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "a"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 10, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 10); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263405203); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "6"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 5, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 5); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404877); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "1"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 3, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - g_object_unref (iter); - - /* A mix of call and text events */ - iter = tpl_log_iter_xml_new (fixture->store, fixture->account, user4, - TPL_EVENT_MASK_ANY); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 0, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 4, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 4); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404881); - duration = tpl_call_event_get_duration (TPL_CALL_EVENT (events->data)); - g_assert_cmpint (duration, ==, 1); - g_list_free_full (events, g_object_unref); - - tpl_log_iter_rewind (iter, 8, &error); - g_assert_no_error (error); - - events = tpl_log_iter_get_events (iter, 4, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 4); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404881); - duration = tpl_call_event_get_duration (TPL_CALL_EVENT (events->data)); - g_assert_cmpint (duration, ==, 1); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 2, &error); - g_assert_no_error (error); - g_assert (events != NULL); - g_assert_cmpint (g_list_length (events), ==, 2); - timestamp = tpl_event_get_timestamp (TPL_EVENT (events->data)); - g_assert_cmpint (timestamp, ==, 1263404877); - message = tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)); - g_assert_cmpstr (message, ==, "7"); - g_list_free_full (events, g_object_unref); - - events = tpl_log_iter_get_events (iter, 1, &error); - g_assert_no_error (error); - g_assert (events == NULL); - - g_object_unref (iter); - - g_object_unref (user2); - g_object_unref (user4); -} - - -gint main (gint argc, gchar **argv) -{ - g_type_init (); - - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - - g_test_add ("/log-iter-xml/get-events", - XmlTestCaseFixture, NULL, - setup, test_get_events, teardown); - - g_test_add ("/log-iter-xml/rewind", - XmlTestCaseFixture, NULL, - setup, test_rewind, teardown); - - return g_test_run (); -} diff --git a/tests/dbus/test-tpl-log-store-pidgin.c b/tests/dbus/test-tpl-log-store-pidgin.c deleted file mode 100644 index edd3ddb..0000000 --- a/tests/dbus/test-tpl-log-store-pidgin.c +++ /dev/null @@ -1,622 +0,0 @@ -#include "config.h" - -/* FIXME: hugly kludge: we need to include all the declarations which are used - * by the GInterface and thus not in the -internal.h */ -#include "telepathy-logger/log-store-pidgin.c" - - -#include "lib/util.h" -#include "lib/simple-account.h" -#include "lib/simple-account-manager.h" - -#include <telepathy-logger/log-store-pidgin-internal.h> -#include <telepathy-logger/text-event-internal.h> -#include <telepathy-logger/client-factory-internal.h> - -#include <telepathy-glib/telepathy-glib.h> - -/* it was defined in telepathy-logger/log-store-pidgin.c */ -#undef DEBUG_FLAG -#define DEBUG_FLAG TPL_DEBUG_TESTSUITE -#include <telepathy-logger/debug-internal.h> - -#include <glib.h> - -#define ACCOUNT_PATH_JABBER TP_ACCOUNT_OBJECT_PATH_BASE "foo/jabber/baz" -#define ACCOUNT_PATH_IRC TP_ACCOUNT_OBJECT_PATH_BASE "foo/irc/baz" -#define ACCOUNT_PATH_ICQ TP_ACCOUNT_OBJECT_PATH_BASE "foo/icq/baz" - -typedef struct -{ - gchar *basedir; - - GMainLoop *main_loop; - - TpDBusDaemon *dbus; - TpAccount *account; - TpTestsSimpleAccount *account_service; - TpClientFactory *factory; - - TplLogStorePidgin *store; - TplEntity *room; - TplEntity *irc_room; - TplEntity *contact; -} PidginTestCaseFixture; - -#ifdef ENABLE_DEBUG -static TpDebugSender *debug_sender = NULL; -static gboolean stamp_logs = FALSE; - - -static void -log_to_debug_sender (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *string) -{ - GTimeVal now; - - g_return_if_fail (TP_IS_DEBUG_SENDER (debug_sender)); - - g_get_current_time (&now); - - tp_debug_sender_add_message (debug_sender, &now, log_domain, log_level, - string); -} - - -static void -log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - if (stamp_logs) - { - GTimeVal now; - gchar now_str[32]; - gchar *tmp; - struct tm tm; - - g_get_current_time (&now); - localtime_r (&(now.tv_sec), &tm); - strftime (now_str, 32, "%Y-%m-%d %H:%M:%S", &tm); - tmp = g_strdup_printf ("%s.%06ld: %s", - now_str, now.tv_usec, message); - - g_log_default_handler (log_domain, log_level, tmp, NULL); - - g_free (tmp); - } - else - { - g_log_default_handler (log_domain, log_level, message, NULL); - } - - log_to_debug_sender (log_domain, log_level, message); -} -#endif /* ENABLE_DEBUG */ - - -static void -account_prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - PidginTestCaseFixture *fixture = user_data; - GError *error = NULL; - - tp_proxy_prepare_finish (source, result, &error); - g_assert_no_error (error); - - g_main_loop_quit (fixture->main_loop); -} - - -static void -setup_service (PidginTestCaseFixture* fixture, - gconstpointer user_data) -{ - GQuark account_features[] = { TP_ACCOUNT_FEATURE_CORE, 0 }; - const gchar *account_path; - GValue *boxed_params; - GHashTable *params = (GHashTable *) user_data; - GError *error = NULL; - - g_assert (params != NULL); - - fixture->dbus = tp_tests_dbus_daemon_dup_or_die (); - g_assert (fixture->dbus != NULL); - - tp_dbus_daemon_request_name (fixture->dbus, - TP_ACCOUNT_MANAGER_BUS_NAME, FALSE, &error); - g_assert_no_error (error); - - /* Create service-side Account object with the passed parameters */ - fixture->account_service = g_object_new (TP_TESTS_TYPE_SIMPLE_ACCOUNT, - NULL); - g_assert (fixture->account_service != NULL); - - /* account-path will be set-up as parameter as well, this is not an issue */ - account_path = g_value_get_string ( - (const GValue *) g_hash_table_lookup (params, "account-path")); - g_assert (account_path != NULL); - - boxed_params = tp_g_value_slice_new_boxed (TP_HASH_TYPE_STRING_VARIANT_MAP, - params); - g_object_set_property (G_OBJECT (fixture->account_service), - "parameters", boxed_params); - - tp_dbus_daemon_register_object (fixture->dbus, account_path, - fixture->account_service); - - fixture->factory = _tpl_client_factory_dup (fixture->dbus); - - fixture->account = tp_client_factory_ensure_account (fixture->factory, - account_path, NULL, NULL); - g_assert (fixture->account != NULL); - - tp_proxy_prepare_async (fixture->account, account_features, - account_prepare_cb, fixture); - g_main_loop_run (fixture->main_loop); - - g_assert (tp_proxy_is_prepared (fixture->account, TP_ACCOUNT_FEATURE_CORE)); - - tp_g_value_slice_free (boxed_params); -} - -static void -setup (PidginTestCaseFixture* fixture, - gconstpointer user_data) -{ - DEBUG ("setting up"); - - fixture->main_loop = g_main_loop_new (NULL, FALSE); - g_assert (fixture->main_loop != NULL); - - fixture->basedir = g_build_path (G_DIR_SEPARATOR_S, - g_getenv ("TPL_TEST_LOG_DIR"), "purple", NULL); - DEBUG ("basedir is %s", fixture->basedir); - - fixture->store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, - "testmode", TRUE, - NULL); - - fixture->room = tpl_entity_new_from_room_id ( - "test@conference.collabora.co.uk"); - - fixture->irc_room = tpl_entity_new_from_room_id ("#telepathy"); - - fixture->contact = tpl_entity_new ("user2@collabora.co.uk", - TPL_ENTITY_CONTACT, NULL, NULL); - - if (user_data != NULL) - setup_service (fixture, user_data); - - DEBUG ("set up finished"); -} - -static void -teardown_service (PidginTestCaseFixture* fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - g_assert (user_data != NULL); - - if (fixture->account != NULL) - { - /* FIXME is it useful in this suite */ - tp_tests_proxy_run_until_dbus_queue_processed (fixture->account); - - g_object_unref (fixture->account); - fixture->account = NULL; - } - - tp_dbus_daemon_unregister_object (fixture->dbus, fixture->account_service); - g_object_unref (fixture->account_service); - fixture->account_service = NULL; - - tp_dbus_daemon_release_name (fixture->dbus, TP_ACCOUNT_MANAGER_BUS_NAME, - &error); - g_assert_no_error (error); - - g_object_unref (fixture->dbus); - fixture->dbus = NULL; - - g_clear_object (&fixture->factory); -} - -static void -teardown (PidginTestCaseFixture* fixture, - gconstpointer user_data) -{ - g_free (fixture->basedir); - fixture->basedir = NULL; - - g_object_unref (fixture->store); - fixture->store = NULL; - - g_object_unref (fixture->room); - g_object_unref (fixture->irc_room); - g_object_unref (fixture->contact); - - if (user_data != NULL) - teardown_service (fixture, user_data); - - g_main_loop_unref (fixture->main_loop); - fixture->main_loop = NULL; -} - -static void -test_basedir (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - TplLogStorePidgin *store; - gchar *dir; - - g_assert_cmpstr (log_store_pidgin_get_basedir (fixture->store), ==, - fixture->basedir); - - /* try to instantiate the default store, without passing basedir, it has to - * match the real libpurple basedir */ - store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, NULL); - dir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".purple", - "logs", NULL); - g_assert_cmpstr (log_store_pidgin_get_basedir (store), ==, dir); - - g_object_unref (store); - g_free (dir); -} - -static void -test_get_dates_jabber (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *dates = NULL; - GDate *date = NULL; - - /* Chatroom messages */ - dates = log_store_pidgin_get_dates (TPL_LOG_STORE (fixture->store), - fixture->account, fixture->room, TPL_EVENT_MASK_ANY); - - g_assert_cmpint (g_list_length (dates), ==, 2); - - date = g_list_nth_data (dates, 0); - g_assert_cmpint (0, ==, - g_date_compare (date, g_date_new_dmy (12, G_DATE_APRIL, 2010))); - - g_date_free (date); - - date = g_list_nth_data (dates, 1); - g_assert_cmpint (0, ==, - g_date_compare (date, g_date_new_dmy (29, G_DATE_APRIL, 2010))); - - g_date_free (date); - g_list_free (dates); - - /* 1-1 messages */ - dates = log_store_pidgin_get_dates (TPL_LOG_STORE (fixture->store), - fixture->account, fixture->contact, TPL_EVENT_MASK_ANY); - - g_assert_cmpint (g_list_length (dates), ==, 1); - - date = g_list_nth_data (dates, 0); - g_assert_cmpint (0, ==, - g_date_compare (date, g_date_new_dmy (10, G_DATE_DECEMBER, 2010))); - - g_date_free (date); - g_list_free (dates); -} - -static void -test_get_dates_irc (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *dates = NULL; - GDate *date = NULL; - - dates = log_store_pidgin_get_dates (TPL_LOG_STORE (fixture->store), - fixture->account, - fixture->irc_room, - TPL_EVENT_MASK_ANY); - - g_assert_cmpint (g_list_length (dates), ==, 1); - - date = g_list_nth_data (dates, 0); - g_assert_cmpint (0, ==, - g_date_compare (date, g_date_new_dmy (30, G_DATE_NOVEMBER, 2010))); - - g_list_foreach (dates, (GFunc) g_date_free, NULL); - g_list_free (dates); -} - -static void -test_get_time (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GDate *date; - - date = log_store_pidgin_get_time ("2010-04-29.140346+0100BST.html"); - - g_assert_cmpint (g_date_get_day (date), ==, 29); - g_assert_cmpint (g_date_get_month (date), ==, G_DATE_APRIL); - g_assert_cmpint (g_date_get_year (date), ==, 2010); - - g_date_free (date); -} - -static void -test_get_name (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - const gchar *name; - - name = _tpl_log_store_get_name (TPL_LOG_STORE (fixture->store)); - - g_assert_cmpstr (name, ==, "Pidgin"); -} - -static void -test_get_events_for_date_jabber (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *l; - TplTextEvent *msg = NULL; - GDate *date = g_date_new_dmy (12, G_DATE_APRIL, 2010); - - /* chatroom messages */ - l = log_store_pidgin_get_events_for_date (TPL_LOG_STORE (fixture->store), - fixture->account, - fixture->room, - TPL_EVENT_MASK_ANY, - date); - - g_assert_cmpint (g_list_length (l), ==, 6); - - msg = g_list_nth_data (l, 0); - g_assert (_tpl_event_target_is_room (TPL_EVENT (msg)) == TRUE); - g_assert_cmpstr (tpl_text_event_get_message (msg), ==, "1"); - - g_list_foreach (l, (GFunc) g_object_unref, NULL); - g_list_free (l); - - /* 1-1 messages */ - g_date_set_dmy (date, 10, G_DATE_DECEMBER, 2010); - l = log_store_pidgin_get_events_for_date (TPL_LOG_STORE (fixture->store), - fixture->account, - fixture->contact, - TPL_EVENT_MASK_ANY, - date); - - g_assert_cmpint (g_list_length (l), ==, 2); - - msg = g_list_nth_data (l, 0); - g_assert (_tpl_event_target_is_room (TPL_EVENT (msg)) == FALSE); - g_assert_cmpstr (tpl_text_event_get_message (msg), ==, "hi"); - - g_list_foreach (l, (GFunc) g_object_unref, NULL); - g_list_free (l); - - g_date_free (date); -} - -static int -cmp_entities (gconstpointer a, - gconstpointer b) -{ - return -1 * g_strcmp0 ( - tpl_entity_get_identifier (TPL_ENTITY (a)), - tpl_entity_get_identifier (TPL_ENTITY (b))); -} - -static void -test_get_entities_jabber (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *l = NULL; - TplEntity *entity; - - l = log_store_pidgin_get_entities (TPL_LOG_STORE (fixture->store), - fixture->account); - - g_assert_cmpint (g_list_length (l), ==, 3); - - /* sort the entities, since their ordering depends on the file order */ - l = g_list_sort (l, cmp_entities); - - entity = g_list_nth_data (l, 0); - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, - "user5@collabora.co.uk"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_CONTACT); - - entity = g_list_nth_data (l, 1); - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, - "user2@collabora.co.uk"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_CONTACT); - - entity = g_list_nth_data (l, 2); - g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, - "test@conference.collabora.co.uk"); - g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_ROOM); - - g_list_foreach (l, (GFunc) g_object_unref, NULL); - g_list_free (l); -} - -static void -test_search_new (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *l = NULL; - - /* empty search */ - l = log_store_pidgin_search_new (TPL_LOG_STORE (fixture->store), - "I do not exist in this log store data base!", - TPL_EVENT_MASK_ANY); - - g_assert_cmpint (g_list_length (l), ==, 0); - - tpl_log_manager_search_free (l); - - /* non empty search matching 1-1 */ - l = log_store_pidgin_search_new (TPL_LOG_STORE (fixture->store), - "hey you", - TPL_EVENT_MASK_ANY); - - g_assert_cmpint (g_list_length (l), ==, 1); - - tpl_log_manager_search_free (l); - - /* non empty search, checking chatrooms are also searched */ - l = log_store_pidgin_search_new (TPL_LOG_STORE (fixture->store), - "disco remote servers", - TPL_EVENT_MASK_ANY); - - g_assert_cmpint (g_list_length (l), ==, 1); - - tpl_log_manager_search_free (l); -} - -static void -test_get_events_for_empty_file (PidginTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *l = NULL; - TplEntity *entity; - GDate *date; - - entity = tpl_entity_new ("87654321", TPL_ENTITY_CONTACT, NULL, NULL); - - /* Check with empty file */ - date = g_date_new_dmy (7, 2, 2010); - - l = log_store_pidgin_get_events_for_date (TPL_LOG_STORE (fixture->store), - fixture->account, entity, TPL_EVENT_MASK_ANY, date); - - g_assert_cmpint (g_list_length (l), ==, 0); - g_date_free (date); - - /* Check with file that contains null bytes */ - date = g_date_new_dmy (6, 2, 2010); - - l = log_store_pidgin_get_events_for_date (TPL_LOG_STORE (fixture->store), - fixture->account, entity, TPL_EVENT_MASK_ANY, date); - - g_assert_cmpint (g_list_length (l), ==, 0); - g_date_free (date); - - g_object_unref (entity); -} - -static void -setup_debug (void) -{ - tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); - -#ifdef ENABLE_DEBUG - _tpl_debug_set_flags_from_env (); - - stamp_logs = (g_getenv ("TPL_TIMING") != NULL); - debug_sender = tp_debug_sender_dup (); - - g_log_set_default_handler (log_handler, NULL); -#endif /* ENABLE_DEBUG */ -} - - -int -main (int argc, char **argv) -{ - GHashTable *params = NULL; - GList *l = NULL; - int retval; - - g_type_init (); - - setup_debug (); - - /* no account tests */ - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - - g_test_add ("/log-store-pidgin/get-name", - PidginTestCaseFixture, NULL, - setup, test_get_name, teardown); - - g_test_add ("/log-store-pidgin/get-time", - PidginTestCaseFixture, NULL, - setup, test_get_time, teardown); - - /* this searches all over the account in the log stores */ - g_test_add ("/log-store-pidgin/search-new", - PidginTestCaseFixture, NULL, - setup, test_search_new, teardown); - - /* jabber account tests */ - params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - g_assert (params != NULL); - - l = g_list_prepend (l, params); - - g_hash_table_insert (params, "account", - tp_g_value_slice_new_static_string ("user@collabora.co.uk")); - g_hash_table_insert (params, "account-path", - tp_g_value_slice_new_static_string (ACCOUNT_PATH_JABBER)); - - g_test_add ("/log-store-pidgin/basedir", - PidginTestCaseFixture, params, - setup, test_basedir, teardown); - - g_test_add ("/log-store-pidgin/get-dates-jabber", - PidginTestCaseFixture, params, - setup, test_get_dates_jabber, teardown); - - g_test_add ("/log-store-pidgin/get-events-for-date-jabber", - PidginTestCaseFixture, params, - setup, test_get_events_for_date_jabber, teardown); - - g_test_add ("/log-store-pidgin/get-entities-jabber", - PidginTestCaseFixture, params, - setup, test_get_entities_jabber, teardown); - - /* IRC account tests */ - params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - g_assert (params != NULL); - - l = g_list_prepend (l, params); - - g_hash_table_insert (params, "account", - tp_g_value_slice_new_static_string ("user")); - g_hash_table_insert (params, "server", - tp_g_value_slice_new_static_string ("irc.freenode.net")); - g_hash_table_insert (params, "account-path", - tp_g_value_slice_new_static_string (ACCOUNT_PATH_IRC)); - - g_test_add ("/log-store-pidgin/get-dates-irc", - PidginTestCaseFixture, params, - setup, test_get_dates_irc, teardown); - - /* Empty file */ - params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - g_assert (params != NULL); - - l = g_list_prepend (l, params); - - g_hash_table_insert (params, "account", - tp_g_value_slice_new_static_string ("12345678")); - g_hash_table_insert (params, "account-path", - tp_g_value_slice_new_static_string (ACCOUNT_PATH_ICQ)); - - g_test_add ("/log-store-pidgin/get-event-for-empty-file", - PidginTestCaseFixture, params, - setup, test_get_events_for_empty_file, teardown); - - retval = g_test_run (); - - g_list_foreach (l, (GFunc) g_hash_table_unref, NULL); - - return retval; -} diff --git a/tests/dbus/test-tpl-log-store-sqlite.c b/tests/dbus/test-tpl-log-store-sqlite.c deleted file mode 100644 index c65718a..0000000 --- a/tests/dbus/test-tpl-log-store-sqlite.c +++ /dev/null @@ -1,40 +0,0 @@ -#include "config.h" - -#include <telepathy-logger/log-store-sqlite-internal.h> -#include <telepathy-logger/debug-internal.h> -#include <telepathy-logger/client-factory-internal.h> - -int -main (int argc, char **argv) -{ - TplLogStore *store; - TpDBusDaemon *bus; - TpAccount *account; - GError *error = NULL; - TpClientFactory* factory; - - g_type_init (); - - _tpl_debug_set_flags_from_env (); - - bus = tp_dbus_daemon_dup (&error); - g_assert_no_error (error); - - factory = _tpl_client_factory_dup (bus); - - account = tp_client_factory_ensure_account (factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/danielle_2emadeley_40collabora_2eco_2euk0", - NULL, &error); - g_assert_no_error (error); - - store = _tpl_log_store_sqlite_dup (); - - g_print ("freq = %g\n", - _tpl_log_store_sqlite_get_frequency (TPL_LOG_STORE_SQLITE (store), - account, "dannielle.meyer@gmail.com")); - - g_object_unref (store); - g_object_unref (account); - g_object_unref (bus); - g_object_unref (factory); -} diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c deleted file mode 100644 index 22c6d9c..0000000 --- a/tests/dbus/test-tpl-log-store-xml.c +++ /dev/null @@ -1,1120 +0,0 @@ -#include "config.h" - -#include "telepathy-logger/log-store-xml.c" - -#include "lib/logger-test-helper.h" -#include "lib/util.h" - -#include "telepathy-logger/debug-internal.h" -#include "telepathy-logger/log-manager-internal.h" -#include "telepathy-logger/log-store-internal.h" -#include <telepathy-logger/client-factory-internal.h> - -#include <telepathy-glib/telepathy-glib.h> -#include <glib.h> - -/* it was defined in telepathy-logger/log-store-xml.c */ -#undef DEBUG_FLAG -#define DEBUG_FLAG TPL_DEBUG_TESTSUITE - - -typedef struct -{ - GMainLoop *main_loop; - gchar *tmp_basedir; - TplLogStore *store; - TpDBusDaemon *bus; - TpClientFactory *factory; -} XmlTestCaseFixture; - - -static void -setup (XmlTestCaseFixture* fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - fixture->main_loop = g_main_loop_new (NULL, FALSE); - - fixture->store = g_object_new (TPL_TYPE_LOG_STORE_XML, - "testmode", TRUE, - NULL); - - if (fixture->tmp_basedir != NULL) - log_store_xml_set_basedir (TPL_LOG_STORE_XML (fixture->store), - fixture->tmp_basedir); - - fixture->bus = tp_tests_dbus_daemon_dup_or_die (); - g_assert (fixture->bus != NULL); - - tp_dbus_daemon_request_name (fixture->bus, - TP_ACCOUNT_MANAGER_BUS_NAME, - FALSE, - &error); - g_assert_no_error (error); - - fixture->factory = _tpl_client_factory_dup (fixture->bus); - - tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); - -#ifdef ENABLE_DEBUG - _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ -} - - -static void -setup_for_writing (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - gchar *readonly_dir; - gchar *writable_dir; - - readonly_dir = g_build_path (G_DIR_SEPARATOR_S, - g_getenv ("TPL_TEST_LOG_DIR"), "TpLogger", "logs", NULL); - - writable_dir = g_build_path (G_DIR_SEPARATOR_S, - g_get_tmp_dir (), "logger-test-logs", NULL); - - tp_tests_copy_dir (readonly_dir, writable_dir); - fixture->tmp_basedir = writable_dir; - g_free (readonly_dir); - - setup (fixture, user_data); -} - - -static void -teardown (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - tp_dbus_daemon_release_name (fixture->bus, TP_ACCOUNT_MANAGER_BUS_NAME, - &error); - g_assert_no_error (error); - - if (fixture->tmp_basedir != NULL) - { - gchar *command = g_strdup_printf ("rm -rf %s", fixture->tmp_basedir); - - if (system (command) == -1) - g_warning ("Failed to cleanup tempory test log dir: %s", - fixture->tmp_basedir); - - g_free (fixture->tmp_basedir); - } - - if (fixture->store == NULL) - g_object_unref (fixture->store); - - g_clear_object (&fixture->factory); -} - - -static void -test_clear (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *hits; - hits = _tpl_log_store_search_new (fixture->store, - "user@collabora.co.uk", - TPL_EVENT_MASK_TEXT); - - g_assert (hits != NULL); - g_assert_cmpint (g_list_length (hits), ==, 4); - - tpl_log_manager_search_free (hits); - - _tpl_log_store_clear (fixture->store); - - hits = _tpl_log_store_search_new (fixture->store, - "user@collabora.co.uk", - TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 0); -} - - -static void -test_clear_account (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *hits; - TpAccount *account; - GError *error = NULL; - const gchar *kept = "user2@collabora.co.uk"; - const gchar *cleared = "test2@collabora.co.uk"; - - hits = _tpl_log_store_search_new (fixture->store, - kept, TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 4); - - tpl_log_manager_search_free (hits); - - hits = _tpl_log_store_search_new (fixture->store, - cleared, TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 1); - - tpl_log_manager_search_free (hits); - - account = tp_client_factory_ensure_account (fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0", - NULL, &error); - - g_assert_no_error (error); - g_assert (account != NULL); - - _tpl_log_store_clear_account (fixture->store, account); - g_object_unref (account); - - hits = _tpl_log_store_search_new (fixture->store, kept, TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 4); - - tpl_log_manager_search_free (hits); - - hits = _tpl_log_store_search_new (fixture->store, cleared, - TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 0); -} - - -static void -test_clear_entity (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - gboolean is_room = GPOINTER_TO_INT (user_data); - GList *hits; - TpAccount *account; - TplEntity *entity; - GError *error = NULL; - const gchar *always_kept, *kept, *cleared; - - always_kept = "user2@collabora.co.uk"; - - if (is_room) - { - kept = "Hey, Just generating logs"; - cleared = "meego@conference.collabora.co.uk/test2@collabora.co.uk"; - } - else - { - kept = "meego@conference.collabora.co.uk/test2@collabora.co.uk"; - cleared = "Hey, Just generating logs"; - } - - hits = _tpl_log_store_search_new (fixture->store, always_kept, - TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 4); - - tpl_log_manager_search_free (hits); - - hits = _tpl_log_store_search_new (fixture->store, kept, TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 1); - - tpl_log_manager_search_free (hits); - - hits = _tpl_log_store_search_new (fixture->store, cleared, - TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 1); - - tpl_log_manager_search_free (hits); - - account = tp_client_factory_ensure_account (fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0", - NULL, &error); - - g_assert_no_error (error); - g_assert (account != NULL); - - if (is_room) - entity = tpl_entity_new_from_room_id ("meego@conference.collabora.co.uk"); - else - entity = tpl_entity_new ("derek.foreman@collabora.co.uk", - TPL_ENTITY_CONTACT, NULL, NULL); - - _tpl_log_store_clear_entity (fixture->store, account, entity); - g_object_unref (account); - g_object_unref (entity); - - hits = _tpl_log_store_search_new (fixture->store, - always_kept, TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 4); - - tpl_log_manager_search_free (hits); - - hits = _tpl_log_store_search_new (fixture->store, kept, TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 1); - - tpl_log_manager_search_free (hits); - - hits = _tpl_log_store_search_new (fixture->store, cleared, - TPL_EVENT_MASK_TEXT); - - g_assert_cmpint (g_list_length (hits), ==, 0); -} - - -static void -assert_cmp_text_event (TplEvent *event, - TplEvent *stored_event) -{ - TplEntity *sender, *stored_sender; - TplEntity *receiver, *stored_receiver; - - g_assert (TPL_IS_TEXT_EVENT (event)); - g_assert (TPL_IS_TEXT_EVENT (stored_event)); - g_assert_cmpstr (tpl_event_get_account_path (event), ==, - tpl_event_get_account_path (stored_event)); - - sender = tpl_event_get_sender (event); - stored_sender = tpl_event_get_sender (stored_event); - - g_assert (_tpl_entity_compare (sender, stored_sender) == 0); - g_assert_cmpstr (tpl_entity_get_alias (sender), ==, - tpl_entity_get_alias (stored_sender)); - g_assert_cmpstr (tpl_entity_get_avatar_token (sender), ==, - tpl_entity_get_avatar_token (stored_sender)); - - receiver = tpl_event_get_receiver (event); - stored_receiver = tpl_event_get_receiver (stored_event); - - g_assert (_tpl_entity_compare (receiver, stored_receiver) == 0); - /* No support for receiver alias/token */ - - g_assert_cmpstr (tpl_text_event_get_message (TPL_TEXT_EVENT (event)), - ==, tpl_text_event_get_message (TPL_TEXT_EVENT (stored_event))); - g_assert_cmpint (tpl_text_event_get_message_type (TPL_TEXT_EVENT (event)), - ==, tpl_text_event_get_message_type (TPL_TEXT_EVENT (stored_event))); - g_assert_cmpstr (tpl_text_event_get_message_token (TPL_TEXT_EVENT (event)), - ==, tpl_text_event_get_message_token (TPL_TEXT_EVENT (stored_event))); - g_assert_cmpint (tpl_event_get_timestamp (event), ==, - tpl_event_get_timestamp (stored_event)); - g_assert_cmpint (tpl_text_event_get_edit_timestamp (TPL_TEXT_EVENT (event)), - ==, tpl_text_event_get_edit_timestamp (TPL_TEXT_EVENT (stored_event))); -} - - -static void -test_add_text_event (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TpAccount *account; - TplEntity *me, *contact, *room; - TplEvent *event; - GError *error = NULL; - GList *events; - gint64 timestamp = time (NULL); - TpTestsSimpleAccount *account_service; - - tpl_test_create_and_prepare_account (fixture->bus, fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "idle/irc/me", - &account, &account_service); - - me = tpl_entity_new ("bob.mcbadgers@example.com", TPL_ENTITY_SELF, - "my-alias", "my-avatar"); - contact = tpl_entity_new ("contact", TPL_ENTITY_CONTACT, "contact-alias", - "contact-token"); - room = tpl_entity_new_from_room_id ("room"); - - - /* 1. Outgoing message to a contact */ - event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "timestamp", timestamp, - /* TplTextEvent */ - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "my message 1", - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_TEXT_EVENT (events->data)); - - assert_cmp_text_event (event, events->data); - - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); - - /* 2. Incoming message from contact (a /me action) */ - event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", contact, - "receiver", me, - "timestamp", timestamp, - /* TplTextEvent */ - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, - "message", "my message 1", - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_TEXT_EVENT (events->data)); - - assert_cmp_text_event (event, events->data); - - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); - - /* 3. Outgoing message to a room */ - event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", room, - "timestamp", timestamp, - /* TplTextEvent */ - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "my message 1", - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, room, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_TEXT_EVENT (events->data)); - - assert_cmp_text_event (event, events->data); - - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); - - /* 4. Incoming message from a room that hit some network lag. */ - event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", contact, - "receiver", room, - "timestamp", timestamp - 1, - /* TplTextEvent */ - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "my message 1", - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, room, - TPL_EVENT_MASK_TEXT, 2, NULL, NULL); - - /* Events appear in their dbus-order for the most part - * (ignoring timestamps). */ - g_assert_cmpint (g_list_length (events), ==, 2); - g_assert (TPL_IS_TEXT_EVENT (g_list_last (events)->data)); - - assert_cmp_text_event (event, g_list_last (events)->data); - - g_object_unref (event); - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* 5. Delayed delivery of incoming message from a room */ - event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", contact, - "receiver", room, - "timestamp", timestamp - (60 * 60 * 24), - /* TplTextEvent */ - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "my message 1", - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - /* Ask for all of the events to this room... */ - events = _tpl_log_store_get_filtered_events (fixture->store, account, room, - TPL_EVENT_MASK_ANY, 1000000, NULL, NULL); - - /* ... but there are only 3. */ - g_assert_cmpint (g_list_length (events), ==, 3); - g_assert (TPL_IS_TEXT_EVENT (events->data)); - /* Also, because of the day discrepancy, this event will not appear in the - * order it arrived (note that the order is actually undefined (the only - * invariant is that we don't lose the message), so don't cry if you break - * this assertion, as long as you don't break message edits). */ - assert_cmp_text_event (event, events->data); - - tpl_test_release_account (fixture->bus, account, account_service); - g_object_unref (event); - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); -} - -static void -test_add_superseding_event (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TpAccount *account; - TplEntity *me, *contact; - TplEvent *event; - TplTextEvent *new_event; - TplTextEvent *new_new_event; - TplTextEvent *late_event; - TplTextEvent *early_event; - GError *error = NULL; - GList *events; - GList *superseded; - gint64 timestamp = time (NULL); - TpTestsSimpleAccount *account_service; - - tpl_test_create_and_prepare_account (fixture->bus, fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "idle/irc/me", - &account, &account_service); - - me = tpl_entity_new ("me", TPL_ENTITY_SELF, "my-alias", "my-avatar"); - contact = tpl_entity_new ("contact", TPL_ENTITY_CONTACT, "contact-alias", - "contact-token"); - - /* 1. Outgoing message to a contact. */ - event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "message-token", "OMGCOMPLETELYRANDOMSTRING1", - "timestamp", timestamp, - /* TplTextEvent */ - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "my message 1", - NULL); - - /* add and re-retrieve the event */ - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_TEXT_EVENT (events->data)); - - assert_cmp_text_event (event, events->data); - - g_object_unref (events->data); - g_list_free (events); - - /* 2. Edit message 1. */ - new_event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "timestamp", timestamp, - /* TplTextEvent */ - "edit-timestamp", timestamp + 1, - "message-token", "OMGCOMPLETELYRANDOMSTRING2", - "supersedes-token", "OMGCOMPLETELYRANDOMSTRING1", - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "My message 1 [FIXED]", - NULL); - - /* add and re-retrieve the event */ - _tpl_log_store_add_event (fixture->store, TPL_EVENT (new_event), &error); - g_assert_no_error (error); - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - assert_cmp_text_event (TPL_EVENT (new_event), events->data); - - /* Check that the two events are linked */ - superseded = tpl_text_event_get_supersedes (events->data); - g_assert (superseded != NULL); - assert_cmp_text_event (event, superseded->data); - g_assert (tpl_text_event_get_supersedes (superseded->data) == NULL); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* 3. Edit it again. - * Note that the (broken) edit-timestamp should not make any - * difference to the message processing, but it should be preserved.*/ - new_new_event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "timestamp", timestamp, - /* TplTextEvent */ - "edit-timestamp", timestamp + (60 * 60 * 24), - "message-token", "OMGCOMPLETELYRANDOMSTRING3", - "supersedes-token", "OMGCOMPLETELYRANDOMSTRING1", - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "My Message 1 [FIXED] [FIXED]", - NULL); - - /* add and re-retrieve the event */ - _tpl_log_store_add_event (fixture->store, TPL_EVENT (new_new_event), &error); - g_assert_no_error (error); - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - assert_cmp_text_event (TPL_EVENT (new_new_event), events->data); - - /* Check that the three events are linked */ - superseded = tpl_text_event_get_supersedes (events->data); - g_assert (superseded != NULL); - assert_cmp_text_event (TPL_EVENT (new_event), superseded->data); - g_assert (superseded->next != NULL); - assert_cmp_text_event (event, superseded->next->data); - g_assert (tpl_text_event_get_supersedes (superseded->next->data) == NULL); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* Also note that the superseding events *replace* the old ones. */ - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1000000, NULL, NULL); - g_assert_cmpint (g_list_length (events), == , 1); - assert_cmp_text_event (TPL_EVENT (new_new_event), events->data); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* 4. Edit comes in with the wrong timestamp. - * Note that the (also broken) edit-timestamp should not make any - * difference to the message processing, but it should be preserved.*/ - late_event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "timestamp", timestamp + (60 * 60 * 24), - /* TplTextEvent */ - "edit-timestamp", timestamp - (60 * 60 * 24), - "message-token", "OMGCOMPLETELYRANDOMSTRING4", - "supersedes-token", "OMGCOMPLETELYRANDOMSTRING1", - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "My Message 1 [FIXED_LATE]", - NULL); - - /* add and re-retrieve the event */ - _tpl_log_store_add_event (fixture->store, TPL_EVENT (late_event), &error); - g_assert_no_error (error); - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1, NULL, NULL); - assert_cmp_text_event (TPL_EVENT (late_event), events->data); - - /* Check that the events are not linked (and a dummy was inserted instead) - * because the timestamp was wrong. */ - superseded = tpl_text_event_get_supersedes (events->data); - g_assert (superseded != NULL); - g_assert_cmpstr (tpl_text_event_get_message (superseded->data), ==, ""); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* And if we ask for all of the events, there will be 2 there. */ - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1000000, NULL, NULL); - g_assert_cmpint (g_list_length (events), == , 2); - assert_cmp_text_event (TPL_EVENT (new_new_event), events->data); - assert_cmp_text_event (TPL_EVENT (late_event), g_list_last (events)->data); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* 5. If we have an event that is broken in the other direction then it will - * also come out as a separate event (since each day is parsed on its own). - * Even though we don't currently omit edit-timestamp, we might as well - * see what happens if we forget it. */ - early_event = g_object_new (TPL_TYPE_TEXT_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "timestamp", timestamp - (60 * 60 * 24), - /* TplTextEvent */ - "message-token", "OMGCOMPLETELYRANDOMSTRING5", - "supersedes-token", "OMGCOMPLETELYRANDOMSTRING1", - "message-type", TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - "message", "My Message 1 [FIXED_EARLY]", - NULL); - - /* And if we ask for all of the events, there will be 3 there. */ - _tpl_log_store_add_event (fixture->store, TPL_EVENT (early_event), &error); - g_assert_no_error (error); - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_TEXT, 1000000, NULL, NULL); - g_assert_cmpint (g_list_length (events), ==, 3); - assert_cmp_text_event (TPL_EVENT (early_event), events->data); - assert_cmp_text_event (TPL_EVENT (new_new_event), events->next->data); - assert_cmp_text_event (TPL_EVENT (late_event), g_list_last (events)->data); - - tpl_test_release_account (fixture->bus, account, account_service); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - g_object_unref (event); - g_object_unref (new_event); - g_object_unref (new_new_event); - g_object_unref (late_event); - g_object_unref (early_event); -} - -static void -assert_cmp_call_event (TplEvent *event, - TplEvent *stored_event) -{ - TplEntity *sender, *stored_sender; - TplEntity *receiver, *stored_receiver; - TplEntity *actor, *stored_actor; - - g_assert (TPL_IS_CALL_EVENT (event)); - g_assert (TPL_IS_CALL_EVENT (stored_event)); - g_assert_cmpstr (tpl_event_get_account_path (event), ==, - tpl_event_get_account_path (stored_event)); - - sender = tpl_event_get_sender (event); - stored_sender = tpl_event_get_sender (stored_event); - - g_assert (_tpl_entity_compare (sender, stored_sender) == 0); - g_assert_cmpstr (tpl_entity_get_alias (sender), ==, - tpl_entity_get_alias (stored_sender)); - g_assert_cmpstr (tpl_entity_get_avatar_token (sender), ==, - tpl_entity_get_avatar_token (stored_sender)); - - receiver = tpl_event_get_receiver (event); - stored_receiver = tpl_event_get_receiver (stored_event); - - g_assert (_tpl_entity_compare (receiver, stored_receiver) == 0); - /* No support for receiver alias/token */ - - g_assert_cmpint (tpl_event_get_timestamp (event), ==, - tpl_event_get_timestamp (stored_event)); - - g_assert_cmpint (tpl_call_event_get_duration (TPL_CALL_EVENT (event)), - ==, tpl_call_event_get_duration (TPL_CALL_EVENT (stored_event))); - - actor = tpl_call_event_get_end_actor (TPL_CALL_EVENT (event)); - stored_actor = tpl_call_event_get_end_actor (TPL_CALL_EVENT (stored_event)); - - g_assert (_tpl_entity_compare (actor, stored_actor) == 0); - g_assert_cmpstr (tpl_entity_get_alias (actor), ==, - tpl_entity_get_alias (stored_actor)); - g_assert_cmpstr (tpl_entity_get_avatar_token (actor), ==, - tpl_entity_get_avatar_token (stored_actor)); - g_assert_cmpstr ( - tpl_call_event_get_detailed_end_reason (TPL_CALL_EVENT (event)), - ==, - tpl_call_event_get_detailed_end_reason (TPL_CALL_EVENT (stored_event))); -} - - -static void -test_add_call_event (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TpAccount *account; - TplEntity *me, *contact, *room; - TplEvent *event; - GError *error = NULL; - GList *events; - gint64 timestamp = time (NULL); - TpTestsSimpleAccount *account_service; - - tpl_test_create_and_prepare_account (fixture->bus, fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/me", - &account, &account_service); - - me = tpl_entity_new ("bob.mcbadgers@example.com", TPL_ENTITY_SELF, - "my-alias", "my-avatar"); - contact = tpl_entity_new ("contact", TPL_ENTITY_CONTACT, "contact-alias", - "contact-token"); - room = tpl_entity_new_from_room_id ("room"); - - /* 1. Outgoing call to a contact */ - event = g_object_new (TPL_TYPE_CALL_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", contact, - "timestamp", timestamp, - /* TplCallEvent */ - "duration", (gint64) 1234, - "end-actor", me, - "end-reason", TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, - "detailed-end-reason", TP_ERROR_STR_CANCELLED, - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_CALL, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_CALL_EVENT (events->data)); - - assert_cmp_call_event (event, events->data); - - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); - - /* 2. Incoming call from contact */ - event = g_object_new (TPL_TYPE_CALL_EVENT, - /* TplEvent */ - "account", account, - "sender", contact, - "receiver", me, - "timestamp", timestamp, - /* TplCallEvent */ - "duration", (gint64) 2345, - "end-actor", contact, - "end-reason", TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, - "detailed-end-reason", TP_ERROR_STR_TERMINATED, - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, contact, - TPL_EVENT_MASK_CALL, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_CALL_EVENT (events->data)); - - assert_cmp_call_event (event, events->data); - - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); - - /* 3. Outgoing call to a room */ - event = g_object_new (TPL_TYPE_CALL_EVENT, - /* TplEvent */ - "account", account, - "sender", me, - "receiver", room, - "timestamp", timestamp, - /* TplCallEvent */ - "duration", (gint64) 3456, - "end-actor", room, - "end-reason", TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED, - "detailed-end-reason", TP_ERROR_STR_CHANNEL_KICKED, - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, room, - TPL_EVENT_MASK_CALL, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_CALL_EVENT (events->data)); - - assert_cmp_call_event (event, events->data); - - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); - - /* 4. Incoming missed call from a room */ - event = g_object_new (TPL_TYPE_CALL_EVENT, - /* TplEvent */ - "account", account, - "sender", contact, - "receiver", room, - "timestamp", timestamp, - /* TplCallEvent */ - "duration", (gint64) -1, - "end-actor", room, - "end-reason", TP_CALL_STATE_CHANGE_REASON_NO_ANSWER, - "detailed-end-reason", "", - NULL); - - _tpl_log_store_add_event (fixture->store, event, &error); - g_assert_no_error (error); - - events = _tpl_log_store_get_filtered_events (fixture->store, account, room, - TPL_EVENT_MASK_CALL, 1, NULL, NULL); - - g_assert_cmpint (g_list_length (events), ==, 1); - g_assert (TPL_IS_CALL_EVENT (events->data)); - - assert_cmp_call_event (event, events->data); - - tpl_test_release_account (fixture->bus, account, account_service); - g_object_unref (event); - g_object_unref (events->data); - g_list_free (events); -} - -static void -test_exists (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TpAccount *account1, *account2; - TplEntity *user2, *user3; - GError *error = NULL; - - account1 = tp_client_factory_ensure_account (fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0", - NULL, &error); - g_assert_no_error (error); - g_assert (account1 != NULL); - - account2 = tp_client_factory_ensure_account (fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk", - NULL, &error); - g_assert_no_error (error); - g_assert (account1 != NULL); - - user2 = tpl_entity_new ("user2@collabora.co.uk", TPL_ENTITY_CONTACT, - "User2", ""); - - user3 = tpl_entity_new ("user3@collabora.co.uk", TPL_ENTITY_CONTACT, - "User3", ""); - - g_assert (_tpl_log_store_exists (fixture->store, account1, NULL, TPL_EVENT_MASK_ANY)); - g_assert (_tpl_log_store_exists (fixture->store, account1, NULL, TPL_EVENT_MASK_TEXT)); - g_assert (!_tpl_log_store_exists (fixture->store, account1, NULL, TPL_EVENT_MASK_CALL)); - - g_assert (_tpl_log_store_exists (fixture->store, account2, NULL, TPL_EVENT_MASK_ANY)); - g_assert (_tpl_log_store_exists (fixture->store, account2, NULL, TPL_EVENT_MASK_TEXT)); - g_assert (_tpl_log_store_exists (fixture->store, account2, NULL, TPL_EVENT_MASK_CALL)); - - g_assert (!_tpl_log_store_exists (fixture->store, account1, user2, TPL_EVENT_MASK_ANY)); - g_assert (!_tpl_log_store_exists (fixture->store, account1, user2, TPL_EVENT_MASK_TEXT)); - g_assert (!_tpl_log_store_exists (fixture->store, account1, user2, TPL_EVENT_MASK_CALL)); - - g_assert (_tpl_log_store_exists (fixture->store, account2, user2, TPL_EVENT_MASK_ANY)); - g_assert (_tpl_log_store_exists (fixture->store, account2, user2, TPL_EVENT_MASK_TEXT)); - g_assert (!_tpl_log_store_exists (fixture->store, account2, user2, TPL_EVENT_MASK_CALL)); - - g_assert (_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_ANY)); - - g_assert (!_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_TEXT)); - g_assert (_tpl_log_store_exists (fixture->store, account2, user3, TPL_EVENT_MASK_CALL)); - - g_object_unref (account1); - g_object_unref (account2); - g_object_unref (user2); - g_object_unref (user3); -} - - -static void -test_get_events_for_date (XmlTestCaseFixture *fixture, - gconstpointer user_data) -{ - TpAccount *account; - TplEntity *user2, *user3, *user4, *user5; - GList *events; - GDate *date; - gint idx; - TpTestsSimpleAccount *account_service; - - tpl_test_create_and_prepare_account (fixture->bus, fixture->factory, - TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk", - &account, &account_service); - - date = g_date_new_dmy (13, 1, 2010); - - user2 = tpl_entity_new ("user2@collabora.co.uk", TPL_ENTITY_CONTACT, - "User2", ""); - - user3 = tpl_entity_new ("user3@collabora.co.uk", TPL_ENTITY_CONTACT, - "User3", ""); - - user4 = tpl_entity_new ("user4@collabora.co.uk", TPL_ENTITY_CONTACT, - "User4", ""); - - user5 = tpl_entity_new ("user5@collabora.co.uk", TPL_ENTITY_CONTACT, - "User5", ""); - - /* Check that text event and call event are merged properly, call events - * should come after any older or same timestamp event. */ - events = _tpl_log_store_get_events_for_date (fixture->store, account, user4, - TPL_EVENT_MASK_ANY, date); - - g_assert_cmpint (g_list_length (events), ==, 6); - idx = -1; - - g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpstr ( - tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, idx))), - ==, "7"); - - g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpstr ( - tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, idx))), - ==, "8"); - - g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpint ( - tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, 1); - g_assert_cmpint ( - tpl_call_event_get_end_reason (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED); - g_assert_cmpstr (tpl_call_event_get_detailed_end_reason (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, TP_ERROR_STR_CANCELLED); - - g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpint ( - tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, 2); - g_assert_cmpint ( - tpl_call_event_get_end_reason (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED); - g_assert_cmpstr (tpl_call_event_get_detailed_end_reason (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, TP_ERROR_STR_CANCELLED); - - g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpint ( - tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, 3); - g_assert_cmpint ( - tpl_call_event_get_end_reason (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED); - g_assert_cmpstr (tpl_call_event_get_detailed_end_reason (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, TP_ERROR_STR_CANCELLED); - - g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpstr ( - tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, idx))), - ==, "9"); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* Check that a call older then any text event is sorted first */ - events = _tpl_log_store_get_events_for_date (fixture->store, account, user5, - TPL_EVENT_MASK_ANY, date); - - g_assert_cmpint (g_list_length (events), ==, 2); - idx = -1; - - g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpint ( - tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, idx))), - ==, 1); - - g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, ++idx))); - g_assert_cmpstr ( - tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, idx))), - ==, "9"); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* Check that call mask work */ - events = _tpl_log_store_get_events_for_date (fixture->store, account, user4, - TPL_EVENT_MASK_CALL, date); - - g_assert_cmpint (g_list_length (events), ==, 3); - g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, 0))); - g_assert_cmpint ( - tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, 0))), - ==, 1); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* Check that text mask work */ - events = _tpl_log_store_get_events_for_date (fixture->store, account, user4, - TPL_EVENT_MASK_TEXT, date); - - g_assert_cmpint (g_list_length (events), ==, 3); - - g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, 0))); - g_assert_cmpstr ( - tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, 0))), - ==, "7"); - - g_list_foreach (events, (GFunc) g_object_unref, NULL); - g_list_free (events); - - /* Check that getting empty list is working */ - events = _tpl_log_store_get_events_for_date (fixture->store, account, user2, - TPL_EVENT_MASK_CALL, date); - g_assert_cmpint (g_list_length (events), ==, 0); - - events = _tpl_log_store_get_events_for_date (fixture->store, account, user3, - TPL_EVENT_MASK_TEXT, date); - g_assert_cmpint (g_list_length (events), ==, 0); - - tpl_test_release_account (fixture->bus, account, account_service); - g_object_unref (user2); - g_object_unref (user3); - g_object_unref (user4); - g_object_unref (user5); - g_date_free (date); -} - - -gint main (gint argc, gchar **argv) -{ - g_type_init (); - - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - - g_test_add ("/log-store-xml/clear", - XmlTestCaseFixture, NULL, - setup_for_writing, test_clear, teardown); - - g_test_add ("/log-store-xml/clear-account", - XmlTestCaseFixture, NULL, - setup_for_writing, test_clear_account, teardown); - - g_test_add ("/log-store-xml/clear-entity", - XmlTestCaseFixture, GINT_TO_POINTER (FALSE), - setup_for_writing, test_clear_entity, teardown); - - g_test_add ("/log-store-xml/clear-entity-room", - XmlTestCaseFixture, GINT_TO_POINTER (TRUE), - setup_for_writing, test_clear_entity, teardown); - - g_test_add ("/log-store-xml/add-text-event", - XmlTestCaseFixture, NULL, - setup_for_writing, test_add_text_event, teardown); - - g_test_add ("/log-store-xml/add-superseding-event", - XmlTestCaseFixture, NULL, - setup_for_writing, test_add_superseding_event, teardown); - - g_test_add ("/log-store-xml/add-call-event", - XmlTestCaseFixture, NULL, - setup_for_writing, test_add_call_event, teardown); - - g_test_add ("/log-store-xml/exists", - XmlTestCaseFixture, NULL, - setup, test_exists, teardown); - - g_test_add ("/log-store-xml/get-events-for-date", - XmlTestCaseFixture, NULL, - setup, test_get_events_for_date, teardown); - - return g_test_run (); -} diff --git a/tests/dbus/test-tpl-log-walker.c b/tests/dbus/test-tpl-log-walker.c deleted file mode 100644 index b924a12..0000000 --- a/tests/dbus/test-tpl-log-walker.c +++ /dev/null @@ -1,463 +0,0 @@ -#include "config.h" - -#include <string.h> - -#include "lib/simple-account.h" -#include "lib/util.h" - -#include "telepathy-logger/call-event.h" -#include "telepathy-logger/debug-internal.h" -#include "telepathy-logger/log-manager.h" -#include "telepathy-logger/text-event.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> -#include <glib.h> - -#define DEBUG_FLAG TPL_DEBUG_TESTSUITE - - -typedef struct -{ - GList *events; - GMainLoop *main_loop; - TplLogManager *manager; - TpAccount *account; - TpDBusDaemon *bus; - TpClientFactory *factory; - TpTestsSimpleAccount *account_service; -} WalkerTestCaseFixture; - - -static void -account_prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - WalkerTestCaseFixture *fixture = user_data; - GError *error = NULL; - - tp_proxy_prepare_finish (source, result, &error); - g_assert_no_error (error); - - g_main_loop_quit (fixture->main_loop); -} - - -static void -setup (WalkerTestCaseFixture* fixture, - gconstpointer user_data) -{ - GArray *features; - GError *error = NULL; - GHashTable *params = (GHashTable *) user_data; - GValue *boxed_params; - const gchar *account_path; - - fixture->main_loop = g_main_loop_new (NULL, FALSE); - g_assert (fixture->main_loop != NULL); - - fixture->manager = tpl_log_manager_dup_singleton (); - - fixture->bus = tp_tests_dbus_daemon_dup_or_die (); - g_assert (fixture->bus != NULL); - - tp_dbus_daemon_request_name (fixture->bus, - TP_ACCOUNT_MANAGER_BUS_NAME, - FALSE, - &error); - g_assert_no_error (error); - - /* Create service-side Account object with the passed parameters */ - fixture->account_service = g_object_new (TP_TESTS_TYPE_SIMPLE_ACCOUNT, - NULL); - g_assert (fixture->account_service != NULL); - - /* account-path will be set-up as parameter as well, this is not an issue */ - account_path = tp_asv_get_string (params, "account-path"); - g_assert (account_path != NULL); - - boxed_params = tp_g_value_slice_new_boxed (TP_HASH_TYPE_STRING_VARIANT_MAP, - params); - g_object_set_property (G_OBJECT (fixture->account_service), - "parameters", - boxed_params); - tp_g_value_slice_free (boxed_params); - - tp_dbus_daemon_register_object (fixture->bus, - account_path, - fixture->account_service); - - fixture->factory = tp_client_factory_new (fixture->bus); - g_assert (fixture->factory != NULL); - - fixture->account = tp_client_factory_ensure_account (fixture->factory, - tp_asv_get_string (params, "account-path"), - params, - &error); - g_assert_no_error (error); - g_assert (fixture->account != NULL); - - features = tp_client_factory_dup_account_features (fixture->factory, - fixture->account); - - tp_proxy_prepare_async (fixture->account, - (GQuark *) features->data, - account_prepare_cb, - fixture); - g_free (features->data); - g_array_free (features, FALSE); - - g_main_loop_run (fixture->main_loop); - - tp_debug_divert_messages (g_getenv ("TPL_LOGFILE")); - -#ifdef ENABLE_DEBUG - _tpl_debug_set_flags_from_env (); -#endif /* ENABLE_DEBUG */ -} - - -static void -teardown (WalkerTestCaseFixture *fixture, - gconstpointer user_data) -{ - GError *error = NULL; - - tp_dbus_daemon_release_name (fixture->bus, - TP_ACCOUNT_MANAGER_BUS_NAME, - &error); - g_assert_no_error (error); - - g_clear_object (&fixture->account); - g_clear_object (&fixture->factory); - - tp_dbus_daemon_unregister_object (fixture->bus, fixture->account_service); - g_clear_object (&fixture->account_service); - - g_clear_object (&fixture->bus); - g_clear_object (&fixture->manager); - g_main_loop_unref (fixture->main_loop); -} - - -static gboolean -filter_events (TplEvent *event, gpointer user_data) -{ - const gchar *message; - - message = tpl_text_event_get_message (TPL_TEXT_EVENT (event)); - return strstr (message, "'") == NULL; -} - - -static void -rewind_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - WalkerTestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_walker_rewind_finish (TPL_LOG_WALKER (source), - result, - &error); - g_assert_no_error (error); - - g_main_loop_quit (fixture->main_loop); -} - - -static void -rewind (WalkerTestCaseFixture *fixture, - TplLogWalker *walker, - guint num_events) -{ - tpl_log_walker_rewind_async (walker, num_events, rewind_cb, fixture); - g_main_loop_run (fixture->main_loop); -} - - -static void -get_events_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - WalkerTestCaseFixture *fixture = user_data; - GError *error = NULL; - - tpl_log_walker_get_events_finish (TPL_LOG_WALKER (source), - result, - &fixture->events, - &error); - g_assert_no_error (error); - - g_main_loop_quit (fixture->main_loop); -} - - -static void -get_events (WalkerTestCaseFixture *fixture, - TplLogWalker *walker, - guint num_events) -{ - tpl_log_walker_get_events_async (walker, num_events, get_events_cb, fixture); - g_main_loop_run (fixture->main_loop); -} - - -static void -test_get_events_call (WalkerTestCaseFixture *fixture, - TplLogWalker *walker, - guint num_events, - gint64 timestamp, - GTimeSpan duration) -{ - GList *events; - - get_events (fixture, walker, num_events); - - events = fixture->events; - g_assert (events != NULL); - g_assert_cmpuint (g_list_length (events), ==, num_events); - g_assert_cmpint (tpl_event_get_timestamp (TPL_EVENT (events->data)), - ==, - timestamp); - g_assert_cmpint (tpl_call_event_get_duration (TPL_CALL_EVENT (events->data)), - ==, - duration); - g_list_free_full (events, g_object_unref); -} - - -static void -test_get_events_text (WalkerTestCaseFixture *fixture, - TplLogWalker *walker, - guint num_events, - gint64 timestamp, - const gchar *message) -{ - GList *events; - - get_events (fixture, walker, num_events); - - events = fixture->events; - g_assert (events != NULL); - g_assert_cmpuint (g_list_length (events), ==, num_events); - g_assert_cmpint (tpl_event_get_timestamp (TPL_EVENT (events->data)), - ==, - timestamp); - g_assert_cmpstr (tpl_text_event_get_message (TPL_TEXT_EVENT (events->data)), - ==, - message); - g_list_free_full (events, g_object_unref); -} - - -static void -test_get_events (WalkerTestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *events; - TplEntity *user5; - TplLogWalker *walker; - - user5 = tpl_entity_new ("user5@collabora.co.uk", TPL_ENTITY_CONTACT, - "User5", ""); - - /* Both text and call events without a filter */ - walker = tpl_log_manager_walk_filtered_events (fixture->manager, - fixture->account, - user5, - TPL_EVENT_MASK_ANY, - NULL, - NULL); - - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 2, 1263427264, "L''"); - test_get_events_text (fixture, walker, 5, 1263427262, "J"); - test_get_events_text (fixture, walker, 1, 1263427261, "I'''"); - test_get_events_text (fixture, walker, 5, 1263427205, "12"); - test_get_events_text (fixture, walker, 2, 1263427202, "11'"); - test_get_events_call (fixture, walker, 4, 1263404881, 1); - test_get_events_text (fixture, walker, 4, 1263254401, "5''"); - test_get_events_text (fixture, walker, 2, 1263254401, "5"); - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 3, 1263168066, "H'"); - test_get_events_text (fixture, walker, 3, 1263168065, "G''"); - test_get_events_text (fixture, walker, 6, 1263168063, "E"); - test_get_events_text (fixture, walker, 1, 1263168062, "D''"); - test_get_events_text (fixture, walker, 2, 1263168062, "D"); - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 4, 1263168005, "4"); - test_get_events_text (fixture, walker, 2, 1263168003, "2"); - test_get_events_text (fixture, walker, 4, 1263081661, "A"); - - tpl_log_walker_get_events_async (walker, 2, get_events_cb, fixture); - g_main_loop_run (fixture->main_loop); - - events = fixture->events; - g_assert (events == NULL); - - g_object_unref (walker); - - /* Only text events with a filter */ - walker = tpl_log_manager_walk_filtered_events (fixture->manager, - fixture->account, - user5, - TPL_EVENT_MASK_TEXT, - filter_events, - NULL); - - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 2, 1263427263, "K"); - test_get_events_text (fixture, walker, 5, 1263427202, "11"); - test_get_events_text (fixture, walker, 1, 1263427201, "10"); - test_get_events_text (fixture, walker, 5, 1263254401, "5"); - test_get_events_text (fixture, walker, 2, 1263168065, "G"); - test_get_events_text (fixture, walker, 4, 1263168061, "C"); - test_get_events_text (fixture, walker, 2, 1263168004, "3"); - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 3, 1263168001, "0"); - test_get_events_text (fixture, walker, 2, 1263081661, "A"); - - tpl_log_walker_get_events_async (walker, 2, get_events_cb, fixture); - g_main_loop_run (fixture->main_loop); - - events = fixture->events; - g_assert (events == NULL); - - g_object_unref (walker); - g_object_unref (user5); -} - - -static void -test_rewind (WalkerTestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *user5; - TplLogWalker *walker; - - user5 = tpl_entity_new ("user5@collabora.co.uk", TPL_ENTITY_CONTACT, - "User5", ""); - - /* Both text and call events without a filter */ - walker = tpl_log_manager_walk_filtered_events (fixture->manager, - fixture->account, - user5, - TPL_EVENT_MASK_ANY, - NULL, - NULL); - - rewind (fixture, walker, 8); - get_events (fixture, walker, 0); - rewind (fixture, walker, 8); - get_events (fixture, walker, 2); - rewind (fixture, walker, 8); - test_get_events_text (fixture, walker, 8, 1263427261, "I'''"); - rewind (fixture, walker, 3); - test_get_events_text (fixture, walker, 5, 1263427261, "I'"); - rewind (fixture, walker, 1); - test_get_events_text (fixture, walker, 7, 1263427202, "11"); - rewind (fixture, walker, 2); - test_get_events_call (fixture, walker, 5, 1263404881, 1); - rewind (fixture, walker, 2); - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 1, 1263404950, "9"); - rewind (fixture, walker, 0); - test_get_events_text (fixture, walker, 5, 1263254401, "5''"); - rewind (fixture, walker, 1); - test_get_events_text (fixture, walker, 8, 1263168065, "G'''"); - rewind (fixture, walker, 7); - test_get_events_text (fixture, walker, 7, 1263168065, "G'''"); - test_get_events_text (fixture, walker, 7, 1263168063, "E"); - rewind (fixture, walker, 2); - test_get_events_text (fixture, walker, 6, 1263168061, "C"); - rewind (fixture, walker, 10); - rewind (fixture, walker, 0); - rewind (fixture, walker, 5); - test_get_events_text (fixture, walker, 16, 1263168005, "4''"); - rewind (fixture, walker, 3); - test_get_events_text (fixture, walker, 6, 1263168004, "3"); - rewind (fixture, walker, 1); - test_get_events_text (fixture, walker, 6, 1263081661, "A"); - - tpl_log_walker_get_events_async (walker, 2, get_events_cb, fixture); - g_main_loop_run (fixture->main_loop); - g_assert (fixture->events == NULL); - - g_object_unref (walker); - - /* Only text events with a filter */ - walker = tpl_log_manager_walk_filtered_events (fixture->manager, - fixture->account, - user5, - TPL_EVENT_MASK_TEXT, - filter_events, - NULL); - - rewind (fixture, walker, 8); - get_events (fixture, walker, 0); - rewind (fixture, walker, 8); - get_events (fixture, walker, 2); - rewind (fixture, walker, 8); - test_get_events_text (fixture, walker, 8, 1263427201, "10"); - rewind (fixture, walker, 3); - test_get_events_text (fixture, walker, 5, 1263254406, "8"); - rewind (fixture, walker, 1); - test_get_events_text (fixture, walker, 7, 1263168064, "F"); - rewind (fixture, walker, 2); - test_get_events_text (fixture, walker, 5, 1263168061, "C"); - rewind (fixture, walker, 2); - get_events (fixture, walker, 0); - test_get_events_text (fixture, walker, 1, 1263168062, "D"); - rewind (fixture, walker, 0); - test_get_events_text (fixture, walker, 5, 1263168002, "1"); - rewind (fixture, walker, 1); - test_get_events_text (fixture, walker, 4, 1263081661, "A"); - - tpl_log_walker_get_events_async (walker, 2, get_events_cb, fixture); - g_main_loop_run (fixture->main_loop); - g_assert (fixture->events == NULL); - - g_object_unref (walker); - g_object_unref (user5); -} - - -gint main (gint argc, gchar **argv) -{ - GHashTable *params; - gint retval; - - g_type_init (); - - g_test_init (&argc, &argv, NULL); - g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id="); - - params = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, - (GDestroyNotify) tp_g_value_slice_free); - g_assert (params != NULL); - - g_hash_table_insert (params, "account", - tp_g_value_slice_new_static_string ("user@collabora.co.uk")); - g_hash_table_insert (params, "account-path", - tp_g_value_slice_new_static_string ( - TP_ACCOUNT_OBJECT_PATH_BASE - "gabble/jabber/user_40collabora_2eco_2euk")); - - g_test_add ("/log-walker/get-events", - WalkerTestCaseFixture, params, - setup, test_get_events, teardown); - - g_test_add ("/log-walker/rewind", - WalkerTestCaseFixture, params, - setup, test_rewind, teardown); - - retval = g_test_run (); - - g_hash_table_unref (params); - - return retval; -} diff --git a/tests/dbus/test-tpl-observer.c b/tests/dbus/test-tpl-observer.c deleted file mode 100644 index b1c687d..0000000 --- a/tests/dbus/test-tpl-observer.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "config.h" - -#include <telepathy-logger/observer-internal.h> - -int -main (int argc, char **argv) -{ - TplObserver *obs, *obs2; - - g_type_init (); - - obs = _tpl_observer_dup (NULL); - - /* TplObserver is a singleton, be sure both references point to the same - * memory address */ - obs2 = _tpl_observer_dup (NULL); - g_assert (obs == obs2); - - /* unref the second singleton pointer and check that the it is still - * valid: checking correct object ref-counting after each _dup () call */ - g_object_unref (obs2); - g_assert (TPL_IS_OBSERVER (obs)); - - /* it points to the same mem area, it should be still valid */ - g_assert (TPL_IS_OBSERVER (obs2)); - - - /* FIXME: This test does not actually test anything useful */ - - /* proper disposal for the singleton when no references are present */ - g_object_unref (obs); - - return 0; -} - diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am deleted file mode 100644 index 1130029..0000000 --- a/tests/lib/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -noinst_LTLIBRARIES = libtp-logger-tests.la - -libtp_logger_tests_la_SOURCES = \ - contacts-conn.c \ - contacts-conn.h \ - contact-list-manager.c \ - contact-list-manager.h \ - echo-chan.c \ - echo-chan.h \ - room-list-chan.c \ - room-list-chan.h \ - simple-account.c \ - simple-account.h \ - simple-account-manager.c \ - simple-account-manager.h \ - simple-conn.c \ - simple-conn.h \ - util.c \ - util.h \ - logger-test-helper.c \ - logger-test-helper.h - -check_c_sources = *.c -include $(top_srcdir)/tools/check-coding-style.mk -check-local: check-coding-style - -AM_CFLAGS = \ - $(ERROR_CFLAGS) \ - $(TPL_CFLAGS)\ - $(NULL) - -libtp_logger_tests_la_LIBADD = $(TPL_LIBS) diff --git a/tests/lib/contact-list-manager.c b/tests/lib/contact-list-manager.c deleted file mode 100644 index bce8e21..0000000 --- a/tests/lib/contact-list-manager.c +++ /dev/null @@ -1,902 +0,0 @@ -/* - * Example channel manager for contact lists - * - * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright © 2007-2010 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "contact-list-manager.h" - -#include <string.h> -#include <telepathy-glib/telepathy-glib.h> - -struct _TpTestsContactListManagerPrivate -{ - TpBaseConnection *conn; - - gulong status_changed_id; - - /* TpHandle => ContactDetails */ - GHashTable *contact_details; - - TpHandleRepoIface *contact_repo; - GHashTable *groups; -}; - -static void contact_groups_iface_init (TpContactGroupListInterface *iface); -static void mutable_contact_groups_iface_init ( - TpMutableContactGroupListInterface *iface); -static void mutable_iface_init ( - TpMutableContactListInterface *iface); - -G_DEFINE_TYPE_WITH_CODE (TpTestsContactListManager, tp_tests_contact_list_manager, - TP_TYPE_BASE_CONTACT_LIST, - G_IMPLEMENT_INTERFACE (TP_TYPE_CONTACT_GROUP_LIST, - contact_groups_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_MUTABLE_CONTACT_GROUP_LIST, - mutable_contact_groups_iface_init) - G_IMPLEMENT_INTERFACE (TP_TYPE_MUTABLE_CONTACT_LIST, - mutable_iface_init)) - -typedef struct { - TpSubscriptionState subscribe; - TpSubscriptionState publish; - gchar *publish_request; - GHashTable *groups; - - TpHandle handle; - TpHandleRepoIface *contact_repo; -} ContactDetails; - -static void -contact_detail_destroy (gpointer p) -{ - ContactDetails *d = p; - - g_free (d->publish_request); - g_hash_table_unref (d->groups); - - g_slice_free (ContactDetails, d); -} - -static ContactDetails * -lookup_contact (TpTestsContactListManager *self, - TpHandle handle) -{ - return g_hash_table_lookup (self->priv->contact_details, - GUINT_TO_POINTER (handle)); -} - -static ContactDetails * -ensure_contact (TpTestsContactListManager *self, - TpHandle handle) -{ - ContactDetails *d = lookup_contact (self, handle); - - if (d == NULL) - { - d = g_slice_new0 (ContactDetails); - d->subscribe = TP_SUBSCRIPTION_STATE_NO; - d->publish = TP_SUBSCRIPTION_STATE_NO; - d->publish_request = NULL; - d->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - d->handle = handle; - d->contact_repo = self->priv->contact_repo; - - g_hash_table_insert (self->priv->contact_details, - GUINT_TO_POINTER (handle), d); - } - - return d; -} - -static void -tp_tests_contact_list_manager_init (TpTestsContactListManager *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TP_TESTS_TYPE_CONTACT_LIST_MANAGER, TpTestsContactListManagerPrivate); - - self->priv->contact_details = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, contact_detail_destroy); -} - -static void -close_all (TpTestsContactListManager *self) -{ - if (self->priv->status_changed_id != 0) - { - g_signal_handler_disconnect (self->priv->conn, - self->priv->status_changed_id); - self->priv->status_changed_id = 0; - } - tp_clear_pointer (&self->priv->contact_details, g_hash_table_unref); - tp_clear_pointer (&self->priv->groups, g_hash_table_unref); -} - -static void -dispose (GObject *object) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (object); - - close_all (self); - - ((GObjectClass *) tp_tests_contact_list_manager_parent_class)->dispose ( - object); -} - -static TpHandleSet * -contact_list_dup_contacts (TpBaseContactList *base) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (base); - TpHandleSet *set; - GHashTableIter iter; - gpointer k, v; - - set = tp_handle_set_new (self->priv->contact_repo); - - g_hash_table_iter_init (&iter, self->priv->contact_details); - while (g_hash_table_iter_next (&iter, &k, &v)) - { - ContactDetails *d = v; - - /* add all the interesting items */ - if (d->subscribe != TP_SUBSCRIPTION_STATE_NO || - d->publish != TP_SUBSCRIPTION_STATE_NO) - tp_handle_set_add (set, GPOINTER_TO_UINT (k)); - } - - return set; -} - -static void -contact_list_dup_states (TpBaseContactList *base, - TpHandle contact, - TpSubscriptionState *subscribe, - TpSubscriptionState *publish, - gchar **publish_request) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (base); - ContactDetails *d = lookup_contact (self, contact); - - if (d == NULL) - { - if (subscribe != NULL) - *subscribe = TP_SUBSCRIPTION_STATE_NO; - - if (publish != NULL) - *publish = TP_SUBSCRIPTION_STATE_NO; - - if (publish_request != NULL) - *publish_request = NULL; - } - else - { - if (subscribe != NULL) - *subscribe = d->subscribe; - - if (publish != NULL) - *publish = d->publish; - - if (publish_request != NULL) - *publish_request = g_strdup (d->publish_request); - } -} - -static GStrv -contact_list_dup_groups (TpBaseContactList *base) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (base); - GPtrArray *ret; - - if (self->priv->groups != NULL) - { - GHashTableIter iter; - gpointer name; - - ret = g_ptr_array_sized_new (g_hash_table_size (self->priv->groups) + 1); - - g_hash_table_iter_init (&iter, self->priv->groups); - while (g_hash_table_iter_next (&iter, &name, NULL)) - { - g_ptr_array_add (ret, g_strdup (name)); - } - } - else - { - ret = g_ptr_array_sized_new (1); - } - - g_ptr_array_add (ret, NULL); - - return (GStrv) g_ptr_array_free (ret, FALSE); -} - -static GStrv -contact_list_dup_contact_groups (TpBaseContactList *base, - TpHandle contact) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (base); - ContactDetails *d = lookup_contact (self, contact); - GPtrArray *ret; - - if (d != NULL && d->groups != NULL) - { - GHashTableIter iter; - gpointer name; - - ret = g_ptr_array_sized_new (g_hash_table_size (d->groups) + 1); - - g_hash_table_iter_init (&iter, d->groups); - while (g_hash_table_iter_next (&iter, &name, NULL)) - { - g_ptr_array_add (ret, g_strdup (name)); - } - } - else - { - ret = g_ptr_array_sized_new (1); - } - - g_ptr_array_add (ret, NULL); - - return (GStrv) g_ptr_array_free (ret, FALSE); -} - -static TpHandleSet * -contact_list_dup_group_members (TpBaseContactList *base, - const gchar *group) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (base); - GHashTableIter iter; - gpointer k, v; - TpHandleSet *set; - - set = tp_handle_set_new (self->priv->contact_repo); - - if (G_UNLIKELY (g_hash_table_lookup (self->priv->groups, group) == NULL)) - { - /* clearly it doesn't have members */ - return set; - } - - g_hash_table_iter_init (&iter, self->priv->contact_details); - while (g_hash_table_iter_next (&iter, &k, &v)) - { - ContactDetails *d = v; - - if (d->groups != NULL && - g_hash_table_lookup (d->groups, group) != NULL) - tp_handle_set_add (set, GPOINTER_TO_UINT (k)); - } - - return set; -} - -static GPtrArray * -group_difference (GHashTable *left, - GHashTable *right) -{ - GHashTableIter iter; - GPtrArray *set = g_ptr_array_sized_new (g_hash_table_size (left)); - gpointer name; - - g_hash_table_iter_init (&iter, left); - while (g_hash_table_iter_next (&iter, &name, NULL)) - { - if (g_hash_table_lookup (right, name) == NULL) - g_ptr_array_add (set, name); - } - - return set; -} - -static void -contact_list_set_contact_groups_async (TpBaseContactList *base, - TpHandle contact, - const gchar * const *names, - gsize n, - GAsyncReadyCallback callback, - gpointer user_data) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (base); - ContactDetails *d; - GHashTable *tmp; - GPtrArray *added, *removed; - GPtrArray *new_groups; - guint i; - - d = ensure_contact (self, contact); - - new_groups = g_ptr_array_new (); - /* make a hash table so we only have one difference function */ - tmp = g_hash_table_new (g_str_hash, g_str_equal); - for (i = 0; i < n; i++) - { - g_hash_table_insert (tmp, (gpointer) names[i], GUINT_TO_POINTER (1)); - - if (g_hash_table_lookup (self->priv->groups, names[i]) == NULL) - { - g_hash_table_insert (self->priv->groups, g_strdup (names[i]), - GUINT_TO_POINTER (1)); - g_ptr_array_add (new_groups, (gchar *) names[i]); - } - } - - if (new_groups->len > 0) - { - tp_base_contact_list_groups_created ((TpBaseContactList *) self, - (const gchar * const *) new_groups->pdata, new_groups->len); - } - - /* see which groups were added and which were removed */ - added = group_difference (tmp, d->groups); - removed = group_difference (d->groups, tmp); - - g_hash_table_unref (tmp); - - /* update the list of groups the contact thinks it has */ - g_hash_table_remove_all (d->groups); - for (i = 0; i < n; i++) - g_hash_table_insert (d->groups, g_strdup (names[i]), GUINT_TO_POINTER (1)); - - /* signal the change */ - if (added->len > 0 || removed->len > 0) - { - tp_base_contact_list_one_contact_groups_changed (base, contact, - (const gchar * const *) added->pdata, added->len, - (const gchar * const *) removed->pdata, removed->len); - } - - tp_simple_async_report_success_in_idle ((GObject *) self, callback, - user_data, contact_list_set_contact_groups_async); - - g_ptr_array_unref (added); - g_ptr_array_unref (removed); - g_ptr_array_unref (new_groups); -} - -static void -contact_list_set_group_members_async (TpBaseContactList *base, - const gchar *normalized_group, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - - simple = g_simple_async_result_new_error ((GObject *) base, callback, - user_data, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Not implemented"); - g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); -} - -static void -contact_list_add_to_group_async (TpBaseContactList *base, - const gchar *group, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - - simple = g_simple_async_result_new_error ((GObject *) base, callback, - user_data, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Not implemented"); - g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); -} - -static void -contact_list_remove_from_group_async (TpBaseContactList *base, - const gchar *group, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - - simple = g_simple_async_result_new_error ((GObject *) base, callback, - user_data, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Not implemented"); - g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); -} - -static void -contact_list_remove_group_async (TpBaseContactList *base, - const gchar *group, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - - simple = g_simple_async_result_new_error ((GObject *) base, callback, - user_data, TP_ERROR, TP_ERROR_NOT_IMPLEMENTED, "Not implemented"); - g_simple_async_result_complete_in_idle (simple); - g_object_unref (simple); -} - -static void -contact_list_request_subscription_async (TpBaseContactList *self, - TpHandleSet *contacts, - const gchar *message, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GArray *handles; - - handles = tp_handle_set_to_array (contacts); - tp_tests_contact_list_manager_request_subscription ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data, message); - g_array_unref (handles); - - tp_simple_async_report_success_in_idle ((GObject *) self, callback, - user_data, contact_list_request_subscription_async); -} - -static void -contact_list_authorize_publication_async (TpBaseContactList *self, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GArray *handles; - - handles = tp_handle_set_to_array (contacts); - tp_tests_contact_list_manager_authorize_publication ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); - - tp_simple_async_report_success_in_idle ((GObject *) self, callback, - user_data, contact_list_authorize_publication_async); -} - -static void -contact_list_remove_contacts_async (TpBaseContactList *self, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GArray *handles; - - handles = tp_handle_set_to_array (contacts); - tp_tests_contact_list_manager_remove ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); - - tp_simple_async_report_success_in_idle ((GObject *) self, callback, - user_data, contact_list_remove_contacts_async); -} - -static void -contact_list_unsubscribe_async (TpBaseContactList *self, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GArray *handles; - - handles = tp_handle_set_to_array (contacts); - tp_tests_contact_list_manager_unsubscribe ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); - - tp_simple_async_report_success_in_idle ((GObject *) self, callback, - user_data, contact_list_unsubscribe_async); -} - -static void -contact_list_unpublish_async (TpBaseContactList *self, - TpHandleSet *contacts, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GArray *handles; - - handles = tp_handle_set_to_array (contacts); - tp_tests_contact_list_manager_unpublish ( - (TpTestsContactListManager *) self, - handles->len, (TpHandle *) handles->data); - g_array_unref (handles); - - tp_simple_async_report_success_in_idle ((GObject *) self, callback, - user_data, contact_list_unpublish_async); -} - -static void -status_changed_cb (TpBaseConnection *conn, - guint status, - guint reason, - TpTestsContactListManager *self) -{ - switch (status) - { - case TP_CONNECTION_STATUS_CONNECTED: - { - tp_base_contact_list_set_list_received (TP_BASE_CONTACT_LIST (self)); - } - break; - - case TP_CONNECTION_STATUS_DISCONNECTED: - { - close_all (self); - } - break; - } -} - -static void -constructed (GObject *object) -{ - TpTestsContactListManager *self = TP_TESTS_CONTACT_LIST_MANAGER (object); - void (*chain_up) (GObject *) = - ((GObjectClass *) tp_tests_contact_list_manager_parent_class)->constructed; - - if (chain_up != NULL) - { - chain_up (object); - } - - self->priv->conn = tp_base_contact_list_get_connection ( - TP_BASE_CONTACT_LIST (self), NULL); - self->priv->status_changed_id = g_signal_connect (self->priv->conn, - "status-changed", G_CALLBACK (status_changed_cb), self); - - self->priv->contact_repo = tp_base_connection_get_handles (self->priv->conn, - TP_HANDLE_TYPE_CONTACT); - self->priv->groups = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, NULL); -} - -static void -contact_groups_iface_init (TpContactGroupListInterface *iface) -{ - iface->dup_groups = contact_list_dup_groups; - iface->dup_contact_groups = contact_list_dup_contact_groups; - iface->dup_group_members = contact_list_dup_group_members; -} - -static void -mutable_contact_groups_iface_init ( - TpMutableContactGroupListInterface *iface) -{ - iface->set_contact_groups_async = contact_list_set_contact_groups_async; - iface->set_group_members_async = contact_list_set_group_members_async; - iface->add_to_group_async = contact_list_add_to_group_async; - iface->remove_from_group_async = contact_list_remove_from_group_async; - iface->remove_group_async = contact_list_remove_group_async; -} - -static void -mutable_iface_init (TpMutableContactListInterface *iface) -{ - iface->request_subscription_async = contact_list_request_subscription_async; - iface->authorize_publication_async = contact_list_authorize_publication_async; - iface->remove_contacts_async = contact_list_remove_contacts_async; - iface->unsubscribe_async = contact_list_unsubscribe_async; - iface->unpublish_async = contact_list_unpublish_async; -} - -static void -tp_tests_contact_list_manager_class_init (TpTestsContactListManagerClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - TpBaseContactListClass *base_class =(TpBaseContactListClass *) klass; - - g_type_class_add_private (klass, sizeof (TpTestsContactListManagerPrivate)); - - object_class->constructed = constructed; - object_class->dispose = dispose; - - base_class->dup_states = contact_list_dup_states; - base_class->dup_contacts = contact_list_dup_contacts; -} - -void -tp_tests_contact_list_manager_add_to_group (TpTestsContactListManager *self, - const gchar *group_name, TpHandle member) -{ - TpBaseContactList *base = TP_BASE_CONTACT_LIST (self); - ContactDetails *d = ensure_contact (self, member); - - g_hash_table_insert (d->groups, g_strdup (group_name), GUINT_TO_POINTER (1)); - - if (g_hash_table_lookup (self->priv->groups, group_name) == NULL) - { - g_hash_table_insert (self->priv->groups, g_strdup (group_name), - GUINT_TO_POINTER (1)); - tp_base_contact_list_groups_created ((TpBaseContactList *) self, - &group_name, 1); - } - - tp_base_contact_list_one_contact_groups_changed (base, member, - &group_name, 1, NULL, 0); -} - -void -tp_tests_contact_list_manager_remove_from_group (TpTestsContactListManager *self, - const gchar *group_name, TpHandle member) -{ - TpBaseContactList *base = TP_BASE_CONTACT_LIST (self); - ContactDetails *d = lookup_contact (self, member); - - if (d == NULL) - return; - - g_hash_table_remove (d->groups, group_name); - - tp_base_contact_list_one_contact_groups_changed (base, member, - NULL, 0, &group_name, 1); -} - -typedef struct { - TpTestsContactListManager *self; - TpHandleSet *handles; -} SelfAndContact; - -static SelfAndContact * -self_and_contact_new (TpTestsContactListManager *self, - TpHandleSet *handles) -{ - SelfAndContact *ret = g_slice_new0 (SelfAndContact); - - ret->self = g_object_ref (self); - ret->handles = tp_handle_set_copy (handles); - - return ret; -} - -static void -self_and_contact_destroy (gpointer p) -{ - SelfAndContact *s = p; - - tp_handle_set_destroy (s->handles); - g_object_unref (s->self); - g_slice_free (SelfAndContact, s); -} - -static gboolean -receive_authorized (gpointer p) -{ - SelfAndContact *s = p; - GArray *handles_array; - guint i; - - handles_array = tp_handle_set_to_array (s->handles); - for (i = 0; i < handles_array->len; i++) - { - ContactDetails *d = lookup_contact (s->self, - g_array_index (handles_array, TpHandle, i)); - - if (d == NULL) - continue; - - d->subscribe = TP_SUBSCRIPTION_STATE_YES; - - /* if we're not publishing to them, also pretend they have asked us to do so */ - if (d->publish != TP_SUBSCRIPTION_STATE_YES) - { - d->publish = TP_SUBSCRIPTION_STATE_ASK; - tp_clear_pointer (&d->publish_request, g_free); - d->publish_request = g_strdup ("automatic publish request"); - } - } - g_array_unref (handles_array); - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (s->self), - s->handles, NULL); - - return FALSE; -} - -static gboolean -receive_unauthorized (gpointer p) -{ - SelfAndContact *s = p; - GArray *handles_array; - guint i; - - handles_array = tp_handle_set_to_array (s->handles); - for (i = 0; i < handles_array->len; i++) - { - ContactDetails *d = lookup_contact (s->self, - g_array_index (handles_array, TpHandle, i)); - - if (d == NULL) - continue; - - d->subscribe = TP_SUBSCRIPTION_STATE_REMOVED_REMOTELY; - } - g_array_unref (handles_array); - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (s->self), - s->handles, NULL); - - return FALSE; -} - -void -tp_tests_contact_list_manager_request_subscription (TpTestsContactListManager *self, - guint n_members, TpHandle *members, const gchar *message) -{ - TpHandleSet *handles; - guint i; - gchar *message_lc; - - handles = tp_handle_set_new (self->priv->contact_repo); - for (i = 0; i < n_members; i++) - { - ContactDetails *d = ensure_contact (self, members[i]); - - if (d->subscribe == TP_SUBSCRIPTION_STATE_YES) - continue; - - d->subscribe = TP_SUBSCRIPTION_STATE_ASK; - tp_handle_set_add (handles, members[i]); - } - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (self), handles, - NULL); - - message_lc = g_ascii_strdown (message, -1); - if (strstr (message_lc, "please") != NULL) - { - g_idle_add_full (G_PRIORITY_DEFAULT, - receive_authorized, - self_and_contact_new (self, handles), - self_and_contact_destroy); - } - else if (strstr (message_lc, "no") != NULL) - { - g_idle_add_full (G_PRIORITY_DEFAULT, - receive_unauthorized, - self_and_contact_new (self, handles), - self_and_contact_destroy); - } - - g_free (message_lc); - tp_handle_set_destroy (handles); -} - -void -tp_tests_contact_list_manager_unsubscribe (TpTestsContactListManager *self, - guint n_members, TpHandle *members) -{ - TpHandleSet *handles; - guint i; - - handles = tp_handle_set_new (self->priv->contact_repo); - for (i = 0; i < n_members; i++) - { - ContactDetails *d = lookup_contact (self, members[i]); - - if (d == NULL || d->subscribe == TP_SUBSCRIPTION_STATE_NO) - continue; - - d->subscribe = TP_SUBSCRIPTION_STATE_NO; - tp_handle_set_add (handles, members[i]); - } - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (self), handles, - NULL); - - tp_handle_set_destroy (handles); -} - -void -tp_tests_contact_list_manager_authorize_publication (TpTestsContactListManager *self, - guint n_members, TpHandle *members) -{ - TpHandleSet *handles; - guint i; - - handles = tp_handle_set_new (self->priv->contact_repo); - for (i = 0; i < n_members; i++) - { - ContactDetails *d = lookup_contact (self, members[i]); - - if (d == NULL || d->publish != TP_SUBSCRIPTION_STATE_ASK) - continue; - - d->publish = TP_SUBSCRIPTION_STATE_YES; - tp_clear_pointer (&d->publish_request, g_free); - tp_handle_set_add (handles, members[i]); - } - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (self), handles, - NULL); - - tp_handle_set_destroy (handles); -} - -void -tp_tests_contact_list_manager_unpublish (TpTestsContactListManager *self, - guint n_members, TpHandle *members) -{ - TpHandleSet *handles; - guint i; - - handles = tp_handle_set_new (self->priv->contact_repo); - for (i = 0; i < n_members; i++) - { - ContactDetails *d = lookup_contact (self, members[i]); - - if (d == NULL || d->publish == TP_SUBSCRIPTION_STATE_NO) - continue; - - d->publish = TP_SUBSCRIPTION_STATE_NO; - tp_clear_pointer (&d->publish_request, g_free); - tp_handle_set_add (handles, members[i]); - } - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (self), handles, - NULL); - - tp_handle_set_destroy (handles); -} - -void -tp_tests_contact_list_manager_remove (TpTestsContactListManager *self, - guint n_members, TpHandle *members) -{ - TpHandleSet *handles; - guint i; - - handles = tp_handle_set_new (self->priv->contact_repo); - for (i = 0; i < n_members; i++) - { - ContactDetails *d = lookup_contact (self, members[i]); - - if (d == NULL) - continue; - - g_hash_table_remove (self->priv->contact_details, - GUINT_TO_POINTER (members[i])); - tp_handle_set_add (handles, members[i]); - } - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (self), NULL, - handles); - - tp_handle_set_destroy (handles); -} - -void -tp_tests_contact_list_manager_add_initial_contacts (TpTestsContactListManager *self, - guint n_members, TpHandle *members) -{ - TpHandleSet *handles; - guint i; - - g_assert_cmpint (tp_base_connection_get_status (self->priv->conn), ==, - TP_CONNECTION_STATUS_DISCONNECTED); - g_assert (!tp_base_connection_is_destroyed (self->priv->conn)); - - handles = tp_handle_set_new (self->priv->contact_repo); - for (i = 0; i < n_members; i++) - { - ContactDetails *d; - - g_assert (lookup_contact (self, members[i]) == NULL); - d = ensure_contact (self, members[i]); - - d->subscribe = TP_SUBSCRIPTION_STATE_YES; - d->publish = TP_SUBSCRIPTION_STATE_YES; - - tp_handle_set_add (handles, members[i]); - } - - tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (self), handles, - NULL); - - tp_handle_set_destroy (handles); -} diff --git a/tests/lib/contact-list-manager.h b/tests/lib/contact-list-manager.h deleted file mode 100644 index bc44863..0000000 --- a/tests/lib/contact-list-manager.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Example channel manager for contact lists - * - * Copyright © 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright © 2007-2010 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_CONTACT_LIST_MANAGER_H__ -#define __TP_TESTS_CONTACT_LIST_MANAGER_H__ - -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -#define TP_TESTS_TYPE_CONTACT_LIST_MANAGER \ - (tp_tests_contact_list_manager_get_type ()) -#define TP_TESTS_CONTACT_LIST_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_CONTACT_LIST_MANAGER, \ - TpTestsContactListManager)) -#define TP_TESTS_CONTACT_LIST_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_CONTACT_LIST_MANAGER, \ - TpTestsContactListManagerClass)) -#define TP_TESTS_IS_CONTACT_LIST_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_CONTACT_LIST_MANAGER)) -#define TP_TESTS_IS_CONTACT_LIST_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_CONTACT_LIST_MANAGER)) -#define TP_TESTS_CONTACT_LIST_MANAGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_CONTACT_LIST_MANAGER, \ - TpTestsContactListManagerClass)) - -typedef struct _TpTestsContactListManager TpTestsContactListManager; -typedef struct _TpTestsContactListManagerClass TpTestsContactListManagerClass; -typedef struct _TpTestsContactListManagerPrivate TpTestsContactListManagerPrivate; - -struct _TpTestsContactListManagerClass { - TpBaseContactListClass parent_class; -}; - -struct _TpTestsContactListManager { - TpBaseContactList parent; - - TpTestsContactListManagerPrivate *priv; -}; - -GType tp_tests_contact_list_manager_get_type (void); - -void tp_tests_contact_list_manager_add_to_group (TpTestsContactListManager *self, - const gchar *group_name, TpHandle member); -void tp_tests_contact_list_manager_remove_from_group (TpTestsContactListManager *self, - const gchar *group_name, TpHandle member); - -void tp_tests_contact_list_manager_request_subscription (TpTestsContactListManager *self, - guint n_members, TpHandle *members, const gchar *message); -void tp_tests_contact_list_manager_unsubscribe (TpTestsContactListManager *self, - guint n_members, TpHandle *members); -void tp_tests_contact_list_manager_authorize_publication (TpTestsContactListManager *self, - guint n_members, TpHandle *members); -void tp_tests_contact_list_manager_unpublish (TpTestsContactListManager *self, - guint n_members, TpHandle *members); -void tp_tests_contact_list_manager_remove (TpTestsContactListManager *self, - guint n_members, TpHandle *members); -void tp_tests_contact_list_manager_add_initial_contacts (TpTestsContactListManager *self, - guint n_members, TpHandle *members); - -G_END_DECLS - -#endif diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c deleted file mode 100644 index 5ebc35f..0000000 --- a/tests/lib/contacts-conn.c +++ /dev/null @@ -1,1120 +0,0 @@ -/* - * contacts-conn.c - connection with contact info - * - * Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007-2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "contacts-conn.h" - -#include <dbus/dbus-glib.h> - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -#include "debug.h" - -static void init_aliasing (gpointer, gpointer); -static void init_avatars (gpointer, gpointer); -static void init_contact_info (gpointer, gpointer); -static void conn_avatars_properties_getter (GObject *object, GQuark interface, - GQuark name, GValue *value, gpointer getter_data); - -G_DEFINE_TYPE_WITH_CODE (TpTestsContactsConnection, - tp_tests_contacts_connection, - TP_TESTS_TYPE_SIMPLE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1, - init_aliasing); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_AVATARS1, - init_avatars); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1, - tp_presence_mixin_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_LOCATION1, NULL) - G_IMPLEMENT_INTERFACE ( - TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1, NULL) - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO1, - init_contact_info) - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, - tp_contacts_mixin_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_LIST1, - tp_base_contact_list_mixin_list_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_GROUPS1, - tp_base_contact_list_mixin_groups_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPES1, - NULL); - ); - -/* type definition stuff */ - -static const char *mime_types[] = { "image/png", NULL }; -static TpDBusPropertiesMixinPropImpl conn_avatars_properties[] = { - { "MinimumAvatarWidth", GUINT_TO_POINTER (1), NULL }, - { "MinimumAvatarHeight", GUINT_TO_POINTER (2), NULL }, - { "RecommendedAvatarWidth", GUINT_TO_POINTER (3), NULL }, - { "RecommendedAvatarHeight", GUINT_TO_POINTER (4), NULL }, - { "MaximumAvatarWidth", GUINT_TO_POINTER (5), NULL }, - { "MaximumAvatarHeight", GUINT_TO_POINTER (6), NULL }, - { "MaximumAvatarBytes", GUINT_TO_POINTER (7), NULL }, - /* special-cased - it's the only one with a non-guint value */ - { "SupportedAvatarMIMETypes", NULL, NULL }, - { NULL } -}; - -enum -{ - N_SIGNALS -}; - -struct _TpTestsContactsConnectionPrivate -{ - /* TpHandle => gchar * */ - GHashTable *aliases; - /* TpHandle => AvatarData */ - GHashTable *avatars; - /* TpHandle => ContactsConnectionPresenceStatusIndex */ - GHashTable *presence_statuses; - /* TpHandle => gchar * */ - GHashTable *presence_messages; - /* TpHandle => GHashTable * */ - GHashTable *locations; - /* TpHandle => GPtrArray * */ - GHashTable *capabilities; - /* TpHandle => GPtrArray * */ - GHashTable *contact_info; - GPtrArray *default_contact_info; - - TpTestsContactListManager *list_manager; -}; - -typedef struct -{ - GArray *data; - gchar *mime_type; - gchar *token; -} AvatarData; - -static AvatarData * -avatar_data_new (GArray *data, - const gchar *mime_type, - const gchar *token) -{ - AvatarData *a; - - a = g_slice_new (AvatarData); - a->data = data ? g_array_ref (data) : NULL; - a->mime_type = g_strdup (mime_type); - a->token = g_strdup (token); - - return a; -} - -static void -avatar_data_free (gpointer data) -{ - AvatarData *a = data; - - if (a != NULL) - { - if (a->data != NULL) - g_array_unref (a->data); - g_free (a->mime_type); - g_free (a->token); - g_slice_free (AvatarData, a); - } -} - -static void -free_rcc_list (GPtrArray *rccs) -{ - g_boxed_free (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, rccs); -} - -static void -tp_tests_contacts_connection_init (TpTestsContactsConnection *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TESTS_TYPE_CONTACTS_CONNECTION, - TpTestsContactsConnectionPrivate); - self->priv->aliases = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, g_free); - self->priv->avatars = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, avatar_data_free); - self->priv->presence_statuses = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, NULL); - self->priv->presence_messages = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, g_free); - self->priv->locations = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify) g_hash_table_unref); - self->priv->capabilities = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, (GDestroyNotify) free_rcc_list); - self->priv->contact_info = g_hash_table_new_full (g_direct_hash, - g_direct_equal, NULL, (GDestroyNotify) g_ptr_array_unref); -} - -static void -finalize (GObject *object) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - - tp_contacts_mixin_finalize (object); - g_hash_table_unref (self->priv->aliases); - g_hash_table_unref (self->priv->avatars); - g_hash_table_unref (self->priv->presence_statuses); - g_hash_table_unref (self->priv->presence_messages); - g_hash_table_unref (self->priv->locations); - g_hash_table_unref (self->priv->capabilities); - g_hash_table_unref (self->priv->contact_info); - - if (self->priv->default_contact_info != NULL) - g_ptr_array_unref (self->priv->default_contact_info); - - G_OBJECT_CLASS (tp_tests_contacts_connection_parent_class)->finalize (object); -} - -static void -aliasing_fill_contact_attributes (GObject *object, - const GArray *contacts, - GHashTable *attributes) -{ - guint i; - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - TpBaseConnection *base = TP_BASE_CONNECTION (object); - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, guint, i); - const gchar *alias = g_hash_table_lookup (self->priv->aliases, - GUINT_TO_POINTER (handle)); - - if (alias == NULL) - { - alias = tp_handle_inspect (contact_repo, handle); - } - - tp_contacts_mixin_set_contact_attribute (attributes, handle, - TP_IFACE_CONNECTION_INTERFACE_ALIASING1 "/alias", - tp_g_value_slice_new_string (alias)); - } -} - -static void -avatars_fill_contact_attributes (GObject *object, - const GArray *contacts, - GHashTable *attributes) -{ - guint i; - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, guint, i); - AvatarData *a = g_hash_table_lookup (self->priv->avatars, - GUINT_TO_POINTER (handle)); - - if (a != NULL && a->token != NULL) - { - tp_contacts_mixin_set_contact_attribute (attributes, handle, - TP_IFACE_CONNECTION_INTERFACE_AVATARS1 "/token", - tp_g_value_slice_new_string (a->token)); - } - } -} - -static void -location_fill_contact_attributes (GObject *object, - const GArray *contacts, - GHashTable *attributes) -{ - guint i; - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, guint, i); - GHashTable *location = g_hash_table_lookup (self->priv->locations, - GUINT_TO_POINTER (handle)); - - if (location != NULL) - { - tp_contacts_mixin_set_contact_attribute (attributes, handle, - TP_IFACE_CONNECTION_INTERFACE_LOCATION1 "/location", - tp_g_value_slice_new_boxed (TP_HASH_TYPE_LOCATION, location)); - } - } -} - -static void -contact_caps_fill_contact_attributes (GObject *object, - const GArray *contacts, - GHashTable *attributes) -{ - guint i; - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, guint, i); - GPtrArray *caps = g_hash_table_lookup (self->priv->capabilities, - GUINT_TO_POINTER (handle)); - - if (caps != NULL) - { - tp_contacts_mixin_set_contact_attribute (attributes, handle, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1 "/capabilities", - tp_g_value_slice_new_boxed ( - TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, caps)); - } - } -} - -static void -contact_info_fill_contact_attributes (GObject *object, - const GArray *contacts, - GHashTable *attributes) -{ - guint i; - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, guint, i); - GPtrArray *info = g_hash_table_lookup (self->priv->contact_info, - GUINT_TO_POINTER (handle)); - - if (info != NULL) - { - tp_contacts_mixin_set_contact_attribute (attributes, handle, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1 "/info", - tp_g_value_slice_new_boxed (TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST, - info)); - } - } -} - -static TpDBusPropertiesMixinPropImpl conn_contact_info_properties[] = { - { "ContactInfoFlags", GUINT_TO_POINTER (TP_CONTACT_INFO_FLAG_PUSH | - TP_CONTACT_INFO_FLAG_CAN_SET), NULL }, - { "SupportedFields", NULL, NULL }, - { NULL } -}; - -static void -conn_contact_info_properties_getter (GObject *object, - GQuark interface, - GQuark name, - GValue *value, - gpointer getter_data) -{ - GQuark q_supported_fields = g_quark_from_static_string ("SupportedFields"); - static GPtrArray *supported_fields = NULL; - - if (name == q_supported_fields) - { - if (supported_fields == NULL) - { - supported_fields = g_ptr_array_new (); - - g_ptr_array_add (supported_fields, tp_value_array_build (4, - G_TYPE_STRING, "bday", - G_TYPE_STRV, NULL, - G_TYPE_UINT, 0, - G_TYPE_UINT, 1, - G_TYPE_INVALID)); - - g_ptr_array_add (supported_fields, tp_value_array_build (4, - G_TYPE_STRING, "email", - G_TYPE_STRV, NULL, - G_TYPE_UINT, 0, - G_TYPE_UINT, G_MAXUINT32, - G_TYPE_INVALID)); - - g_ptr_array_add (supported_fields, tp_value_array_build (4, - G_TYPE_STRING, "fn", - G_TYPE_STRV, NULL, - G_TYPE_UINT, 0, - G_TYPE_UINT, 1, - G_TYPE_INVALID)); - - g_ptr_array_add (supported_fields, tp_value_array_build (4, - G_TYPE_STRING, "tel", - G_TYPE_STRV, NULL, - G_TYPE_UINT, 0, - G_TYPE_UINT, G_MAXUINT32, - G_TYPE_INVALID)); - - g_ptr_array_add (supported_fields, tp_value_array_build (4, - G_TYPE_STRING, "url", - G_TYPE_STRV, NULL, - G_TYPE_UINT, 0, - G_TYPE_UINT, G_MAXUINT32, - G_TYPE_INVALID)); - } - g_value_set_boxed (value, supported_fields); - } - else - { - g_value_set_uint (value, GPOINTER_TO_UINT (getter_data)); - } -} - -static void -client_types_fill_contact_attributes ( - GObject *object, - const GArray *contacts, - GHashTable *attributes) -{ - TpTestsContactsConnectionClass *klass = - TP_TESTS_CONTACTS_CONNECTION_GET_CLASS (object); - - if (klass->fill_client_types != NULL) - klass->fill_client_types (object, contacts, attributes); - /* …else do nothing: a no-op implementation is valid, relatively speaking. - * The spec sez the /client-types attribute should be “omitted from the - * result if the contact's client types are not known.” - */ -} - -static void -constructed (GObject *object) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - TpBaseConnection *base = TP_BASE_CONNECTION (object); - void (*parent_impl) (GObject *) = - G_OBJECT_CLASS (tp_tests_contacts_connection_parent_class)->constructed; - - if (parent_impl != NULL) - parent_impl (object); - - self->priv->list_manager = g_object_new (TP_TESTS_TYPE_CONTACT_LIST_MANAGER, - "connection", self, NULL); - - tp_contacts_mixin_init (object, - G_STRUCT_OFFSET (TpTestsContactsConnection, contacts_mixin)); - tp_base_connection_register_with_contacts_mixin (base); - if (self->priv->list_manager) - { - tp_base_contact_list_mixin_register_with_contacts_mixin ( - TP_BASE_CONTACT_LIST (self->priv->list_manager), base); - } - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_ALIASING1, - aliasing_fill_contact_attributes); - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_AVATARS1, - avatars_fill_contact_attributes); - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_LOCATION1, - location_fill_contact_attributes); - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1, - contact_caps_fill_contact_attributes); - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1, - contact_info_fill_contact_attributes); - tp_contacts_mixin_add_contact_attributes_iface (object, - TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES1, - client_types_fill_contact_attributes); - - tp_presence_mixin_init (object, - G_STRUCT_OFFSET (TpTestsContactsConnection, presence_mixin)); - tp_presence_mixin_register_with_contacts_mixin (object); -} - -static const TpPresenceStatusOptionalArgumentSpec can_have_message[] = { - { "message", "s", NULL, NULL }, - { NULL } -}; - -/* Must match TpTestsContactsConnectionPresenceStatusIndex in the .h */ -static const TpPresenceStatusSpec my_statuses[] = { - { "available", TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, TRUE, - can_have_message }, - { "busy", TP_CONNECTION_PRESENCE_TYPE_BUSY, TRUE, can_have_message }, - { "away", TP_CONNECTION_PRESENCE_TYPE_AWAY, TRUE, can_have_message }, - { "offline", TP_CONNECTION_PRESENCE_TYPE_OFFLINE, FALSE, NULL }, - { "unknown", TP_CONNECTION_PRESENCE_TYPE_UNKNOWN, FALSE, NULL }, - { "error", TP_CONNECTION_PRESENCE_TYPE_ERROR, FALSE, NULL }, - { NULL } -}; - -static gboolean -my_status_available (GObject *object, - guint index) -{ - TpBaseConnection *base = TP_BASE_CONNECTION (object); - - return tp_base_connection_check_connected (base, NULL); -} - -static GHashTable * -my_get_contact_statuses (GObject *object, - const GArray *contacts) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object); - GHashTable *result = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify) tp_presence_status_free); - guint i; - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, TpHandle, i); - gpointer key = GUINT_TO_POINTER (handle); - TpTestsContactsConnectionPresenceStatusIndex index; - const gchar *presence_message; - GHashTable *parameters; - - index = GPOINTER_TO_UINT (g_hash_table_lookup ( - self->priv->presence_statuses, key)); - presence_message = g_hash_table_lookup ( - self->priv->presence_messages, key); - - parameters = g_hash_table_new_full (g_str_hash, - g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free); - - if (presence_message != NULL) - g_hash_table_insert (parameters, (gpointer) "message", - tp_g_value_slice_new_string (presence_message)); - - g_hash_table_insert (result, key, - tp_presence_status_new (index, parameters)); - g_hash_table_unref (parameters); - } - - return result; -} - -static gboolean -my_set_own_status (GObject *object, - const TpPresenceStatus *status, - GError **error) -{ - TpBaseConnection *base_conn = TP_BASE_CONNECTION (object); - TpTestsContactsConnectionPresenceStatusIndex index = status->index; - const gchar *message = ""; - TpHandle self_handle; - - if (status->optional_arguments != NULL) - { - message = g_hash_table_lookup (status->optional_arguments, "message"); - - if (message == NULL) - message = ""; - } - - self_handle = tp_base_connection_get_self_handle (base_conn); - tp_tests_contacts_connection_change_presences (TP_TESTS_CONTACTS_CONNECTION (object), - 1, &self_handle, &index, &message); - - return TRUE; -} - -static guint -my_get_maximum_status_message_length_cb (GObject *obj) -{ - return 512; -} - -static GPtrArray * -create_channel_managers (TpBaseConnection *conn) -{ - return g_ptr_array_new (); -} - -static GPtrArray * -tp_tests_contacts_get_interfaces_always_present (TpBaseConnection *base) -{ - GPtrArray *interfaces; - static const gchar *interfaces_always_present[] = { - TP_IFACE_CONNECTION_INTERFACE_ALIASING1, - TP_IFACE_CONNECTION_INTERFACE_AVATARS1, - TP_IFACE_CONNECTION_INTERFACE_CONTACTS, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST1, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS1, - TP_IFACE_CONNECTION_INTERFACE_PRESENCE1, - TP_IFACE_CONNECTION_INTERFACE_LOCATION1, - TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES1, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1, - TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1, - NULL }; - guint i; - - interfaces = TP_BASE_CONNECTION_CLASS ( - tp_tests_contacts_connection_parent_class)->get_interfaces_always_present (base); - - for (i = 0; interfaces_always_present[i] != NULL; i++) - g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]); - - return interfaces; -} - -enum -{ - ALIASING_DP_ALIAS_FLAGS, -}; - -static void -aliasing_get_dbus_property (GObject *object, - GQuark interface, - GQuark name, - GValue *value, - gpointer user_data) -{ - switch (GPOINTER_TO_UINT (user_data)) - { - case ALIASING_DP_ALIAS_FLAGS: - g_value_set_uint (value, TP_CONNECTION_ALIAS_FLAG_USER_SET); - break; - - default: - g_assert_not_reached (); - } -} - -static void -tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass) -{ - TpBaseConnectionClass *base_class = - (TpBaseConnectionClass *) klass; - GObjectClass *object_class = (GObjectClass *) klass; - TpPresenceMixinClass *mixin_class; - static TpDBusPropertiesMixinPropImpl aliasing_props[] = { - { "AliasFlags", GUINT_TO_POINTER (ALIASING_DP_ALIAS_FLAGS), NULL }, - { NULL } - }; - static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = { - { TP_IFACE_CONNECTION_INTERFACE_AVATARS1, - conn_avatars_properties_getter, - NULL, - conn_avatars_properties, - }, - { TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1, - conn_contact_info_properties_getter, - NULL, - conn_contact_info_properties, - }, - { TP_IFACE_CONNECTION_INTERFACE_ALIASING1, - aliasing_get_dbus_property, - NULL, - aliasing_props, - }, - { NULL } - }; - - object_class->constructed = constructed; - object_class->finalize = finalize; - g_type_class_add_private (klass, sizeof (TpTestsContactsConnectionPrivate)); - - base_class->get_interfaces_always_present = tp_tests_contacts_get_interfaces_always_present; - base_class->create_channel_managers = create_channel_managers; - - tp_contacts_mixin_class_init (object_class, - G_STRUCT_OFFSET (TpTestsContactsConnectionClass, contacts_mixin)); - - tp_presence_mixin_class_init (object_class, - G_STRUCT_OFFSET (TpTestsContactsConnectionClass, presence_mixin), - my_status_available, my_get_contact_statuses, - my_set_own_status, my_statuses); - mixin_class = TP_PRESENCE_MIXIN_CLASS(klass); - mixin_class->get_maximum_status_message_length = - my_get_maximum_status_message_length_cb; - - tp_presence_mixin_init_dbus_properties (object_class); - - klass->properties_class.interfaces = prop_interfaces; - tp_dbus_properties_mixin_class_init (object_class, - G_STRUCT_OFFSET (TpTestsContactsConnectionClass, properties_class)); - - tp_base_contact_list_mixin_class_init (base_class); -} - -TpTestsContactListManager * -tp_tests_contacts_connection_get_contact_list_manager ( - TpTestsContactsConnection *self) -{ - return self->priv->list_manager; -} - -/** - * tp_tests_contacts_connection_change_aliases: - * @self: a #TpTestsContactsConnection - * @n: the number of handles - * @handles: (array length=n): the handles - * @aliases: (array length=n): aliases - * - */ -void -tp_tests_contacts_connection_change_aliases (TpTestsContactsConnection *self, - guint n, - const TpHandle *handles, - const gchar * const *aliases) -{ - GHashTable *changes = g_hash_table_new (NULL, NULL); - guint i; - - for (i = 0; i < n; i++) - { - DEBUG ("contact#%u -> %s", handles[i], aliases[i]); - - g_hash_table_insert (self->priv->aliases, - GUINT_TO_POINTER (handles[i]), g_strdup (aliases[i])); - - g_hash_table_insert (changes, - GUINT_TO_POINTER (handles[i]), (gchar *) aliases[i]); - } - - tp_svc_connection_interface_aliasing1_emit_aliases_changed (self, changes); - - g_hash_table_unref (changes); -} - -void -tp_tests_contacts_connection_change_presences ( - TpTestsContactsConnection *self, - guint n, - const TpHandle *handles, - const TpTestsContactsConnectionPresenceStatusIndex *indexes, - const gchar * const *messages) -{ - GHashTable *presences = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, (GDestroyNotify) tp_presence_status_free); - guint i; - - for (i = 0; i < n; i++) - { - GHashTable *parameters; - gpointer key = GUINT_TO_POINTER (handles[i]); - - DEBUG ("contact#%u -> %s \"%s\"", handles[i], - my_statuses[indexes[i]].name, messages[i]); - - g_hash_table_insert (self->priv->presence_statuses, key, - GUINT_TO_POINTER (indexes[i])); - g_hash_table_insert (self->priv->presence_messages, key, - g_strdup (messages[i])); - - parameters = g_hash_table_new_full (g_str_hash, - g_str_equal, NULL, (GDestroyNotify) tp_g_value_slice_free); - - if (messages[i] != NULL && messages[i][0] != '\0') - g_hash_table_insert (parameters, (gpointer) "message", - tp_g_value_slice_new_string (messages[i])); - - g_hash_table_insert (presences, key, tp_presence_status_new (indexes[i], - parameters)); - g_hash_table_unref (parameters); - } - - tp_presence_mixin_emit_presence_update ((GObject *) self, - presences); - g_hash_table_unref (presences); -} - -void -tp_tests_contacts_connection_change_avatar_tokens (TpTestsContactsConnection *self, - guint n, - const TpHandle *handles, - const gchar * const *tokens) -{ - guint i; - - for (i = 0; i < n; i++) - { - DEBUG ("contact#%u -> %s", handles[i], tokens[i]); - g_hash_table_insert (self->priv->avatars, - GUINT_TO_POINTER (handles[i]), avatar_data_new (NULL, NULL, tokens[i])); - tp_svc_connection_interface_avatars1_emit_avatar_updated (self, - handles[i], tokens[i]); - } -} - -void -tp_tests_contacts_connection_change_avatar_data ( - TpTestsContactsConnection *self, - TpHandle handle, - GArray *data, - const gchar *mime_type, - const gchar *token) -{ - g_hash_table_insert (self->priv->avatars, - GUINT_TO_POINTER (handle), avatar_data_new (data, mime_type, token)); - - tp_svc_connection_interface_avatars1_emit_avatar_updated (self, - handle, token); -} - -void -tp_tests_contacts_connection_change_locations (TpTestsContactsConnection *self, - guint n, - const TpHandle *handles, - GHashTable **locations) -{ - guint i; - - for (i = 0; i < n; i++) - { - DEBUG ("contact#%u ->", handles[i]); - tp_asv_dump (locations[i]); - g_hash_table_insert (self->priv->locations, - GUINT_TO_POINTER (handles[i]), g_hash_table_ref (locations[i])); - - tp_svc_connection_interface_location1_emit_location_updated (self, - handles[i], locations[i]); - } -} - -void -tp_tests_contacts_connection_change_capabilities ( - TpTestsContactsConnection *self, - GHashTable *capabilities) -{ - GHashTableIter iter; - gpointer handle, caps; - - g_hash_table_iter_init (&iter, capabilities); - while (g_hash_table_iter_next (&iter, &handle, &caps)) - { - g_hash_table_insert (self->priv->capabilities, - handle, - g_boxed_copy (TP_ARRAY_TYPE_REQUESTABLE_CHANNEL_CLASS_LIST, - caps)); - } - - tp_svc_connection_interface_contact_capabilities1_emit_contact_capabilities_changed ( - self, capabilities); -} - -void -tp_tests_contacts_connection_change_contact_info ( - TpTestsContactsConnection *self, - TpHandle handle, - GPtrArray *info) -{ - g_hash_table_insert (self->priv->contact_info, GUINT_TO_POINTER (handle), - g_ptr_array_ref (info)); - - tp_svc_connection_interface_contact_info1_emit_contact_info_changed (self, - handle, info); -} - -void -tp_tests_contacts_connection_set_default_contact_info ( - TpTestsContactsConnection *self, - GPtrArray *info) -{ - if (self->priv->default_contact_info != NULL) - g_ptr_array_unref (self->priv->default_contact_info); - self->priv->default_contact_info = g_ptr_array_ref (info); -} - -static void -my_request_aliases (TpSvcConnectionInterfaceAliasing1 *aliasing, - const GArray *contacts, - DBusGMethodInvocation *context) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (aliasing); - TpBaseConnection *base = TP_BASE_CONNECTION (aliasing); - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - GPtrArray *result; - gchar **strings; - GError *error = NULL; - guint i; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); - - if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error)) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - result = g_ptr_array_sized_new (contacts->len + 1); - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, TpHandle, i); - const gchar *alias = g_hash_table_lookup (self->priv->aliases, - GUINT_TO_POINTER (handle)); - - if (alias == NULL) - g_ptr_array_add (result, - (gchar *) tp_handle_inspect (contact_repo, handle)); - else - g_ptr_array_add (result, (gchar *) alias); - } - - g_ptr_array_add (result, NULL); - strings = (gchar **) g_ptr_array_free (result, FALSE); - tp_svc_connection_interface_aliasing1_return_from_request_aliases (context, - (const gchar **) strings); - g_free (strings); -} - -static void -my_set_aliases (TpSvcConnectionInterfaceAliasing1 *aliasing, - GHashTable *table, - DBusGMethodInvocation *context) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (aliasing); - TpBaseConnection *base = TP_BASE_CONNECTION (aliasing); - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - guint n; - GArray *handles; - GPtrArray *aliases; - GHashTableIter iter; - gpointer key, value; - GError *error = NULL; - - /* Convert the hash table to arrays of handles and aliases */ - n = g_hash_table_size (table); - handles = g_array_sized_new (FALSE, FALSE, sizeof (TpHandle), n); - aliases = g_ptr_array_sized_new (n); - g_hash_table_iter_init (&iter, table); - while (g_hash_table_iter_next (&iter, &key, &value)) - { - TpHandle handle = GPOINTER_TO_UINT (key); - - g_array_append_val (handles, handle); - g_ptr_array_add (aliases, value); - } - g_assert_cmpuint (handles->len, ==, n); - g_assert_cmpuint (aliases->len, ==, n); - - /* Verify all handles are valid */ - if (!tp_handles_are_valid (contact_repo, handles, FALSE, &error)) - { - dbus_g_method_return_error (context, error); - g_clear_error (&error); - goto out; - } - - /* Change aliases */ - tp_tests_contacts_connection_change_aliases (self, n, - (const TpHandle *) handles->data, - (const gchar * const *) aliases->pdata); - - tp_svc_connection_interface_aliasing1_return_from_set_aliases (context); - -out: - g_array_unref (handles); - g_ptr_array_unref (aliases); -} - -static void -init_aliasing (gpointer g_iface, - gpointer iface_data) -{ - TpSvcConnectionInterfaceAliasing1Class *klass = g_iface; - -#define IMPLEMENT(x) tp_svc_connection_interface_aliasing1_implement_##x (\ - klass, my_##x) - IMPLEMENT(request_aliases); - IMPLEMENT(set_aliases); -#undef IMPLEMENT -} - -static void -my_request_avatars (TpSvcConnectionInterfaceAvatars1 *avatars, - const GArray *contacts, - DBusGMethodInvocation *context) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (avatars); - TpBaseConnection *base = TP_BASE_CONNECTION (avatars); - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - GError *error = NULL; - guint i; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); - - if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error)) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, TpHandle, i); - AvatarData *a = g_hash_table_lookup (self->priv->avatars, - GUINT_TO_POINTER (handle)); - - if (a != NULL) - tp_svc_connection_interface_avatars1_emit_avatar_retrieved (self, handle, - a->token, a->data, a->mime_type); - } - - tp_svc_connection_interface_avatars1_return_from_request_avatars (context); -} - -static void -conn_avatars_properties_getter (GObject *object, - GQuark interface, - GQuark name, - GValue *value, - gpointer getter_data) -{ - GQuark q_mime_types = g_quark_from_static_string ( - "SupportedAvatarMIMETypes"); - - if (name == q_mime_types) - { - g_value_set_static_boxed (value, mime_types); - } - else - { - g_value_set_uint (value, GPOINTER_TO_UINT (getter_data)); - } -} - -static void -init_avatars (gpointer g_iface, - gpointer iface_data) -{ - TpSvcConnectionInterfaceAvatars1Class *klass = g_iface; - -#define IMPLEMENT(x) tp_svc_connection_interface_avatars1_implement_##x (\ - klass, my_##x) - /* IMPLEMENT(get_avatar_requirements); */ - /* IMPLEMENT(request_avatar); */ - IMPLEMENT(request_avatars); - /* IMPLEMENT(set_avatar); */ - /* IMPLEMENT(clear_avatar); */ -#undef IMPLEMENT -} - -static GPtrArray * -lookup_contact_info (TpTestsContactsConnection *self, - TpHandle handle) -{ - GPtrArray *ret = g_hash_table_lookup (self->priv->contact_info, - GUINT_TO_POINTER (handle)); - - if (ret == NULL && self->priv->default_contact_info != NULL) - { - ret = self->priv->default_contact_info; - g_hash_table_insert (self->priv->contact_info, GUINT_TO_POINTER (handle), - g_ptr_array_ref (ret)); - } - - if (ret == NULL) - return g_ptr_array_new (); - - return g_ptr_array_ref (ret); -} - -static void -my_refresh_contact_info (TpSvcConnectionInterfaceContactInfo1 *obj, - const GArray *contacts, - DBusGMethodInvocation *context) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (obj); - TpBaseConnection *base = TP_BASE_CONNECTION (obj); - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - GError *error = NULL; - guint i; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); - - if (!tp_handles_are_valid (contact_repo, contacts, FALSE, &error)) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - for (i = 0; i < contacts->len; i++) - { - TpHandle handle = g_array_index (contacts, guint, i); - GPtrArray *arr = lookup_contact_info (self, handle); - - tp_svc_connection_interface_contact_info1_emit_contact_info_changed (self, - handle, arr); - g_ptr_array_unref (arr); - } - - tp_svc_connection_interface_contact_info1_return_from_refresh_contact_info ( - context); -} - -static void -my_request_contact_info (TpSvcConnectionInterfaceContactInfo1 *obj, - guint handle, - DBusGMethodInvocation *context) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (obj); - TpBaseConnection *base = TP_BASE_CONNECTION (obj); - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (base, - TP_HANDLE_TYPE_CONTACT); - GError *error = NULL; - GPtrArray *ret; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); - - if (!tp_handle_is_valid (contact_repo, handle, &error)) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - ret = lookup_contact_info (self, handle); - - tp_svc_connection_interface_contact_info1_return_from_request_contact_info ( - context, ret); - - g_ptr_array_unref (ret); -} - -static void -my_set_contact_info (TpSvcConnectionInterfaceContactInfo1 *obj, - const GPtrArray *info, - DBusGMethodInvocation *context) -{ - TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (obj); - TpBaseConnection *base = TP_BASE_CONNECTION (obj); - GPtrArray *copy; - guint i; - TpHandle self_handle; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); - - /* Deep copy info */ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - copy = g_ptr_array_new_with_free_func ((GDestroyNotify) g_value_array_free); - for (i = 0; i < info->len; i++) - g_ptr_array_add (copy, g_value_array_copy (g_ptr_array_index (info, i))); - G_GNUC_END_IGNORE_DEPRECATIONS - - self_handle = tp_base_connection_get_self_handle (base); - tp_tests_contacts_connection_change_contact_info (self, self_handle, copy); - g_ptr_array_unref (copy); - - tp_svc_connection_interface_contact_info1_return_from_set_contact_info ( - context); -} - -static void -init_contact_info (gpointer g_iface, - gpointer iface_data) -{ - TpSvcConnectionInterfaceContactInfo1Class *klass = g_iface; - -#define IMPLEMENT(x) tp_svc_connection_interface_contact_info1_implement_##x (\ - klass, my_##x) - IMPLEMENT (refresh_contact_info); - IMPLEMENT (request_contact_info); - IMPLEMENT (set_contact_info); -#undef IMPLEMENT -} diff --git a/tests/lib/contacts-conn.h b/tests/lib/contacts-conn.h deleted file mode 100644 index 679b0eb..0000000 --- a/tests/lib/contacts-conn.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * contacts-conn.h - header for a connection with contact info - * - * Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007-2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_CONTACTS_CONN_H__ -#define __TP_TESTS_CONTACTS_CONN_H__ - -#include <glib-object.h> -#include <telepathy-glib/telepathy-glib.h> - -#include "simple-conn.h" -#include "contact-list-manager.h" - -G_BEGIN_DECLS - -typedef struct _TpTestsContactsConnection TpTestsContactsConnection; -typedef struct _TpTestsContactsConnectionClass TpTestsContactsConnectionClass; -typedef struct _TpTestsContactsConnectionPrivate TpTestsContactsConnectionPrivate; - -struct _TpTestsContactsConnectionClass { - TpTestsSimpleConnectionClass parent_class; - - TpPresenceMixinClass presence_mixin; - TpContactsMixinClass contacts_mixin; - TpDBusPropertiesMixinClass properties_class; - - TpContactsMixinFillContactAttributesFunc fill_client_types; -}; - -struct _TpTestsContactsConnection { - TpTestsSimpleConnection parent; - - TpPresenceMixin presence_mixin; - TpContactsMixin contacts_mixin; - - TpTestsContactsConnectionPrivate *priv; -}; - -GType tp_tests_contacts_connection_get_type (void); - -/* Must match my_statuses in the .c */ -typedef enum { - TP_TESTS_CONTACTS_CONNECTION_STATUS_AVAILABLE, - TP_TESTS_CONTACTS_CONNECTION_STATUS_BUSY, - TP_TESTS_CONTACTS_CONNECTION_STATUS_AWAY, - TP_TESTS_CONTACTS_CONNECTION_STATUS_OFFLINE, - TP_TESTS_CONTACTS_CONNECTION_STATUS_UNKNOWN, - TP_TESTS_CONTACTS_CONNECTION_STATUS_ERROR -} TpTestsContactsConnectionPresenceStatusIndex; - -/* TYPE MACROS */ -#define TP_TESTS_TYPE_CONTACTS_CONNECTION \ - (tp_tests_contacts_connection_get_type ()) -#define TP_TESTS_CONTACTS_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_CONTACTS_CONNECTION, \ - TpTestsContactsConnection)) -#define TP_TESTS_CONTACTS_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_CONTACTS_CONNECTION, \ - TpTestsContactsConnectionClass)) -#define TP_TESTS_IS_CONTACTS_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_CONTACTS_CONNECTION)) -#define TP_TESTS_IS_CONTACTS_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_CONTACTS_CONNECTION)) -#define TP_TESTS_CONTACTS_CONNECTION_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_CONTACTS_CONNECTION, \ - TpTestsContactsConnectionClass)) - -TpTestsContactListManager *tp_tests_contacts_connection_get_contact_list_manager ( - TpTestsContactsConnection *self); - -void tp_tests_contacts_connection_change_aliases ( - TpTestsContactsConnection *self, guint n, - const TpHandle *handles, const gchar * const *aliases); - -void tp_tests_contacts_connection_change_presences ( - TpTestsContactsConnection *self, guint n, const TpHandle *handles, - const TpTestsContactsConnectionPresenceStatusIndex *indexes, - const gchar * const *messages); - -void tp_tests_contacts_connection_change_avatar_tokens ( - TpTestsContactsConnection *self, guint n, const TpHandle *handles, - const gchar * const *tokens); - -void tp_tests_contacts_connection_change_avatar_data ( - TpTestsContactsConnection *self, - TpHandle handle, - GArray *data, - const gchar *mime_type, - const gchar *token); - -void tp_tests_contacts_connection_change_locations ( - TpTestsContactsConnection *self, - guint n, - const TpHandle *handles, - GHashTable **locations); - -void tp_tests_contacts_connection_change_capabilities ( - TpTestsContactsConnection *self, GHashTable *capabilities); - -void tp_tests_contacts_connection_change_contact_info ( - TpTestsContactsConnection *self, TpHandle handle, GPtrArray *info); - -void tp_tests_contacts_connection_set_default_contact_info ( - TpTestsContactsConnection *self, - GPtrArray *info); - -G_END_DECLS - -#endif /* ifndef __TP_TESTS_CONTACTS_CONN_H__ */ diff --git a/tests/lib/debug.h b/tests/lib/debug.h deleted file mode 100644 index 60e070b..0000000 --- a/tests/lib/debug.h +++ /dev/null @@ -1,3 +0,0 @@ -#undef DEBUG -#define DEBUG(format, ...) \ - g_debug ("%s: " format, G_STRFUNC, ##__VA_ARGS__) diff --git a/tests/lib/echo-chan.c b/tests/lib/echo-chan.c deleted file mode 100644 index 9234a6a..0000000 --- a/tests/lib/echo-chan.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * chan.c - an example text channel talking to a particular - * contact. Similar code is used for 1-1 IM channels in many protocols - * (IRC private messages ("/query"), XMPP IM etc.) - * - * Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "echo-chan.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -static void destroyable_iface_init (gpointer iface, gpointer data); - -G_DEFINE_TYPE_WITH_CODE (TpTestsEchoChannel, - tp_tests_echo_channel, - TP_TYPE_BASE_CHANNEL, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_TEXT, - tp_message_mixin_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_DESTROYABLE1, - destroyable_iface_init); - ) - -/* type definition stuff */ - -static GPtrArray * -tp_tests_echo_channel_get_interfaces (TpBaseChannel *self) -{ - GPtrArray *interfaces; - - interfaces = TP_BASE_CHANNEL_CLASS (tp_tests_echo_channel_parent_class)-> - get_interfaces (self); - - g_ptr_array_add (interfaces, TP_IFACE_CHANNEL_INTERFACE_DESTROYABLE1); - return interfaces; -}; - -static void -tp_tests_echo_channel_init (TpTestsEchoChannel *self) -{ -} - -static void text_send (GObject *object, TpMessage *message, - TpMessageSendingFlags flags); - -static void -constructed (GObject *object) -{ - TpTestsEchoChannel *self = TP_TESTS_ECHO_CHANNEL (object); - TpBaseConnection *conn = tp_base_channel_get_connection (TP_BASE_CHANNEL (self)); - const TpChannelTextMessageType types[] = { - TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL, - TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION, - TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE, - }; - const gchar * supported_content_types[] = { - "text/plain", - NULL - }; - g_assert (conn != NULL); - - G_OBJECT_CLASS (tp_tests_echo_channel_parent_class)->constructed (object); - - tp_base_channel_register (TP_BASE_CHANNEL (self)); - - tp_message_mixin_init (object, - G_STRUCT_OFFSET (TpTestsEchoChannel, message), - conn); - tp_message_mixin_implement_sending (object, - text_send, G_N_ELEMENTS (types), types, 0, 0, - supported_content_types); -} - -static void -finalize (GObject *object) -{ - tp_message_mixin_finalize (object); - - ((GObjectClass *) tp_tests_echo_channel_parent_class)->finalize (object); -} - -static void -tp_tests_echo_channel_close (TpTestsEchoChannel *self) -{ - GObject *object = (GObject *) self; - gboolean closed = tp_base_channel_is_destroyed (TP_BASE_CHANNEL (self)); - - if (!closed) - { - TpHandle first_sender; - - /* The manager wants to be able to respawn the channel if it has pending - * messages. When respawned, the channel must have the initiator set - * to the contact who sent us those messages (if it isn't already), - * and the messages must be marked as having been rescued so they - * don't get logged twice. */ - if (tp_message_mixin_has_pending_messages (object, &first_sender)) - { - tp_base_channel_reopened (TP_BASE_CHANNEL (self), first_sender); - tp_message_mixin_set_rescued (object); - } - else - { - tp_base_channel_destroyed (TP_BASE_CHANNEL (self)); - } - } -} - -static void -channel_close (TpBaseChannel *channel) -{ - TpTestsEchoChannel *self = TP_TESTS_ECHO_CHANNEL (channel); - - tp_tests_echo_channel_close (self); -} - -static void -tp_tests_echo_channel_class_init (TpTestsEchoChannelClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - TpBaseChannelClass *base_class = TP_BASE_CHANNEL_CLASS (klass); - - object_class->constructed = constructed; - object_class->finalize = finalize; - - base_class->channel_type = TP_IFACE_CHANNEL_TYPE_TEXT; - base_class->target_handle_type = TP_HANDLE_TYPE_CONTACT; - base_class->get_interfaces = tp_tests_echo_channel_get_interfaces; - base_class->close = channel_close; - - tp_message_mixin_init_dbus_properties (object_class); -} - - -static void -text_send (GObject *object, - TpMessage *message, - TpMessageSendingFlags flags) -{ - TpTestsEchoChannel *self = TP_TESTS_ECHO_CHANNEL (object); - TpChannelTextMessageType type = tp_message_get_message_type (message); - TpChannelTextMessageType echo_type = type; - TpHandle target = tp_base_channel_get_target_handle (TP_BASE_CHANNEL (self)); - gchar *echo; - gint64 now = time (NULL); - const GHashTable *part; - const gchar *text; - TpMessage *msg; - - /* Pretend that the remote contact has replied. Normally, you'd - * call tp_text_mixin_receive or tp_text_mixin_receive_with_flags - * in response to network events */ - - part = tp_message_peek (message, 1); - text = tp_asv_get_string (part, "content"); - - switch (type) - { - case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL: - echo = g_strdup_printf ("You said: %s", text); - break; - case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION: - echo = g_strdup_printf ("notices that the user %s", text); - break; - case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE: - echo = g_strdup_printf ("You sent a notice: %s", text); - break; - default: - echo = g_strdup_printf ("You sent some weird message type, %u: \"%s\"", - type, text); - echo_type = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL; - } - - tp_message_mixin_sent (object, message, 0, "", NULL); - - msg = tp_cm_message_new ( - tp_base_channel_get_connection (TP_BASE_CHANNEL (self)), - 2); - - tp_cm_message_set_sender (msg, target); - tp_message_set_uint32 (msg, 0, "message-type", echo_type); - tp_message_set_int64 (msg, 0, "message-sent", now); - tp_message_set_int64 (msg, 0, "message-received", now); - - tp_message_set_string (msg, 1, "content-type", "text/plain"); - tp_message_set_string (msg, 1, "content", echo); - - tp_message_mixin_take_received (object, msg); - - g_free (echo); -} - -static void -destroyable_destroy (TpSvcChannelInterfaceDestroyable1 *iface, - DBusGMethodInvocation *context) -{ - TpTestsEchoChannel *self = TP_TESTS_ECHO_CHANNEL (iface); - - tp_message_mixin_clear ((GObject *) self); - tp_base_channel_destroyed (TP_BASE_CHANNEL (self)); - - tp_svc_channel_interface_destroyable1_return_from_destroy (context); -} - -static void -destroyable_iface_init (gpointer iface, - gpointer data) -{ - TpSvcChannelInterfaceDestroyable1Class *klass = iface; - -#define IMPLEMENT(x) \ - tp_svc_channel_interface_destroyable1_implement_##x (klass, destroyable_##x) - IMPLEMENT (destroy); -#undef IMPLEMENT -} diff --git a/tests/lib/echo-chan.h b/tests/lib/echo-chan.h deleted file mode 100644 index 5fbe6ee..0000000 --- a/tests/lib/echo-chan.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * chan.h - header for an example channel - * - * Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_CHAN_H__ -#define __TP_TESTS_CHAN_H__ - -#include <glib-object.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef struct _TpTestsEchoChannel TpTestsEchoChannel; -typedef struct _TpTestsEchoChannelClass TpTestsEchoChannelClass; -typedef struct _TpTestsEchoChannelPrivate TpTestsEchoChannelPrivate; - -GType tp_tests_echo_channel_get_type (void); - -#define TP_TESTS_TYPE_ECHO_CHANNEL \ - (tp_tests_echo_channel_get_type ()) -#define TP_TESTS_ECHO_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), TP_TESTS_TYPE_ECHO_CHANNEL, \ - TpTestsEchoChannel)) -#define TP_TESTS_ECHO_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), TP_TESTS_TYPE_ECHO_CHANNEL, \ - TpTestsEchoChannelClass)) -#define TP_TESTS_IS_ECHO_CHANNEL(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TP_TESTS_TYPE_ECHO_CHANNEL)) -#define TP_TESTS_IS_ECHO_CHANNEL_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), TP_TESTS_TYPE_ECHO_CHANNEL)) -#define TP_TESTS_ECHO_CHANNEL_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_ECHO_CHANNEL, \ - TpTestsEchoChannelClass)) - -struct _TpTestsEchoChannelClass { - TpBaseChannelClass parent_class; - TpDBusPropertiesMixinClass dbus_properties_class; -}; - -struct _TpTestsEchoChannel { - TpBaseChannel parent; - TpMessageMixin message; - - TpTestsEchoChannelPrivate *priv; -}; - -G_END_DECLS - -#endif /* #ifndef __TP_TESTS_CHAN_H__ */ diff --git a/tests/lib/logger-test-helper.c b/tests/lib/logger-test-helper.c deleted file mode 100644 index fd20baf..0000000 --- a/tests/lib/logger-test-helper.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * logger-test-helper.c - * - * Copyright (C) 2013 Collabora Ltd. <http://www.collabora.co.uk/> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <config.h> - -#include "logger-test-helper.h" - -#include <stdlib.h> - -#include "util.h" - -void -tpl_test_create_and_prepare_account (TpDBusDaemon *dbus, - TpClientFactory *factory, - const gchar *path, - TpAccount **account, - TpTestsSimpleAccount **account_service) -{ - GError *error = NULL; - GArray *features; - GQuark zero = 0; - - *account_service = g_object_new (TP_TESTS_TYPE_SIMPLE_ACCOUNT, - NULL); - g_assert (*account_service != NULL); - - tp_dbus_daemon_register_object (dbus, path, *account_service); - - *account = tp_client_factory_ensure_account (factory, path, NULL, - &error); - g_assert_no_error (error); - g_assert (*account != NULL); - - features = tp_client_factory_dup_account_features (factory, *account); - g_array_append_val (features, zero); - - tp_tests_proxy_run_until_prepared (*account, (GQuark *) features->data); - g_array_free (features, FALSE); -} - -void -tpl_test_release_account (TpDBusDaemon *dbus, - TpAccount *account, - TpTestsSimpleAccount *account_service) -{ - tp_dbus_daemon_unregister_object (dbus, account_service); - g_object_unref (account_service); - g_object_unref (account); -} - -void -tp_tests_copy_dir (const gchar *from_dir, const gchar *to_dir) -{ - gchar *command; - - // If destination directory exist erase it - command = g_strdup_printf ("rm -rf %s", to_dir); - g_assert (system (command) == 0); - g_free (command); - - command = g_strdup_printf ("cp -r %s %s", from_dir, to_dir); - g_assert (system (command) == 0); - g_free (command); - - // In distcheck mode the files and directory are read-only, fix that - command = g_strdup_printf ("chmod -R +w %s", to_dir); - g_assert (system (command) == 0); - g_free (command); -} diff --git a/tests/lib/logger-test-helper.h b/tests/lib/logger-test-helper.h deleted file mode 100644 index cb836f2..0000000 --- a/tests/lib/logger-test-helper.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * logger-test-helper.h - * - * Copyright (C) 2013 Collabora Ltd. <http://www.collabora.co.uk/> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __LOGGER_TEST_HELPER_H__ -#define __LOGGER_TEST_HELPER_H__ - -#include <telepathy-glib/telepathy-glib.h> - -#include "simple-account.h" - -void tpl_test_create_and_prepare_account (TpDBusDaemon *dbus, - TpClientFactory *factory, - const gchar *path, - TpAccount **account, - TpTestsSimpleAccount **account_service); - -void tpl_test_release_account (TpDBusDaemon *dbus, - TpAccount *account, - TpTestsSimpleAccount *account_service); - -void tp_tests_copy_dir (const gchar *from_dir, const gchar *to_dir); - -#endif diff --git a/tests/lib/room-list-chan.c b/tests/lib/room-list-chan.c deleted file mode 100644 index a3a7a8c..0000000 --- a/tests/lib/room-list-chan.c +++ /dev/null @@ -1,252 +0,0 @@ - -#include "config.h" - -#include "room-list-chan.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -static void room_list_iface_init (gpointer iface, - gpointer data); - -G_DEFINE_TYPE_WITH_CODE (TpTestsRoomListChan, tp_tests_room_list_chan, TP_TYPE_BASE_CHANNEL, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_ROOM_LIST1, room_list_iface_init)) - -enum { - PROP_SERVER = 1, - LAST_PROPERTY, -}; - -/* -enum { - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; -*/ - -struct _TpTestsRoomListChanPriv { - gchar *server; - gboolean listing; -}; - -static void -tp_tests_room_list_chan_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object); - - switch (property_id) - { - case PROP_SERVER: - g_value_set_string (value, self->priv->server); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tp_tests_room_list_chan_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object); - - switch (property_id) - { - case PROP_SERVER: - g_assert (self->priv->server == NULL); /* construct only */ - self->priv->server = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tp_tests_room_list_chan_constructed (GObject *object) -{ - TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object); - void (*chain_up) (GObject *) = - ((GObjectClass *) tp_tests_room_list_chan_parent_class)->constructed; - - if (chain_up != NULL) - chain_up (object); - - tp_base_channel_register (TP_BASE_CHANNEL (self)); -} - -static void -tp_tests_room_list_chan_finalize (GObject *object) -{ - TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (object); - void (*chain_up) (GObject *) = - ((GObjectClass *) tp_tests_room_list_chan_parent_class)->finalize; - - g_free (self->priv->server); - - if (chain_up != NULL) - chain_up (object); -} - -static void -fill_immutable_properties (TpBaseChannel *chan, - GHashTable *properties) -{ - TpBaseChannelClass *klass = TP_BASE_CHANNEL_CLASS ( - tp_tests_room_list_chan_parent_class); - - klass->fill_immutable_properties (chan, properties); - - tp_dbus_properties_mixin_fill_properties_hash ( - G_OBJECT (chan), properties, - TP_IFACE_CHANNEL_TYPE_ROOM_LIST1, "Server", - NULL); -} - -static void -room_list_chan_close (TpBaseChannel *channel) -{ - tp_base_channel_destroyed (channel); -} - -static void -tp_tests_room_list_chan_class_init ( - TpTestsRoomListChanClass *klass) -{ - GObjectClass *oclass = G_OBJECT_CLASS (klass); - TpBaseChannelClass *base_class = TP_BASE_CHANNEL_CLASS (klass); - GParamSpec *spec; - static TpDBusPropertiesMixinPropImpl room_list_props[] = { - { "Server", "server", NULL, }, - { NULL } - }; - - oclass->get_property = tp_tests_room_list_chan_get_property; - oclass->set_property = tp_tests_room_list_chan_set_property; - oclass->constructed = tp_tests_room_list_chan_constructed; - oclass->finalize = tp_tests_room_list_chan_finalize; - - base_class->channel_type = TP_IFACE_CHANNEL_TYPE_ROOM_LIST1; - base_class->target_handle_type = TP_HANDLE_TYPE_NONE; - base_class->fill_immutable_properties = fill_immutable_properties; - base_class->close = room_list_chan_close; - - spec = g_param_spec_string ("server", "server", - "Server", - "", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_SERVER, spec); - - tp_dbus_properties_mixin_implement_interface (oclass, - TP_IFACE_QUARK_CHANNEL_TYPE_ROOM_LIST1, - tp_dbus_properties_mixin_getter_gobject_properties, NULL, - room_list_props); - - g_type_class_add_private (klass, sizeof (TpTestsRoomListChanPriv)); -} - -static void -tp_tests_room_list_chan_init (TpTestsRoomListChan *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TP_TESTS_TYPE_ROOM_LIST_CHAN, TpTestsRoomListChanPriv); -} - -static void -add_room (GPtrArray *rooms) -{ - GHashTable *hash; - - hash = tp_asv_new ( - "handle-name", G_TYPE_STRING, "the handle name", - "name", G_TYPE_STRING, "the name", - "description", G_TYPE_STRING, "the description", - "subject", G_TYPE_STRING, "the subject", - "members", G_TYPE_UINT, 10, - "password", G_TYPE_BOOLEAN, TRUE, - "invite-only", G_TYPE_BOOLEAN, TRUE, - "room-id", G_TYPE_STRING, "the room id", - "server", G_TYPE_STRING, "the server", - NULL); - - g_ptr_array_add (rooms, tp_value_array_build (3, - G_TYPE_UINT, 0, - G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_HASH_TYPE_STRING_VARIANT_MAP, hash, - G_TYPE_INVALID)); - - g_hash_table_unref (hash); -} - -static gboolean -find_rooms (gpointer data) -{ - TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (data); - GPtrArray *rooms; - - rooms = g_ptr_array_new_with_free_func ((GDestroyNotify) tp_value_array_free); - - /* Find 2 rooms */ - add_room (rooms); - add_room (rooms); - tp_svc_channel_type_room_list1_emit_got_rooms (self, rooms); - g_ptr_array_set_size (rooms, 0); - - /* Find 1 room */ - add_room (rooms); - tp_svc_channel_type_room_list1_emit_got_rooms (self, rooms); - g_ptr_array_unref (rooms); - - return FALSE; -} - -static void -room_list_list_rooms (TpSvcChannelTypeRoomList1 *chan, - DBusGMethodInvocation *context) -{ - TpTestsRoomListChan *self = TP_TESTS_ROOM_LIST_CHAN (chan); - - if (self->priv->listing) - { - GError error = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "Already listing" }; - - dbus_g_method_return_error (context, &error); - return; - } - - if (!tp_strdiff (self->priv->server, "ListRoomsFail")) - { - GError error = { TP_ERROR, TP_ERROR_SERVICE_CONFUSED, - "Computer says no" }; - - dbus_g_method_return_error (context, &error); - return; - } - - self->priv->listing = TRUE; - tp_svc_channel_type_room_list1_emit_listing_rooms (self, TRUE); - - g_idle_add (find_rooms, self); - - tp_svc_channel_type_room_list1_return_from_list_rooms (context); -} - -static void -room_list_iface_init (gpointer iface, - gpointer data) -{ - TpSvcChannelTypeRoomList1Class *klass = iface; - -#define IMPLEMENT(x) \ - tp_svc_channel_type_room_list1_implement_##x (klass, room_list_##x) - IMPLEMENT(list_rooms); -#undef IMPLEMENT -} diff --git a/tests/lib/room-list-chan.h b/tests/lib/room-list-chan.h deleted file mode 100644 index 52dbd2e..0000000 --- a/tests/lib/room-list-chan.h +++ /dev/null @@ -1,50 +0,0 @@ - -#ifndef __TP_TESTS_ROOM_LIST_CHAN_H__ -#define __TP_TESTS_ROOM_LIST_CHAN_H__ - -#include <glib-object.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef struct _TpTestsRoomListChan TpTestsRoomListChan; -typedef struct _TpTestsRoomListChanClass TpTestsRoomListChanClass; -typedef struct _TpTestsRoomListChanPriv TpTestsRoomListChanPriv; - -struct _TpTestsRoomListChanClass { - TpBaseChannelClass parent_class; - TpDBusPropertiesMixinClass dbus_properties_class; -}; - -struct _TpTestsRoomListChan { - TpBaseChannel parent; - TpTestsRoomListChanPriv *priv; -}; - -GType tp_tests_room_list_chan_get_type (void); - -/* TYPE MACROS */ -#define TP_TESTS_TYPE_ROOM_LIST_CHAN \ - (tp_tests_room_list_chan_get_type ()) -#define TP_TESTS_ROOM_LIST_CHAN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), \ - TP_TESTS_TYPE_ROOM_LIST_CHAN, \ - TpTestsRoomListChan)) -#define TP_TESTS_ROOM_LIST_CHAN_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), \ - TP_TESTS_TYPE_ROOM_LIST_CHAN, \ - TpTestsRoomListChanClass)) -#define TP_TESTS_IS_ROOM_LIST_CHAN(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ - TP_TESTS_TYPE_ROOM_LIST_CHAN)) -#define TP_TESTS_IS_ROOM_LIST_CHAN_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), \ - TP_TESTS_TYPE_ROOM_LIST_CHAN)) -#define TP_TESTS_ROOM_LIST_CHAN_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TP_TESTS_TYPE_ROOM_LIST_CHAN, \ - TpTestsRoomListChanClass)) - -G_END_DECLS - -#endif /* #ifndef __TP_TESTS_ROOM_LIST_CHAN_H__*/ diff --git a/tests/lib/simple-account-manager.c b/tests/lib/simple-account-manager.c deleted file mode 100644 index e5bddbc..0000000 --- a/tests/lib/simple-account-manager.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * simple-account-manager.c - a simple account manager service. - * - * Copyright (C) 2007-2012 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007-2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "simple-account-manager.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -static void account_manager_iface_init (gpointer, gpointer); - -G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleAccountManager, - tp_tests_simple_account_manager, - G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_MANAGER, - account_manager_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES, - tp_dbus_properties_mixin_iface_init) - ) - - -/* TP_IFACE_ACCOUNT_MANAGER is implied */ -static const char *ACCOUNT_MANAGER_INTERFACES[] = { NULL }; - -enum -{ - PROP_0, - PROP_INTERFACES, - PROP_USABLE_ACCOUNTS, - PROP_UNUSABLE_ACCOUNTS, -}; - -struct _TpTestsSimpleAccountManagerPrivate -{ - GPtrArray *usable_accounts; - GPtrArray *unusable_accounts; -}; - -static void -tp_tests_simple_account_manager_create_account (TpSvcAccountManager *svc, - const gchar *in_Connection_Manager, - const gchar *in_Protocol, - const gchar *in_Display_Name, - GHashTable *in_Parameters, - GHashTable *in_Properties, - DBusGMethodInvocation *context) -{ - TpTestsSimpleAccountManager *self = (TpTestsSimpleAccountManager *) svc; - const gchar *out = TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/lospolloshermanos"; - - /* if we have fail=yes as a parameter, make the call fail */ - if (!tp_strdiff (tp_asv_get_string (in_Parameters, "fail"), "yes")) - { - GError e = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "loldongs" }; - dbus_g_method_return_error (context, &e); - return; - } - - self->create_cm = g_strdup (in_Connection_Manager); - self->create_protocol = g_strdup (in_Protocol); - self->create_display_name = g_strdup (in_Display_Name); - self->create_parameters = g_hash_table_ref (in_Parameters); - self->create_properties = g_hash_table_ref (in_Properties); - - tp_svc_account_manager_return_from_create_account (context, out); -} - -static void -account_manager_iface_init (gpointer klass, - gpointer unused G_GNUC_UNUSED) -{ -#define IMPLEMENT(x) tp_svc_account_manager_implement_##x (\ - klass, tp_tests_simple_account_manager_##x) - IMPLEMENT (create_account); -#undef IMPLEMENT -} - - -static void -tp_tests_simple_account_manager_init (TpTestsSimpleAccountManager *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, TpTestsSimpleAccountManagerPrivate); - - self->priv->usable_accounts = g_ptr_array_new_with_free_func (g_free); - self->priv->unusable_accounts = g_ptr_array_new_with_free_func (g_free); -} - -static void -tp_tests_simple_account_manager_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *spec) -{ - TpTestsSimpleAccountManager *self = SIMPLE_ACCOUNT_MANAGER (object); - - switch (property_id) { - case PROP_INTERFACES: - g_value_set_boxed (value, ACCOUNT_MANAGER_INTERFACES); - break; - - case PROP_USABLE_ACCOUNTS: - g_value_set_boxed (value, self->priv->usable_accounts); - break; - - case PROP_UNUSABLE_ACCOUNTS: - g_value_set_boxed (value, self->priv->unusable_accounts); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec); - break; - } -} - -static void -tp_tests_simple_account_manager_finalize (GObject *object) -{ - TpTestsSimpleAccountManager *self = SIMPLE_ACCOUNT_MANAGER (object); - - g_ptr_array_unref (self->priv->usable_accounts); - g_ptr_array_unref (self->priv->unusable_accounts); - - tp_clear_pointer (&self->create_cm, g_free); - tp_clear_pointer (&self->create_protocol, g_free); - tp_clear_pointer (&self->create_display_name, g_free); - tp_clear_pointer (&self->create_parameters, g_hash_table_unref); - tp_clear_pointer (&self->create_properties, g_hash_table_unref); - - G_OBJECT_CLASS (tp_tests_simple_account_manager_parent_class)->finalize ( - object); -} - -/** - * This class currently only provides the minimum for - * tp_account_manager_prepare to succeed. This turns out to be only a working - * Properties.GetAll(). If we wanted later to check the case where - * tp_account_prepare succeeds, we would need to implement an account object - * too. - */ -static void -tp_tests_simple_account_manager_class_init ( - TpTestsSimpleAccountManagerClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - GParamSpec *param_spec; - - static TpDBusPropertiesMixinPropImpl am_props[] = { - { "Interfaces", "interfaces", NULL }, - { "UsableAccounts", "usable-accounts", NULL }, - { "UnusableAccounts", "unusable-accounts", NULL }, - /* - { "SupportedAccountProperties", "supported-account-properties", NULL }, - */ - { NULL } - }; - - static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = { - { TP_IFACE_ACCOUNT_MANAGER, - tp_dbus_properties_mixin_getter_gobject_properties, - NULL, - am_props - }, - { NULL }, - }; - - g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountManagerPrivate)); - object_class->finalize = tp_tests_simple_account_manager_finalize; - object_class->get_property = tp_tests_simple_account_manager_get_property; - - param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces", - "In this case we only implement AccountManager, so none.", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_INTERFACES, param_spec); - param_spec = g_param_spec_boxed ("usable-accounts", "Usable accounts", - "The accounts which are usable on this account manager. This may be a lie.", - TP_ARRAY_TYPE_OBJECT_PATH_LIST, - G_PARAM_READABLE); - g_object_class_install_property (object_class, PROP_USABLE_ACCOUNTS, param_spec); - param_spec = g_param_spec_boxed ("unusable-accounts", "Unusable accounts", - "The accounts which are unusable on this account manager. This may be a lie.", - TP_ARRAY_TYPE_OBJECT_PATH_LIST, - G_PARAM_READABLE); - g_object_class_install_property (object_class, PROP_UNUSABLE_ACCOUNTS, param_spec); - - klass->dbus_props_class.interfaces = prop_interfaces; - tp_dbus_properties_mixin_class_init (object_class, - G_STRUCT_OFFSET (TpTestsSimpleAccountManagerClass, dbus_props_class)); -} - -static void -remove_from_array (GPtrArray *array, const gchar *str) -{ - guint i; - - for (i = 0; i < array->len; i++) - if (!tp_strdiff (str, g_ptr_array_index (array, i))) - { - g_ptr_array_remove_index_fast (array, i); - return; - } -} - -void -tp_tests_simple_account_manager_add_account ( - TpTestsSimpleAccountManager *self, - const gchar *object_path, - gboolean usable) -{ - remove_from_array (self->priv->usable_accounts, object_path); - remove_from_array (self->priv->unusable_accounts, object_path); - - if (usable) - g_ptr_array_add (self->priv->usable_accounts, g_strdup (object_path)); - else - g_ptr_array_add (self->priv->unusable_accounts, g_strdup (object_path)); - - tp_svc_account_manager_emit_account_usability_changed (self, object_path, - usable); -} - -void -tp_tests_simple_account_manager_remove_account ( - TpTestsSimpleAccountManager *self, - const gchar *object_path) -{ - remove_from_array (self->priv->usable_accounts, object_path); - remove_from_array (self->priv->unusable_accounts, object_path); - - tp_svc_account_manager_emit_account_removed (self, object_path); -} diff --git a/tests/lib/simple-account-manager.h b/tests/lib/simple-account-manager.h deleted file mode 100644 index cc65f09..0000000 --- a/tests/lib/simple-account-manager.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * simple-account-manager.h - header for a simple account manager service. - * - * Copyright (C) 2007-2012 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007-2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_SIMPLE_ACCOUNT_MANAGER_H__ -#define __TP_TESTS_SIMPLE_ACCOUNT_MANAGER_H__ - -#include <glib-object.h> -#include <telepathy-glib/telepathy-glib.h> - - -G_BEGIN_DECLS - -typedef struct _TpTestsSimpleAccountManager TpTestsSimpleAccountManager; -typedef struct _TpTestsSimpleAccountManagerClass TpTestsSimpleAccountManagerClass; -typedef struct _TpTestsSimpleAccountManagerPrivate TpTestsSimpleAccountManagerPrivate; - -struct _TpTestsSimpleAccountManagerClass { - GObjectClass parent_class; - TpDBusPropertiesMixinClass dbus_props_class; -}; - -struct _TpTestsSimpleAccountManager { - GObject parent; - - gchar *create_cm; - gchar *create_protocol; - gchar *create_display_name; - GHashTable *create_parameters; - GHashTable *create_properties; - - TpTestsSimpleAccountManagerPrivate *priv; -}; - -GType tp_tests_simple_account_manager_get_type (void); - -/* TYPE MACROS */ -#define TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER \ - (tp_tests_simple_account_manager_get_type ()) -#define SIMPLE_ACCOUNT_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, \ - TpTestsSimpleAccountManager)) -#define SIMPLE_ACCOUNT_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, \ - TpTestsSimpleAccountManagerClass)) -#define SIMPLE_IS_ACCOUNT_MANAGER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER)) -#define SIMPLE_IS_ACCOUNT_MANAGER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER)) -#define SIMPLE_ACCOUNT_MANAGER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT_MANAGER, \ - TpTestsSimpleAccountManagerClass)) - -void tp_tests_simple_account_manager_add_account ( - TpTestsSimpleAccountManager *self, - const gchar *object_path, - gboolean usable); - -void tp_tests_simple_account_manager_remove_account ( - TpTestsSimpleAccountManager *self, - const gchar *object_path); - -G_END_DECLS - -#endif /* #ifndef __TP_TESTS_SIMPLE_ACCOUNT_MANAGER_H__ */ diff --git a/tests/lib/simple-account.c b/tests/lib/simple-account.c deleted file mode 100644 index 2c6131b..0000000 --- a/tests/lib/simple-account.c +++ /dev/null @@ -1,641 +0,0 @@ -/* - * simple-account.c - a simple account service. - * - * Copyright (C) 2010-2012 Collabora Ltd. <http://www.collabora.co.uk/> - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "simple-account.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -static void account_iface_init (gpointer, gpointer); - -G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleAccount, - tp_tests_simple_account, - G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT, - account_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_INTERFACE_AVATAR1, - NULL); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_INTERFACE_ADDRESSING1, - NULL); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_ACCOUNT_INTERFACE_STORAGE1, - NULL); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES, - tp_dbus_properties_mixin_iface_init) - ) - -/* TP_IFACE_ACCOUNT is implied */ -static const char *ACCOUNT_INTERFACES[] = { - TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING1, - TP_IFACE_ACCOUNT_INTERFACE_STORAGE1, - NULL }; - -enum -{ - PROP_0, - PROP_INTERFACES, - PROP_DISPLAY_NAME, - PROP_ICON, - PROP_USABLE, - PROP_ENABLED, - PROP_NICKNAME, - PROP_PARAMETERS, - PROP_AUTOMATIC_PRESENCE, - PROP_CONNECT_AUTO, - PROP_CONNECTION, - PROP_CONNECTION_STATUS, - PROP_CONNECTION_STATUS_REASON, - PROP_CURRENT_PRESENCE, - PROP_REQUESTED_PRESENCE, - PROP_NORMALIZED_NAME, - PROP_HAS_BEEN_ONLINE, - PROP_URI_SCHEMES, - PROP_STORAGE_PROVIDER, - PROP_STORAGE_IDENTIFIER, - PROP_STORAGE_SPECIFIC_INFORMATION, - PROP_STORAGE_RESTRICTIONS, - PROP_AVATAR, - PROP_SUPERSEDES, - N_PROPS -}; - -struct _TpTestsSimpleAccountPrivate -{ - TpConnectionPresenceType presence; - gchar *presence_status; - gchar *presence_msg; - gchar *connection_path; - gboolean enabled; - GPtrArray *uri_schemes; - GHashTable *parameters; -}; - -static void -tp_tests_simple_account_update_parameters (TpSvcAccount *svc, - GHashTable *parameters, - const gchar **unset_parameters, - DBusGMethodInvocation *context) -{ - GPtrArray *reconnect_required = g_ptr_array_new (); - GHashTableIter iter; - gpointer k; - guint i; - - /* We don't actually store any parameters, but for the purposes - * of this method we pretend that every parameter provided is - * valid and requires reconnection. */ - - g_hash_table_iter_init (&iter, parameters); - - while (g_hash_table_iter_next (&iter, &k, NULL)) - g_ptr_array_add (reconnect_required, k); - - for (i = 0; unset_parameters != NULL && unset_parameters[i] != NULL; i++) - g_ptr_array_add (reconnect_required, (gchar *) unset_parameters[i]); - - g_ptr_array_add (reconnect_required, NULL); - - tp_svc_account_return_from_update_parameters (context, - (const gchar **) reconnect_required->pdata); - g_ptr_array_unref (reconnect_required); -} - -static void -account_iface_init (gpointer klass, - gpointer unused G_GNUC_UNUSED) -{ -#define IMPLEMENT(x) tp_svc_account_implement_##x (\ - klass, tp_tests_simple_account_##x) - IMPLEMENT (update_parameters); -#undef IMPLEMENT -} - -/* you may have noticed this is not entirely realistic */ -static const gchar * const uri_schemes[] = { "about", "telnet", NULL }; - -static void -tp_tests_simple_account_init (TpTestsSimpleAccount *self) -{ - guint i; - - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TESTS_TYPE_SIMPLE_ACCOUNT, - TpTestsSimpleAccountPrivate); - - self->priv->presence = TP_CONNECTION_PRESENCE_TYPE_AWAY; - self->priv->presence_status = g_strdup ("currently-away"); - self->priv->presence_msg = g_strdup ("this is my CurrentPresence"); - self->priv->connection_path = g_strdup ("/"); - self->priv->enabled = TRUE; - - self->priv->uri_schemes = g_ptr_array_new_with_free_func (g_free); - for (i = 0; uri_schemes[i] != NULL; i++) - g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_schemes[i])); - - self->priv->parameters = g_hash_table_new (NULL, NULL); -} - -static void -tp_tests_simple_account_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *spec) -{ - TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object); - GValue identifier = { 0, }; - - g_value_init (&identifier, G_TYPE_STRING); - g_value_set_string (&identifier, "unique-identifier"); - - switch (property_id) { - case PROP_INTERFACES: - g_value_set_boxed (value, ACCOUNT_INTERFACES); - break; - case PROP_DISPLAY_NAME: - g_value_set_string (value, "Fake Account"); - break; - case PROP_ICON: - g_value_set_string (value, ""); - break; - case PROP_USABLE: - g_value_set_boolean (value, TRUE); - break; - case PROP_ENABLED: - g_value_set_boolean (value, self->priv->enabled); - break; - case PROP_NICKNAME: - g_value_set_string (value, "badger"); - break; - case PROP_PARAMETERS: - g_value_set_boxed (value, self->priv->parameters); - break; - case PROP_AUTOMATIC_PRESENCE: - g_value_take_boxed (value, tp_value_array_build (3, - G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, - G_TYPE_STRING, "automatically-available", - G_TYPE_STRING, "this is my AutomaticPresence", - G_TYPE_INVALID)); - break; - case PROP_CONNECT_AUTO: - g_value_set_boolean (value, FALSE); - break; - case PROP_CONNECTION: - g_value_set_boxed (value, self->priv->connection_path); - break; - case PROP_CONNECTION_STATUS: - g_value_set_uint (value, TP_CONNECTION_STATUS_CONNECTED); - break; - case PROP_CONNECTION_STATUS_REASON: - g_value_set_uint (value, TP_CONNECTION_STATUS_REASON_REQUESTED); - break; - case PROP_CURRENT_PRESENCE: - g_value_take_boxed (value, tp_value_array_build (3, - G_TYPE_UINT, self->priv->presence, - G_TYPE_STRING, self->priv->presence_status, - G_TYPE_STRING, self->priv->presence_msg, - G_TYPE_INVALID)); - break; - case PROP_REQUESTED_PRESENCE: - g_value_take_boxed (value, tp_value_array_build (3, - G_TYPE_UINT, TP_CONNECTION_PRESENCE_TYPE_BUSY, - G_TYPE_STRING, "requesting", - G_TYPE_STRING, "this is my RequestedPresence", - G_TYPE_INVALID)); - break; - case PROP_NORMALIZED_NAME: - g_value_set_string (value, "bob.mcbadgers@example.com"); - break; - case PROP_HAS_BEEN_ONLINE: - g_value_set_boolean (value, TRUE); - break; - case PROP_STORAGE_PROVIDER: - g_value_set_string (value, "im.telepathy1.glib.test"); - break; - case PROP_STORAGE_IDENTIFIER: - g_value_set_boxed (value, &identifier); - break; - case PROP_STORAGE_SPECIFIC_INFORMATION: - g_value_take_boxed (value, tp_asv_new ( - "one", G_TYPE_INT, 1, - "two", G_TYPE_UINT, 2, - "marco", G_TYPE_STRING, "polo", - NULL)); - break; - case PROP_STORAGE_RESTRICTIONS: - g_value_set_uint (value, - TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED | - TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS); - break; - case PROP_URI_SCHEMES: - { - GPtrArray *arr; - guint i; - - arr = g_ptr_array_sized_new (self->priv->uri_schemes->len + 1); - for (i = 0; i < self->priv->uri_schemes->len; i++) - g_ptr_array_add (arr, - g_ptr_array_index (self->priv->uri_schemes, i)); - g_ptr_array_add (arr, NULL); - - g_value_set_boxed (value, arr->pdata); - g_ptr_array_unref (arr); - } - break; - case PROP_AVATAR: - { - GArray *arr = g_array_new (FALSE, FALSE, sizeof (char)); - - /* includes NUL for simplicity */ - g_array_append_vals (arr, ":-)", 4); - - g_value_take_boxed (value, - tp_value_array_build (2, - TP_TYPE_UCHAR_ARRAY, arr, - G_TYPE_STRING, "text/plain", - G_TYPE_INVALID)); - g_array_unref (arr); - } - break; - case PROP_SUPERSEDES: - { - GPtrArray *arr = g_ptr_array_new (); - - g_ptr_array_add (arr, - g_strdup (TP_ACCOUNT_OBJECT_PATH_BASE "super/seded/whatever")); - g_value_take_boxed (value, arr); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec); - break; - } - - g_value_unset (&identifier); -} - -static void -tp_tests_simple_account_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *spec) -{ - TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object); - - switch (property_id) - { - case PROP_PARAMETERS: - self->priv->parameters = g_value_dup_boxed (value); - /* In principle we should be emitting AccountPropertyChanged here */ - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec); - break; - } -} - -static void -tp_tests_simple_account_finalize (GObject *object) -{ - TpTestsSimpleAccount *self = TP_TESTS_SIMPLE_ACCOUNT (object); - - g_free (self->priv->presence_status); - g_free (self->priv->presence_msg); - g_free (self->priv->connection_path); - - g_ptr_array_unref (self->priv->uri_schemes); - g_hash_table_unref (self->priv->parameters); - - G_OBJECT_CLASS (tp_tests_simple_account_parent_class)->finalize (object); -} - -/** - * This class currently only provides the minimum for - * tp_account_prepare to succeed. This turns out to be only a working - * Properties.GetAll(). - */ -static void -tp_tests_simple_account_class_init (TpTestsSimpleAccountClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - GParamSpec *param_spec; - - static TpDBusPropertiesMixinPropImpl a_props[] = { - { "Interfaces", "interfaces", NULL }, - { "DisplayName", "display-name", NULL }, - { "Icon", "icon", NULL }, - { "Usable", "usable", NULL }, - { "Enabled", "enabled", NULL }, - { "Nickname", "nickname", NULL }, - { "Parameters", "parameters", NULL }, - { "AutomaticPresence", "automatic-presence", NULL }, - { "ConnectAutomatically", "connect-automatically", NULL }, - { "Connection", "connection", NULL }, - { "ConnectionStatus", "connection-status", NULL }, - { "ConnectionStatusReason", "connection-status-reason", NULL }, - { "CurrentPresence", "current-presence", NULL }, - { "RequestedPresence", "requested-presence", NULL }, - { "NormalizedName", "normalized-name", NULL }, - { "HasBeenOnline", "has-been-online", NULL }, - { "Supersedes", "supersedes", NULL }, - { NULL } - }; - - static TpDBusPropertiesMixinPropImpl ais_props[] = { - { "StorageProvider", "storage-provider", NULL }, - { "StorageIdentifier", "storage-identifier", NULL }, - { "StorageSpecificInformation", "storage-specific-information", NULL }, - { "StorageRestrictions", "storage-restrictions", NULL }, - { NULL }, - }; - - static TpDBusPropertiesMixinPropImpl aia_props[] = { - { "URISchemes", "uri-schemes", NULL }, - { NULL }, - }; - - static TpDBusPropertiesMixinPropImpl avatar_props[] = { - { "Avatar", "avatar", NULL }, - { NULL }, - }; - - static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = { - { TP_IFACE_ACCOUNT, - tp_dbus_properties_mixin_getter_gobject_properties, - NULL, - a_props - }, - { - TP_IFACE_ACCOUNT_INTERFACE_STORAGE1, - tp_dbus_properties_mixin_getter_gobject_properties, - NULL, - ais_props - }, - { - TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING1, - tp_dbus_properties_mixin_getter_gobject_properties, - NULL, - aia_props - }, - { TP_IFACE_ACCOUNT_INTERFACE_AVATAR1, - tp_dbus_properties_mixin_getter_gobject_properties, - NULL, - avatar_props - }, - { NULL }, - }; - - g_type_class_add_private (klass, sizeof (TpTestsSimpleAccountPrivate)); - object_class->get_property = tp_tests_simple_account_get_property; - object_class->set_property = tp_tests_simple_account_set_property; - object_class->finalize = tp_tests_simple_account_finalize; - - param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces", - "In this case we only implement Account, so none.", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_INTERFACES, param_spec); - - param_spec = g_param_spec_string ("display-name", "display name", - "DisplayName property", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_DISPLAY_NAME, param_spec); - - param_spec = g_param_spec_string ("icon", "icon", - "Icon property", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_ICON, param_spec); - - param_spec = g_param_spec_boolean ("usable", "usable", - "Usable property", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_USABLE, param_spec); - - param_spec = g_param_spec_boolean ("enabled", "enabled", - "Enabled property", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_ENABLED, param_spec); - - param_spec = g_param_spec_string ("nickname", "nickname", - "Nickname property", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_NICKNAME, param_spec); - - param_spec = g_param_spec_boxed ("parameters", "parameters", - "Parameters property", - TP_HASH_TYPE_STRING_VARIANT_MAP, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_PARAMETERS, param_spec); - - param_spec = g_param_spec_boxed ("automatic-presence", "automatic presence", - "AutomaticPresence property", - TP_STRUCT_TYPE_PRESENCE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_AUTOMATIC_PRESENCE, - param_spec); - - param_spec = g_param_spec_boolean ("connect-automatically", - "connect automatically", "ConnectAutomatically property", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_CONNECT_AUTO, param_spec); - - param_spec = g_param_spec_boxed ("connection", "connection", - "Connection property", - DBUS_TYPE_G_OBJECT_PATH, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_CONNECTION, param_spec); - - param_spec = g_param_spec_uint ("connection-status", "connection status", - "ConnectionStatus property", - 0, TP_NUM_CONNECTION_STATUSES, TP_CONNECTION_STATUS_DISCONNECTED, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_CONNECTION_STATUS, - param_spec); - - param_spec = g_param_spec_uint ("connection-status-reason", - "connection status reason", "ConnectionStatusReason property", - 0, TP_NUM_CONNECTION_STATUS_REASONS, - TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_CONNECTION_STATUS_REASON, - param_spec); - - param_spec = g_param_spec_boxed ("current-presence", "current presence", - "CurrentPresence property", - TP_STRUCT_TYPE_PRESENCE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_CURRENT_PRESENCE, - param_spec); - - param_spec = g_param_spec_boxed ("requested-presence", "requested presence", - "RequestedPresence property", - TP_STRUCT_TYPE_PRESENCE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_REQUESTED_PRESENCE, - param_spec); - - param_spec = g_param_spec_string ("normalized-name", "normalized name", - "NormalizedName property", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_NORMALIZED_NAME, - param_spec); - - param_spec = g_param_spec_boolean ("has-been-online", "has been online", - "HasBeenOnline property", - FALSE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_HAS_BEEN_ONLINE, - param_spec); - - param_spec = g_param_spec_string ("storage-provider", "storage provider", - "StorageProvider property", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_STORAGE_PROVIDER, - param_spec); - - param_spec = g_param_spec_boxed ("storage-identifier", "storage identifier", - "StorageIdentifier property", - G_TYPE_VALUE, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_STORAGE_IDENTIFIER, - param_spec); - - param_spec = g_param_spec_boxed ("storage-specific-information", - "storage specific information", "StorageSpecificInformation property", - TP_HASH_TYPE_STRING_VARIANT_MAP, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - PROP_STORAGE_SPECIFIC_INFORMATION, param_spec); - - param_spec = g_param_spec_uint ("storage-restrictions", - "storage restrictions", "StorageRestrictions property", - 0, G_MAXUINT, 0, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_STORAGE_RESTRICTIONS, - param_spec); - - param_spec = g_param_spec_boxed ("uri-schemes", "URI schemes", - "Some URI schemes", - G_TYPE_STRV, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_URI_SCHEMES, param_spec); - - param_spec = g_param_spec_boxed ("avatar", - "Avatar", "Avatar", - TP_STRUCT_TYPE_AVATAR, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - PROP_AVATAR, param_spec); - - param_spec = g_param_spec_boxed ("supersedes", - "Supersedes", "List of superseded accounts", - TP_ARRAY_TYPE_OBJECT_PATH_LIST, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - PROP_SUPERSEDES, param_spec); - - klass->dbus_props_class.interfaces = prop_interfaces; - tp_dbus_properties_mixin_class_init (object_class, - G_STRUCT_OFFSET (TpTestsSimpleAccountClass, dbus_props_class)); -} - -void -tp_tests_simple_account_set_presence (TpTestsSimpleAccount *self, - TpConnectionPresenceType presence, - const gchar *status, - const gchar *message) -{ - GHashTable *props; - GValueArray *v; - - g_free (self->priv->presence_status); - g_free (self->priv->presence_msg); - - self->priv->presence = presence; - self->priv->presence_status = g_strdup (status); - self->priv->presence_msg = g_strdup (message); - - g_object_get (self, "current-presence", &v, NULL); - - props = tp_asv_new ( - "CurrentPresence", TP_STRUCT_TYPE_PRESENCE, v, - NULL); - - tp_svc_account_emit_account_property_changed (self, props); - - g_boxed_free (TP_STRUCT_TYPE_PRESENCE, v); -} - -void -tp_tests_simple_account_set_connection (TpTestsSimpleAccount *self, - const gchar *object_path) -{ - GHashTable *change; - - if (object_path == NULL) - object_path = "/"; - - g_free (self->priv->connection_path); - self->priv->connection_path = g_strdup (object_path); - - change = tp_asv_new (NULL, NULL); - tp_asv_set_string (change, "Connection", object_path); - tp_svc_account_emit_account_property_changed (self, change); - g_hash_table_unref (change); -} - -void -tp_tests_simple_account_removed (TpTestsSimpleAccount *self) -{ - tp_svc_account_emit_removed (self); -} - -void -tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self, - gboolean enabled) -{ - GHashTable *change; - - self->priv->enabled = enabled; - - change = tp_asv_new (NULL, NULL); - tp_asv_set_boolean (change, "Enabled", enabled); - tp_svc_account_emit_account_property_changed (self, change); - g_hash_table_unref (change); -} - -void -tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self, - const gchar *uri_scheme) -{ - GHashTable *changed; - GStrv schemes; - - g_ptr_array_add (self->priv->uri_schemes, g_strdup (uri_scheme)); - - g_object_get (self, "uri-schemes", &schemes, NULL); - - changed = tp_asv_new ( - "URISchemes", G_TYPE_STRV, schemes, - NULL); - - tp_svc_dbus_properties_emit_properties_changed (self, - TP_IFACE_ACCOUNT_INTERFACE_ADDRESSING1, changed, NULL); - - g_strfreev (schemes); - g_hash_table_unref (changed); -} diff --git a/tests/lib/simple-account.h b/tests/lib/simple-account.h deleted file mode 100644 index 351c6cc..0000000 --- a/tests/lib/simple-account.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * simple-account.h - header for a simple account service. - * - * Copyright (C) 2010-2012 Collabora Ltd. <http://www.collabora.co.uk/> - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_SIMPLE_ACCOUNT_H__ -#define __TP_TESTS_SIMPLE_ACCOUNT_H__ - -#include <glib-object.h> - -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef struct _TpTestsSimpleAccount TpTestsSimpleAccount; -typedef struct _TpTestsSimpleAccountClass TpTestsSimpleAccountClass; -typedef struct _TpTestsSimpleAccountPrivate TpTestsSimpleAccountPrivate; - -struct _TpTestsSimpleAccountClass { - GObjectClass parent_class; - TpDBusPropertiesMixinClass dbus_props_class; -}; - -struct _TpTestsSimpleAccount { - GObject parent; - - TpTestsSimpleAccountPrivate *priv; -}; - -GType tp_tests_simple_account_get_type (void); - -/* TYPE MACROS */ -#define TP_TESTS_TYPE_SIMPLE_ACCOUNT \ - (tp_tests_simple_account_get_type ()) -#define TP_TESTS_SIMPLE_ACCOUNT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT, \ - TpTestsSimpleAccount)) -#define TP_TESTS_SIMPLE_ACCOUNT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_SIMPLE_ACCOUNT, \ - TpTestsSimpleAccountClass)) -#define TP_TESTS_SIMPLE_IS_ACCOUNT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT)) -#define TP_TESTS_SIMPLE_IS_ACCOUNT_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_SIMPLE_ACCOUNT)) -#define TP_TESTS_SIMPLE_ACCOUNT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_SIMPLE_ACCOUNT, \ - TpTestsSimpleAccountClass)) - -void tp_tests_simple_account_set_presence (TpTestsSimpleAccount *self, - TpConnectionPresenceType presence, - const gchar *status, - const gchar *message); - -void tp_tests_simple_account_set_connection (TpTestsSimpleAccount *self, - const gchar *object_path); - -void tp_tests_simple_account_removed (TpTestsSimpleAccount *self); -void tp_tests_simple_account_set_enabled (TpTestsSimpleAccount *self, - gboolean enabled); - -void tp_tests_simple_account_add_uri_scheme (TpTestsSimpleAccount *self, - const gchar * uri_scheme); - -G_END_DECLS - -#endif /* #ifndef __TP_TESTS_SIMPLE_ACCOUNT_H__ */ diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c deleted file mode 100644 index fa7bfda..0000000 --- a/tests/lib/simple-conn.c +++ /dev/null @@ -1,456 +0,0 @@ -/* - * simple-conn.c - a simple connection - * - * Copyright (C) 2007-2010 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007-2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "simple-conn.h" - -#include <string.h> - -#include <dbus/dbus-glib.h> - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -#include "echo-chan.h" -#include "room-list-chan.h" -#include "util.h" - -static void props_iface_init (TpSvcDBusPropertiesClass *); - -G_DEFINE_TYPE_WITH_CODE (TpTestsSimpleConnection, tp_tests_simple_connection, - TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES, props_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION, NULL)) - -/* type definition stuff */ - -enum -{ - PROP_ACCOUNT = 1, - PROP_DBUS_STATUS, - N_PROPS -}; - -enum -{ - SIGNAL_GOT_ALL, - N_SIGNALS -}; - -static guint signals[N_SIGNALS] = {0}; - -struct _TpTestsSimpleConnectionPrivate -{ - gchar *account; - guint connect_source; - guint disconnect_source; - - /* TpHandle => reffed TpTestsTextChannelNull */ - GHashTable *text_channels; - TpTestsRoomListChan *room_list_chan; -}; - -static void -tp_tests_simple_connection_init (TpTestsSimpleConnection *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TP_TESTS_TYPE_SIMPLE_CONNECTION, TpTestsSimpleConnectionPrivate); - - self->priv->text_channels = g_hash_table_new_full (NULL, NULL, NULL, - (GDestroyNotify) g_object_unref); -} - -static void -get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *spec) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (object); - - switch (property_id) { - case PROP_ACCOUNT: - g_value_set_string (value, self->priv->account); - break; - case PROP_DBUS_STATUS: - { - g_value_set_uint (value, - tp_base_connection_get_status (TP_BASE_CONNECTION (self))); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec); - } -} - -static void -set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *spec) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (object); - - switch (property_id) { - case PROP_ACCOUNT: - g_free (self->priv->account); - self->priv->account = g_utf8_strdown (g_value_get_string (value), -1); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, spec); - } -} - -static void -dispose (GObject *object) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (object); - - g_hash_table_unref (self->priv->text_channels); - g_clear_object (&self->priv->room_list_chan); - - G_OBJECT_CLASS (tp_tests_simple_connection_parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (object); - - if (self->priv->connect_source != 0) - { - g_source_remove (self->priv->connect_source); - } - - if (self->priv->disconnect_source != 0) - { - g_source_remove (self->priv->disconnect_source); - } - - g_free (self->priv->account); - - G_OBJECT_CLASS (tp_tests_simple_connection_parent_class)->finalize (object); -} - -static gchar * -get_unique_connection_name (TpBaseConnection *conn) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (conn); - - return g_strdup (self->priv->account); -} - -static gchar * -tp_tests_simple_normalize_contact (TpHandleRepoIface *repo, - const gchar *id, - gpointer context, - GError **error) -{ - if (id[0] == '\0') - { - g_set_error (error, TP_ERROR, TP_ERROR_INVALID_HANDLE, - "ID must not be empty"); - return NULL; - } - - if (strchr (id, ' ') != NULL) - { - g_set_error (error, TP_ERROR, TP_ERROR_INVALID_HANDLE, - "ID must not contain spaces"); - return NULL; - } - - return g_utf8_strdown (id, -1); -} - -static void -create_handle_repos (TpBaseConnection *conn, - TpHandleRepoIface *repos[TP_NUM_HANDLE_TYPES]) -{ - repos[TP_HANDLE_TYPE_CONTACT] = tp_dynamic_handle_repo_new - (TP_HANDLE_TYPE_CONTACT, tp_tests_simple_normalize_contact, NULL); - repos[TP_HANDLE_TYPE_ROOM] = tp_dynamic_handle_repo_new - (TP_HANDLE_TYPE_ROOM, NULL, NULL); -} - -static GPtrArray * -create_channel_managers (TpBaseConnection *conn) -{ - return g_ptr_array_sized_new (0); -} - -void -tp_tests_simple_connection_inject_disconnect (TpTestsSimpleConnection *self) -{ - tp_base_connection_change_status ((TpBaseConnection *) self, - TP_CONNECTION_STATUS_DISCONNECTED, - TP_CONNECTION_STATUS_REASON_REQUESTED); -} - -static gboolean -pretend_connected (gpointer data) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (data); - TpBaseConnection *conn = (TpBaseConnection *) self; - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn, - TP_HANDLE_TYPE_CONTACT); - TpHandle self_handle; - - self_handle = tp_handle_ensure (contact_repo, self->priv->account, - NULL, NULL); - tp_base_connection_set_self_handle (conn, self_handle); - - if (tp_base_connection_get_status (conn) == TP_CONNECTION_STATUS_CONNECTING) - { - tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTED, - TP_CONNECTION_STATUS_REASON_REQUESTED); - } - - self->priv->connect_source = 0; - return FALSE; -} - -static gboolean -start_connecting (TpBaseConnection *conn, - GError **error) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (conn); - - tp_base_connection_change_status (conn, TP_CONNECTION_STATUS_CONNECTING, - TP_CONNECTION_STATUS_REASON_REQUESTED); - - /* In a real connection manager we'd ask the underlying implementation to - * start connecting, then go to state CONNECTED when finished. Here there - * isn't actually a connection, so we'll fake a connection process that - * takes time. */ - self->priv->connect_source = g_timeout_add (0, pretend_connected, self); - - return TRUE; -} - -static gboolean -pretend_disconnected (gpointer data) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (data); - - /* We are disconnected, all our channels are invalidated */ - g_hash_table_remove_all (self->priv->text_channels); - g_clear_object (&self->priv->room_list_chan); - - tp_base_connection_finish_shutdown (TP_BASE_CONNECTION (data)); - self->priv->disconnect_source = 0; - return FALSE; -} - -static void -shut_down (TpBaseConnection *conn) -{ - TpTestsSimpleConnection *self = TP_TESTS_SIMPLE_CONNECTION (conn); - - /* In a real connection manager we'd ask the underlying implementation to - * start shutting down, then call this function when finished. Here there - * isn't actually a connection, so we'll fake a disconnection process that - * takes time. */ - self->priv->disconnect_source = g_timeout_add (0, pretend_disconnected, - conn); -} - -static GPtrArray * -get_interfaces_always_present (TpBaseConnection *base) -{ - GPtrArray *interfaces; - - interfaces = TP_BASE_CONNECTION_CLASS ( - tp_tests_simple_connection_parent_class)->get_interfaces_always_present (base); - - g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS); - - return interfaces; -} - -static void -tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass) -{ - TpBaseConnectionClass *base_class = - (TpBaseConnectionClass *) klass; - GObjectClass *object_class = (GObjectClass *) klass; - GParamSpec *param_spec; - - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->dispose = dispose; - object_class->finalize = finalize; - g_type_class_add_private (klass, sizeof (TpTestsSimpleConnectionPrivate)); - - base_class->create_handle_repos = create_handle_repos; - base_class->get_unique_connection_name = get_unique_connection_name; - base_class->create_channel_managers = create_channel_managers; - base_class->start_connecting = start_connecting; - base_class->shut_down = shut_down; - - base_class->get_interfaces_always_present = get_interfaces_always_present; - - param_spec = g_param_spec_string ("account", "Account name", - "The username of this user", NULL, - G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec); - - param_spec = g_param_spec_uint ("dbus-status", - "Connection.Status", - "The connection status as visible on D-Bus (overridden so can break it)", - TP_CONNECTION_STATUS_CONNECTED, G_MAXUINT, - TP_CONNECTION_STATUS_DISCONNECTED, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_DBUS_STATUS, param_spec); - - signals[SIGNAL_GOT_ALL] = g_signal_new ("got-all", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, NULL, - G_TYPE_NONE, 0); -} - -void -tp_tests_simple_connection_set_identifier (TpTestsSimpleConnection *self, - const gchar *identifier) -{ - TpBaseConnection *conn = (TpBaseConnection *) self; - TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (conn, - TP_HANDLE_TYPE_CONTACT); - TpHandle handle = tp_handle_ensure (contact_repo, identifier, NULL, NULL); - - /* if this fails then the identifier was bad - caller error */ - g_return_if_fail (handle != 0); - - tp_base_connection_set_self_handle (conn, handle); -} - -TpTestsSimpleConnection * -tp_tests_simple_connection_new (const gchar *account, - const gchar *protocol) -{ - return TP_TESTS_SIMPLE_CONNECTION (g_object_new ( - TP_TESTS_TYPE_SIMPLE_CONNECTION, - "account", account, - "protocol", protocol, - NULL)); -} - -gchar * -tp_tests_simple_connection_ensure_text_chan (TpTestsSimpleConnection *self, - const gchar *target_id, - GHashTable **props) -{ - TpTestsEchoChannel *chan; - gchar *chan_path; - TpHandleRepoIface *contact_repo; - TpHandle handle; - TpBaseConnection *base_conn = (TpBaseConnection *) self; - - /* Get contact handle */ - contact_repo = tp_base_connection_get_handles (base_conn, - TP_HANDLE_TYPE_CONTACT); - g_assert (contact_repo != NULL); - - handle = tp_handle_ensure (contact_repo, target_id, NULL, NULL); - - chan = g_hash_table_lookup (self->priv->text_channels, - GUINT_TO_POINTER (handle)); - if (chan == NULL) - { - chan = TP_TESTS_ECHO_CHANNEL ( - tp_tests_object_new_static_class ( - TP_TESTS_TYPE_ECHO_CHANNEL, - "connection", self, - "handle", handle, - NULL)); - - g_hash_table_insert (self->priv->text_channels, GUINT_TO_POINTER (handle), - chan); - } - - g_object_get (chan, "object-path", &chan_path, NULL); - - if (props != NULL) - g_object_get (chan, "channel-properties", props, NULL); - - return chan_path; -} - -static void -room_list_chan_closed_cb (TpBaseChannel *channel, - TpTestsSimpleConnection *self) -{ - g_clear_object (&self->priv->room_list_chan); -} - -gchar * -tp_tests_simple_connection_ensure_room_list_chan (TpTestsSimpleConnection *self, - const gchar *server, - GHashTable **props) -{ - gchar *chan_path; - TpBaseConnection *base_conn = (TpBaseConnection *) self; - - if (self->priv->room_list_chan != NULL) - { - /* Channel already exist, reuse it */ - g_object_get (self->priv->room_list_chan, - "object-path", &chan_path, NULL); - } - else - { - chan_path = g_strdup_printf ("%s/RoomListChannel", - tp_base_connection_get_object_path (base_conn)); - - self->priv->room_list_chan = TP_TESTS_ROOM_LIST_CHAN ( - tp_tests_object_new_static_class ( - TP_TESTS_TYPE_ROOM_LIST_CHAN, - "connection", self, - "object-path", chan_path, - "server", server ? server : "", - NULL)); - - g_signal_connect (self->priv->room_list_chan, "closed", - G_CALLBACK (room_list_chan_closed_cb), self); - } - - if (props != NULL) - g_object_get (self->priv->room_list_chan, - "channel-properties", props, NULL); - - return chan_path; -} - -static void -get_all (TpSvcDBusProperties *iface, - const gchar *interface_name, - DBusGMethodInvocation *context) -{ - GHashTable *values = tp_dbus_properties_mixin_dup_all (G_OBJECT (iface), - interface_name); - - tp_svc_dbus_properties_return_from_get_all (context, values); - g_hash_table_unref (values); - g_signal_emit (iface, signals[SIGNAL_GOT_ALL], - g_quark_from_string (interface_name)); -} - -static void -props_iface_init (TpSvcDBusPropertiesClass *iface) -{ -#define IMPLEMENT(x) \ - tp_svc_dbus_properties_implement_##x (iface, x) - IMPLEMENT (get_all); -#undef IMPLEMENT -} diff --git a/tests/lib/simple-conn.h b/tests/lib/simple-conn.h deleted file mode 100644 index ffe5778..0000000 --- a/tests/lib/simple-conn.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * simple-conn.h - header for a simple connection - * - * Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright (C) 2007-2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_SIMPLE_CONN_H__ -#define __TP_TESTS_SIMPLE_CONN_H__ - -#include <glib-object.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef struct _TpTestsSimpleConnection TpTestsSimpleConnection; -typedef struct _TpTestsSimpleConnectionClass TpTestsSimpleConnectionClass; -typedef struct _TpTestsSimpleConnectionPrivate TpTestsSimpleConnectionPrivate; - -struct _TpTestsSimpleConnectionClass { - TpBaseConnectionClass parent_class; -}; - -struct _TpTestsSimpleConnection { - TpBaseConnection parent; - - TpTestsSimpleConnectionPrivate *priv; -}; - -GType tp_tests_simple_connection_get_type (void); - -/* TYPE MACROS */ -#define TP_TESTS_TYPE_SIMPLE_CONNECTION \ - (tp_tests_simple_connection_get_type ()) -#define TP_TESTS_SIMPLE_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TESTS_TYPE_SIMPLE_CONNECTION, \ - TpTestsSimpleConnection)) -#define TP_TESTS_SIMPLE_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TP_TESTS_TYPE_SIMPLE_CONNECTION, \ - TpTestsSimpleConnectionClass)) -#define TP_TESTS_SIMPLE_IS_CONNECTION(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TESTS_TYPE_SIMPLE_CONNECTION)) -#define TP_TESTS_SIMPLE_IS_CONNECTION_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TESTS_TYPE_SIMPLE_CONNECTION)) -#define TP_TESTS_SIMPLE_CONNECTION_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TESTS_TYPE_SIMPLE_CONNECTION, \ - TpTestsSimpleConnectionClass)) - -TpTestsSimpleConnection * tp_tests_simple_connection_new (const gchar *account, - const gchar *protocol); - -/* Cause "network events", for debugging/testing */ - -void tp_tests_simple_connection_inject_disconnect ( - TpTestsSimpleConnection *self); - -void tp_tests_simple_connection_set_identifier (TpTestsSimpleConnection *self, - const gchar *identifier); - -gchar * tp_tests_simple_connection_ensure_text_chan ( - TpTestsSimpleConnection *self, - const gchar *target_id, - GHashTable **props); - -gchar * tp_tests_simple_connection_ensure_room_list_chan ( - TpTestsSimpleConnection *self, - const gchar *server, - GHashTable **props); - -G_END_DECLS - -#endif /* #ifndef __TP_TESTS_SIMPLE_CONN_H__ */ diff --git a/tests/lib/util.c b/tests/lib/util.c deleted file mode 100644 index 67af4e0..0000000 --- a/tests/lib/util.c +++ /dev/null @@ -1,712 +0,0 @@ -/* Simple utility code used by the regression tests. - * - * Copyright © 2008-2010 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright © 2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#include "config.h" - -#include "util.h" - -#include <telepathy-glib/telepathy-glib.h> -#include <telepathy-glib/telepathy-glib-dbus.h> - -#include <glib/gstdio.h> -#include <string.h> - -#ifdef G_OS_UNIX -# include <unistd.h> /* for alarm() */ -#endif - -#ifdef HAVE_GIO_UNIX -#include <gio/gunixsocketaddress.h> -#include <gio/gunixconnection.h> -#endif - -void -tp_tests_proxy_run_until_prepared (gpointer proxy, - const GQuark *features) -{ - GError *error = NULL; - - tp_tests_proxy_run_until_prepared_or_failed (proxy, features, &error); - g_assert_no_error (error); -} - -/* A GAsyncReadyCallback whose user_data is a GAsyncResult **. It writes a - * reference to the result into that pointer. */ -void -tp_tests_result_ready_cb (GObject *object, - GAsyncResult *res, - gpointer user_data) -{ - GAsyncResult **result = user_data; - - *result = g_object_ref (res); -} - -/* Run until *result contains a result. Intended to be used with a pending - * async call that uses tp_tests_result_ready_cb. */ -void -tp_tests_run_until_result (GAsyncResult **result) -{ - /* not synchronous */ - g_assert (*result == NULL); - - while (*result == NULL) - g_main_context_iteration (NULL, TRUE); -} - -gboolean -tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy, - const GQuark *features, - GError **error) -{ - GAsyncResult *result = NULL; - gboolean r; - - tp_proxy_prepare_async (proxy, features, tp_tests_result_ready_cb, &result); - - tp_tests_run_until_result (&result); - - r = tp_proxy_prepare_finish (proxy, result, error); - g_object_unref (result); - return r; -} - -static GTestDBus *test_dbus = NULL; - -static void -start_dbus_session (void) -{ - g_assert (test_dbus == NULL); - - g_type_init (); - - /* Make sure we won't be using user's bus. This unsets more than - * g_test_dbus_unset() currently does (glib 2.36) */ - g_unsetenv ("DISPLAY"); - g_unsetenv ("DBUS_STARTER_ADDRESS"); - g_unsetenv ("DBUS_STARTER_BUS_TYPE"); - g_unsetenv ("DBUS_SESSION_BUS_ADDRESS"); - - test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE); - g_test_dbus_add_service_dir (test_dbus, g_getenv ("TP_TESTS_SERVICES_DIR")); - g_test_dbus_up (test_dbus); -} - -static void -stop_dbus_session (void) -{ - g_assert (test_dbus != NULL); - g_test_dbus_down (test_dbus); - g_clear_object (&test_dbus); -} - -gint -tp_tests_run_with_bus (void) -{ - gint ret; - - if (test_dbus != NULL) - return g_test_run (); - - start_dbus_session (); - ret = g_test_run (); - stop_dbus_session (); - - return ret; -} - -TpDBusDaemon * -tp_tests_dbus_daemon_dup_or_die (void) -{ - TpDBusDaemon *d; - - if (test_dbus == NULL) - { - /* HACK: Some tests are not yet ported to GTest and thus are not using - * tp_tests_run_with_bus(). In that case we make sure to start the dbus - * session before aquiring the TpDBusDaemon and we stop the session when - * the daemon is disposed. In a perfect world this should not be needed. - */ - start_dbus_session (); - d = tp_dbus_daemon_dup (NULL); - g_object_weak_ref ((GObject *) d, (GWeakNotify) stop_dbus_session, NULL); - } - else - { - d = tp_dbus_daemon_dup (NULL); - } - - /* In a shared library, this would be very bad (see fd.o #18832), but in a - * regression test that's going to be run under a temporary session bus, - * it's just what we want. */ - if (d == NULL) - { - g_error ("Unable to connect to session bus"); - } - - return d; -} - -static void -introspect_cb (TpProxy *proxy G_GNUC_UNUSED, - const gchar *xml G_GNUC_UNUSED, - const GError *error G_GNUC_UNUSED, - gpointer user_data, - GObject *weak_object G_GNUC_UNUSED) -{ - g_main_loop_quit (user_data); -} - -void -tp_tests_proxy_run_until_dbus_queue_processed (gpointer proxy) -{ - GMainLoop *loop = g_main_loop_new (NULL, FALSE); - - tp_cli_dbus_introspectable_call_introspect (proxy, -1, introspect_cb, - loop, NULL, NULL); - g_main_loop_run (loop); - g_main_loop_unref (loop); -} - -void -_test_assert_empty_strv (const char *file, - int line, - gconstpointer strv) -{ - const gchar * const *strings = strv; - - if (strv != NULL && strings[0] != NULL) - { - guint i; - - g_message ("%s:%d: expected empty strv, but got:", file, line); - - for (i = 0; strings[i] != NULL; i++) - { - g_message ("* \"%s\"", strings[i]); - } - - g_error ("%s:%d: strv wasn't empty (see above for contents", - file, line); - } -} - -void -_tp_tests_assert_strv_equals (const char *file, - int line, - const char *expected_desc, - gconstpointer expected_strv, - const char *actual_desc, - gconstpointer actual_strv) -{ - const gchar * const *expected = expected_strv; - const gchar * const *actual = actual_strv; - guint i; - - g_assert (expected != NULL); - g_assert (actual != NULL); - - for (i = 0; expected[i] != NULL || actual[i] != NULL; i++) - { - if (expected[i] == NULL) - { - g_error ("%s:%d: assertion failed: (%s)[%u] == (%s)[%u]: " - "NULL == %s", file, line, expected_desc, i, - actual_desc, i, actual[i]); - } - else if (actual[i] == NULL) - { - g_error ("%s:%d: assertion failed: (%s)[%u] == (%s)[%u]: " - "%s == NULL", file, line, expected_desc, i, - actual_desc, i, expected[i]); - } - else if (tp_strdiff (expected[i], actual[i])) - { - g_error ("%s:%d: assertion failed: (%s)[%u] == (%s)[%u]: " - "%s == %s", file, line, expected_desc, i, - actual_desc, i, expected[i], actual[i]); - } - } -} - -void -_tp_tests_assert_bytes_equal (const gchar *file, int line, - GBytes *actual, gconstpointer expected_data, - gsize expected_length) -{ - if (expected_length != g_bytes_get_size (actual)) - { - g_error ("%s:%d: assertion failed: expected %"G_GSIZE_FORMAT - " bytes, got %"G_GSIZE_FORMAT, - file, line, expected_length, g_bytes_get_size (actual)); - } - else if (memcmp (g_bytes_get_data (actual, NULL), - expected_data, expected_length) != 0) - { - g_error ( - "%s:%d: assertion failed: expected data didn't match the actual data", - file, line); - } -} - -void -tp_tests_create_conn (GType conn_type, - const gchar *account, - gboolean connect, - TpBaseConnection **service_conn, - TpConnection **client_conn) -{ - TpDBusDaemon *dbus; - gchar *name; - gchar *conn_path; - GError *error = NULL; - - g_assert (service_conn != NULL); - g_assert (client_conn != NULL); - - dbus = tp_tests_dbus_daemon_dup_or_die (); - - *service_conn = tp_tests_object_new_static_class ( - conn_type, - "account", account, - "protocol", "simple", - NULL); - g_assert (*service_conn != NULL); - - g_assert (tp_base_connection_register (*service_conn, "simple", - &name, &conn_path, &error)); - g_assert_no_error (error); - - *client_conn = tp_tests_connection_new (dbus, NULL, conn_path, &error); - g_assert (*client_conn != NULL); - g_assert_no_error (error); - - if (connect) - { - GQuark conn_features[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 }; - - tp_cli_connection_call_connect (*client_conn, -1, NULL, NULL, NULL, NULL); - tp_tests_proxy_run_until_prepared (*client_conn, conn_features); - } - - g_free (name); - g_free (conn_path); - - g_object_unref (dbus); -} - -void -tp_tests_create_and_connect_conn (GType conn_type, - const gchar *account, - TpBaseConnection **service_conn, - TpConnection **client_conn) -{ - tp_tests_create_conn (conn_type, account, TRUE, service_conn, client_conn); -} - -/* This object exists solely so that tests/tests.supp can ignore "leaked" - * classes. */ -gpointer -tp_tests_object_new_static_class (GType type, - ...) -{ - va_list ap; - GObject *object; - const gchar *first_property; - - va_start (ap, type); - first_property = va_arg (ap, const gchar *); - object = g_object_new_valist (type, first_property, ap); - va_end (ap); - return object; -} - -static gboolean -time_out (gpointer nil G_GNUC_UNUSED) -{ - g_error ("Timed out"); - g_assert_not_reached (); - return FALSE; -} - -void -tp_tests_abort_after (guint sec) -{ - gboolean debugger = FALSE; - gchar *contents; - - if (g_file_get_contents ("/proc/self/status", &contents, NULL, NULL)) - { -/* http://www.youtube.com/watch?v=SXmv8quf_xM */ -#define TRACER_T "\nTracerPid:\t" - gchar *line = strstr (contents, TRACER_T); - - if (line != NULL) - { - gchar *value = line + strlen (TRACER_T); - - if (value[0] != '0' || value[1] != '\n') - debugger = TRUE; - } - - g_free (contents); - } - - if (g_getenv ("TP_TESTS_NO_TIMEOUT") != NULL || debugger) - return; - - g_timeout_add_seconds (sec, time_out, NULL); - -#ifdef G_OS_UNIX - /* On Unix, we can kill the process more reliably; this is a safety-catch - * in case it deadlocks or something, in which case the main loop won't be - * processed. The default handler for SIGALRM is process termination. */ - alarm (sec + 2); -#endif -} - -void -tp_tests_init (int *argc, - char ***argv) -{ - g_type_init (); - tp_tests_abort_after (10); - tp_debug_set_flags ("all"); - - g_test_init (argc, argv, NULL); -} - -void -_tp_destroy_socket_control_list (gpointer data) -{ - GArray *tab = data; - g_array_unref (tab); -} - -GValue * -_tp_create_local_socket (TpSocketAddressType address_type, - TpSocketAccessControl access_control, - GSocketService **service, - gchar **unix_address, - gchar **unix_tmpdir, - GError **error) -{ - gboolean success; - GSocketAddress *address, *effective_address; - GValue *address_gvalue; - - g_assert (service != NULL); - g_assert (unix_address != NULL); - - switch (access_control) - { - case TP_SOCKET_ACCESS_CONTROL_LOCALHOST: - case TP_SOCKET_ACCESS_CONTROL_CREDENTIALS: - case TP_SOCKET_ACCESS_CONTROL_PORT: - break; - - default: - g_assert_not_reached (); - } - - switch (address_type) - { -#ifdef HAVE_GIO_UNIX - case TP_SOCKET_ADDRESS_TYPE_UNIX: - { - GError *e = NULL; - gchar *dir = g_dir_make_tmp ("tp-glib-tests.XXXXXX", &e); - gchar *name; - - g_assert_no_error (e); - - name = g_build_filename (dir, "s", NULL); - address = g_unix_socket_address_new (name); - g_free (name); - - if (unix_tmpdir != NULL) - *unix_tmpdir = dir; - else - g_free (dir); - break; - } -#endif - - case TP_SOCKET_ADDRESS_TYPE_IPV4: - case TP_SOCKET_ADDRESS_TYPE_IPV6: - { - GInetAddress *localhost; - - localhost = g_inet_address_new_loopback ( - address_type == TP_SOCKET_ADDRESS_TYPE_IPV4 ? - G_SOCKET_FAMILY_IPV4 : G_SOCKET_FAMILY_IPV6); - address = g_inet_socket_address_new (localhost, 0); - - g_object_unref (localhost); - break; - } - - default: - g_assert_not_reached (); - } - - *service = g_socket_service_new (); - - success = g_socket_listener_add_address ( - G_SOCKET_LISTENER (*service), - address, G_SOCKET_TYPE_STREAM, - G_SOCKET_PROTOCOL_DEFAULT, - NULL, &effective_address, NULL); - g_assert (success); - - switch (address_type) - { -#ifdef HAVE_GIO_UNIX - case TP_SOCKET_ADDRESS_TYPE_UNIX: - *unix_address = g_strdup (g_unix_socket_address_get_path ( - G_UNIX_SOCKET_ADDRESS (effective_address))); - address_gvalue = tp_g_value_slice_new_bytes ( - g_unix_socket_address_get_path_len ( - G_UNIX_SOCKET_ADDRESS (effective_address)), - g_unix_socket_address_get_path ( - G_UNIX_SOCKET_ADDRESS (effective_address))); - break; -#endif - - case TP_SOCKET_ADDRESS_TYPE_IPV4: - case TP_SOCKET_ADDRESS_TYPE_IPV6: - *unix_address = NULL; - - address_gvalue = tp_g_value_slice_new_take_boxed ( - TP_STRUCT_TYPE_SOCKET_ADDRESS_IPV4, - dbus_g_type_specialized_construct ( - TP_STRUCT_TYPE_SOCKET_ADDRESS_IPV4)); - - dbus_g_type_struct_set (address_gvalue, - 0, address_type == TP_SOCKET_ADDRESS_TYPE_IPV4 ? - "127.0.0.1" : "::1", - 1, g_inet_socket_address_get_port ( - G_INET_SOCKET_ADDRESS (effective_address)), - G_MAXUINT); - break; - - default: - g_assert_not_reached (); - } - - g_object_unref (address); - g_object_unref (effective_address); - return address_gvalue; -} - -void -tp_tests_connection_assert_disconnect_succeeds (TpConnection *connection) -{ - GAsyncResult *result = NULL; - GError *error = NULL; - gboolean ok; - - tp_connection_disconnect_async (connection, tp_tests_result_ready_cb, - &result); - tp_tests_run_until_result (&result); - ok = tp_connection_disconnect_finish (connection, result, &error); - g_assert_no_error (error); - g_assert (ok); - g_object_unref (result); -} - -static void -one_contact_cb (GObject *object, - GAsyncResult *result, - gpointer user_data) -{ - TpConnection *connection = (TpConnection *) object; - TpContact **contact_loc = user_data; - GError *error = NULL; - - *contact_loc = tp_connection_dup_contact_by_id_finish (connection, result, - &error); - - g_assert_no_error (error); - g_assert (TP_IS_CONTACT (*contact_loc)); -} - -TpContact * -tp_tests_connection_run_until_contact_by_id (TpConnection *connection, - const gchar *id, - const GQuark *features) -{ - TpContact *contact = NULL; - - tp_connection_dup_contact_by_id_async (connection, id, features, - one_contact_cb, &contact); - - while (contact == NULL) - g_main_context_iteration (NULL, TRUE); - - return contact; -} - -void -tp_tests_channel_assert_expect_members (TpChannel *channel, - TpIntset *expected_members) -{ - GPtrArray *contacts; - TpIntset *members; - guint i; - - members = tp_intset_new (); - contacts = tp_channel_group_dup_members (channel); - if (contacts != NULL) - { - for (i = 0; i < contacts->len; i++) - { - TpContact *contact = g_ptr_array_index (contacts, i); - tp_intset_add (members, tp_contact_get_handle (contact)); - } - } - - g_assert (tp_intset_is_equal (members, expected_members)); - - g_ptr_array_unref (contacts); - tp_intset_destroy (members); -} - -TpConnection * -tp_tests_connection_new (TpDBusDaemon *dbus, - const gchar *bus_name, - const gchar *object_path, - GError **error) -{ - TpClientFactory *factory; - gchar *dup_path = NULL; - TpConnection *ret = NULL; - - g_return_val_if_fail (TP_IS_DBUS_DAEMON (dbus), NULL); - g_return_val_if_fail (object_path != NULL || - (bus_name != NULL && bus_name[0] != ':'), NULL); - - if (object_path == NULL) - { - dup_path = g_strdelimit (g_strdup_printf ("/%s", bus_name), ".", '/'); - object_path = dup_path; - } - - if (!tp_dbus_check_valid_object_path (object_path, error)) - goto finally; - - factory = tp_automatic_client_factory_new (dbus); - ret = tp_client_factory_ensure_connection (factory, - object_path, NULL, error); - g_object_unref (factory); - -finally: - g_free (dup_path); - - return ret; -} - -TpAccount * -tp_tests_account_new (TpDBusDaemon *dbus, - const gchar *object_path, - GError **error) -{ - TpClientFactory *factory; - TpAccount *ret; - - if (!tp_dbus_check_valid_object_path (object_path, error)) - return NULL; - - factory = tp_automatic_client_factory_new (dbus); - ret = tp_client_factory_ensure_account (factory, - object_path, NULL, error); - g_object_unref (factory); - - return ret; -} - -TpChannel * -tp_tests_channel_new (TpConnection *conn, - const gchar *object_path, - const gchar *optional_channel_type, - TpHandleType optional_handle_type, - TpHandle optional_handle, - GError **error) -{ - TpChannel *ret; - GHashTable *asv; - - asv = tp_asv_new (NULL, NULL); - - if (optional_channel_type != NULL) - { - tp_asv_set_string (asv, - TP_PROP_CHANNEL_CHANNEL_TYPE, optional_channel_type); - } - if (optional_handle_type != TP_HANDLE_TYPE_NONE) - { - tp_asv_set_uint32 (asv, - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, optional_handle_type); - } - if (optional_handle != 0) - { - tp_asv_set_uint32 (asv, - TP_PROP_CHANNEL_TARGET_HANDLE, optional_handle); - } - - ret = tp_tests_channel_new_from_properties (conn, object_path, asv, error); - - g_hash_table_unref (asv); - - return ret; -} - -TpChannel * -tp_tests_channel_new_from_properties (TpConnection *conn, - const gchar *object_path, - const GHashTable *immutable_properties, - GError **error) -{ - TpClientFactory *factory; - - if (!tp_dbus_check_valid_object_path (object_path, error)) - return NULL; - - factory = tp_proxy_get_factory (conn); - return tp_client_factory_ensure_channel (factory, conn, - object_path, immutable_properties, error); -} - -void -tp_tests_add_channel_to_ptr_array (GPtrArray *arr, - TpChannel *channel) -{ - GValueArray *tmp; - GVariant *variant; - GValue v = G_VALUE_INIT; - GHashTable *asv; - - g_assert (arr != NULL); - g_assert (channel != NULL); - - variant = tp_channel_dup_immutable_properties (channel); - dbus_g_value_parse_g_variant (variant, &v); - asv = g_value_get_boxed (&v); - - tmp = tp_value_array_build (2, - DBUS_TYPE_G_OBJECT_PATH, tp_proxy_get_object_path (channel), - TP_HASH_TYPE_STRING_VARIANT_MAP, asv, - G_TYPE_INVALID); - - g_ptr_array_add (arr, tmp); - g_variant_unref (variant); - g_value_unset (&v); -} - diff --git a/tests/lib/util.h b/tests/lib/util.h deleted file mode 100644 index 183e00f..0000000 --- a/tests/lib/util.h +++ /dev/null @@ -1,112 +0,0 @@ -/* Simple utility code used by the regression tests. - * - * Copyright © 2008-2010 Collabora Ltd. <http://www.collabora.co.uk/> - * Copyright © 2008 Nokia Corporation - * - * Copying and distribution of this file, with or without modification, - * are permitted in any medium without royalty provided the copyright - * notice and this notice are preserved. - */ - -#ifndef __TP_TESTS_LIB_UTIL_H__ -#define __TP_TESTS_LIB_UTIL_H__ - -#include <telepathy-glib/telepathy-glib.h> - -gint tp_tests_run_with_bus (void); - -TpDBusDaemon *tp_tests_dbus_daemon_dup_or_die (void); - -void tp_tests_proxy_run_until_dbus_queue_processed (gpointer proxy); - -void tp_tests_proxy_run_until_prepared (gpointer proxy, - const GQuark *features); -gboolean tp_tests_proxy_run_until_prepared_or_failed (gpointer proxy, - const GQuark *features, - GError **error); - -#define test_assert_empty_strv(strv) \ - _test_assert_empty_strv (__FILE__, __LINE__, strv) -void _test_assert_empty_strv (const char *file, int line, gconstpointer strv); - -#define tp_tests_assert_strv_equals(actual, expected) \ - _tp_tests_assert_strv_equals (__FILE__, __LINE__, \ - #actual, actual, \ - #expected, expected) -void _tp_tests_assert_strv_equals (const char *file, int line, - const char *actual_desc, gconstpointer actual_strv, - const char *expected_desc, gconstpointer expected_strv); - -#define tp_tests_assert_bytes_equals(actual, expected, expected_length) \ - _tp_tests_assert_bytes_equal (__FILE__, __LINE__, \ - actual, expected, expected_length) -void _tp_tests_assert_bytes_equal (const gchar *file, int line, - GBytes *actual, gconstpointer expected_data, gsize expected_length); - -void tp_tests_create_conn (GType conn_type, - const gchar *account, - gboolean connect, - TpBaseConnection **service_conn, - TpConnection **client_conn); - -void tp_tests_create_and_connect_conn (GType conn_type, - const gchar *account, - TpBaseConnection **service_conn, - TpConnection **client_conn); - -gpointer tp_tests_object_new_static_class (GType type, - ...) G_GNUC_NULL_TERMINATED; - -void tp_tests_run_until_result (GAsyncResult **result); -void tp_tests_result_ready_cb (GObject *object, - GAsyncResult *res, gpointer user_data); - -void tp_tests_abort_after (guint sec); - -void tp_tests_init (int *argc, - char ***argv); - -GValue *_tp_create_local_socket (TpSocketAddressType address_type, - TpSocketAccessControl access_control, - GSocketService **service, - gchar **unix_address, - gchar **unix_tmpdir, - GError **error); - -void _tp_destroy_socket_control_list (gpointer data); - -void tp_tests_connection_assert_disconnect_succeeds (TpConnection *connection); - -TpContact *tp_tests_connection_run_until_contact_by_id ( - TpConnection *connection, - const gchar *id, - const GQuark *features); - -void tp_tests_channel_assert_expect_members (TpChannel *channel, - TpIntset *expected_members); - -TpConnection *tp_tests_connection_new (TpDBusDaemon *dbus, - const gchar *bus_name, - const gchar *object_path, - GError **error); - -TpAccount *tp_tests_account_new (TpDBusDaemon *dbus, - const gchar *object_path, - GError **error); - -TpChannel *tp_tests_channel_new (TpConnection *conn, - const gchar *object_path, - const gchar *optional_channel_type, - TpHandleType optional_handle_type, - TpHandle optional_handle, - GError **error); - -TpChannel *tp_tests_channel_new_from_properties (TpConnection *conn, - const gchar *object_path, - const GHashTable *immutable_properties, - GError **error); - -void tp_tests_add_channel_to_ptr_array (GPtrArray *arr, - TpChannel *channel); - -#endif /* #ifndef __TP_TESTS_LIB_UTIL_H__ */ diff --git a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100113.log b/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100113.log deleted file mode 100644 index ea42828..0000000 --- a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100113.log +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100113T17:47:57' cm_id='123' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>1</message> -<message time='20100113T17:48:01' cm_id='123' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>2</message> -<message time='20100113T17:49:10' cm_id='123' id='user2@collabora.co.uk' name='User2' token='' isuser='false' type='normal'>3</message> -<message time='20100113T17:51:55' cm_id='123' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>4</message> -<message time='20100113T17:52:58' cm_id='1263405178' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>5</message> -<message time='20100113T17:53:23' cm_id='1263405203' id='user2@collabora.co.uk' name='User2' token='' isuser='false' type='normal'>6</message> -</log> diff --git a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100208.log b/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100208.log deleted file mode 100644 index c85340b..0000000 --- a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100208.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100208T11:58:54' cm_id='1265630334' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>1</message> -</log> diff --git a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100216.log b/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100216.log deleted file mode 100644 index 2aa9ee2..0000000 --- a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100216.log +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100216T13:43:12' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>fooooo</message> -<message time='20100216T13:43:24' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>123123</message> -<message time='20100216T13:43:31' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>123</message> -<message time='20100216T13:45:44' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>gna2</message> -<message time='20100216T14:10:59' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>prova 3</message> -<message time='20100216T14:13:48' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>123</message> -<message time='20100216T15:51:28' cm_id='1266335488' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>1</message> -<message time='20100216T15:52:36' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>1</message> -<message time='20100216T15:56:43' cm_id='1266335803' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>a</message> -<message time='20100216T15:57:30' cm_id='0' id='user2@collabora.co.uk' name='User2' token='' isuser='false' type='normal'>bar</message> -</log> diff --git a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100217.log b/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100217.log deleted file mode 100644 index 46804f6..0000000 --- a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100217.log +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100217T13:47:31' cm_id='1266414451' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>1</message> -<message time='20100217T15:49:41' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>123</message> -<message time='20100217T15:49:57' cm_id='1266421797' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>321</message> -<message time='20100217T16:52:45' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>1</message> -<message time='20100217T16:52:46' cm_id='1' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>2</message> -<message time='20100217T16:52:46' cm_id='2' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>3</message> -<message time='20100217T16:52:46' cm_id='3' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>4</message> -<message time='20100217T16:52:46' cm_id='4' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>5</message> -<message time='20100217T16:52:51' cm_id='1266425571' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>1</message> -<message time='20100217T16:52:52' cm_id='1266425572' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>3</message> -<message time='20100217T16:52:46' cm_id='1' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>2</message> -<message time='20100217T16:52:46' cm_id='2' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>3</message> -<message time='20100217T16:52:46' cm_id='3' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>4</message> -<message time='20100217T16:52:46' cm_id='4' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>5</message> -<message time='20100217T16:53:06' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>3</message> -</log> diff --git a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100218.log b/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100218.log deleted file mode 100644 index 6cdb627..0000000 --- a/tests/logs/Empathy/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100218.log +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100218T14:32:14' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>now</message> -<message time='20100218T14:35:11' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>1</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_test2_40collabora_2eco_2euk0/chatrooms/meego@conference.collabora.co.uk/20110112.log b/tests/logs/TpLogger/logs/gabble_jabber_test2_40collabora_2eco_2euk0/chatrooms/meego@conference.collabora.co.uk/20110112.log deleted file mode 100644 index b4b2a3b..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_test2_40collabora_2eco_2euk0/chatrooms/meego@conference.collabora.co.uk/20110112.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="log-store-xml.xsl"?> -<log> -<message time='20110112T22:11:04' cm_id='8957fb4064049e7a1f9d8f84234d3bf09fb6778c' id='meego@conference.collabora.co.uk/test2@collabora.co.uk' name='test2@collabora.co.uk' token='' isuser='true' type='normal'>test</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_test2_40collabora_2eco_2euk0/derek.foreman@collabora.co.uk/20110210.log b/tests/logs/TpLogger/logs/gabble_jabber_test2_40collabora_2eco_2euk0/derek.foreman@collabora.co.uk/20110210.log deleted file mode 100644 index aa63a58..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_test2_40collabora_2eco_2euk0/derek.foreman@collabora.co.uk/20110210.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="log-store-xml.xsl"?> -<log> -<message time='20110210T11:21:01' cm_id='f95e605a3ae97c463b626a3538567bc90fc58730' id='test2@test.collabora.co.uk' name='test2@test.collabora.co.uk' token='' isuser='true' type='normal'>Hey, Just generating logs, don't bother replying ;)</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100113.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100113.log deleted file mode 100644 index ea42828..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100113.log +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100113T17:47:57' cm_id='123' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>1</message> -<message time='20100113T17:48:01' cm_id='123' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>2</message> -<message time='20100113T17:49:10' cm_id='123' id='user2@collabora.co.uk' name='User2' token='' isuser='false' type='normal'>3</message> -<message time='20100113T17:51:55' cm_id='123' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>4</message> -<message time='20100113T17:52:58' cm_id='1263405178' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>5</message> -<message time='20100113T17:53:23' cm_id='1263405203' id='user2@collabora.co.uk' name='User2' token='' isuser='false' type='normal'>6</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100208.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100208.log deleted file mode 100644 index c85340b..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100208.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100208T11:58:54' cm_id='1265630334' id='user@collabora.co.uk' name='User1' token='' isuser='true' type='normal'>1</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100216.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100216.log deleted file mode 100644 index 2aa9ee2..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100216.log +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100216T13:43:12' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>fooooo</message> -<message time='20100216T13:43:24' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>123123</message> -<message time='20100216T13:43:31' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>123</message> -<message time='20100216T13:45:44' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>gna2</message> -<message time='20100216T14:10:59' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>prova 3</message> -<message time='20100216T14:13:48' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>123</message> -<message time='20100216T15:51:28' cm_id='1266335488' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>1</message> -<message time='20100216T15:52:36' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>1</message> -<message time='20100216T15:56:43' cm_id='1266335803' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>a</message> -<message time='20100216T15:57:30' cm_id='0' id='user2@collabora.co.uk' name='User2' token='' isuser='false' type='normal'>bar</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100217.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100217.log deleted file mode 100644 index 46804f6..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100217.log +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100217T13:47:31' cm_id='1266414451' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>1</message> -<message time='20100217T15:49:41' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>123</message> -<message time='20100217T15:49:57' cm_id='1266421797' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>321</message> -<message time='20100217T16:52:45' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>1</message> -<message time='20100217T16:52:46' cm_id='1' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>2</message> -<message time='20100217T16:52:46' cm_id='2' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>3</message> -<message time='20100217T16:52:46' cm_id='3' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>4</message> -<message time='20100217T16:52:46' cm_id='4' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>5</message> -<message time='20100217T16:52:51' cm_id='1266425571' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>1</message> -<message time='20100217T16:52:52' cm_id='1266425572' id='user@collabora.co.uk' name='User1' token='b42b37774fe34e9891ab1ecd1f187062b7135e6a' isuser='true' type='normal'>3</message> -<message time='20100217T16:52:46' cm_id='1' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>2</message> -<message time='20100217T16:52:46' cm_id='2' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>3</message> -<message time='20100217T16:52:46' cm_id='3' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>4</message> -<message time='20100217T16:52:46' cm_id='4' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>5</message> -<message time='20100217T16:53:06' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='true' type='normal'>3</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100218.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100218.log deleted file mode 100644 index 6cdb627..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user2@collabora.co.uk/20100218.log +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100218T14:32:14' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>now</message> -<message time='20100218T14:35:11' cm_id='0' id='user2@collabora.co.uk' name='User2' token='863d261bd11170b87b67ccb9c7ec90a5bd17e990' isuser='false' type='normal'>1</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user3@collabora.co.uk/20100113.call.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user3@collabora.co.uk/20100113.call.log deleted file mode 100644 index 7ab442a..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user3@collabora.co.uk/20100113.call.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<call time='20100113T23:11:15' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='12' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='im.telepathy1.Error.Cancelled' /> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.call.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.call.log deleted file mode 100644 index dfb79cb..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.call.log +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='1' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='im.telepathy1.Error.Cancelled' /> -<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='2' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='im.telepathy1.Error.Cancelled' /> -<!-- use the old Telepathy namespace for 'detail' to test backward compatibility --> -<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='3' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='org.freedesktop.Telepathy.Error.Cancelled' /> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.log deleted file mode 100644 index f3cbd00..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.log +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100113T17:47:57' cm_id='234' id='user3@collabora.co.uk' name='User3' token='' isuser='true' type='normal'>7</message> -<message time='20100113T17:48:01' cm_id='345' id='user3@collabora.co.uk' name='User3' token='' isuser='true' type='normal'>8</message> -<message time='20100113T17:49:10' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>9</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100111.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100111.log deleted file mode 100644 index 1d3af7e..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100111.log +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100111T00:00:01' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>0</message> -<message time='20100111T00:00:02' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>1</message> -<message time='20100111T00:00:03' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>2</message> -<message time='20100111T00:00:04' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>3</message> -<message time='20100111T00:00:05' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>4</message> -<message time='20100111T00:00:05' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>4'</message> -<message time='20100111T00:00:05' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>4''</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100112.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100112.log deleted file mode 100644 index 3f3a495..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100112.log +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100112T00:00:01' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>5</message> -<message time='20100112T00:00:01' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>5'</message> -<message time='20100112T00:00:01' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>5''</message> -<message time='20100112T00:00:04' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>6</message> -<message time='20100112T00:00:05' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>7</message> -<message time='20100112T00:00:06' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>8</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100113.call.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100113.call.log deleted file mode 100644 index 34e5e6a..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100113.call.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='1' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='im.telepathy1.Error.Cancelled' /> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100113.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100113.log deleted file mode 100644 index 23d6859..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100113.log +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100113T17:49:10' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>9</message> -</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100114.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100114.log deleted file mode 100644 index 0ee06a3..0000000 --- a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user5@collabora.co.uk/20100114.log +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> -<log> -<message time='20100114T00:00:01' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>10</message> -<message time='20100114T00:00:02' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>11</message> -<message time='20100114T00:00:02' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>11'</message> -<message time='20100114T00:00:02' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>11''</message> -<message time='20100114T00:00:05' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>12</message> -<message time='20100114T00:00:06' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>13</message> -</log> diff --git a/tests/logs/purple/bonjour/user@host/user2@host2/2010-04-29.140346+0100BST.html b/tests/logs/purple/bonjour/user@host/user2@host2/2010-04-29.140346+0100BST.html deleted file mode 100644 index 1d8f029..0000000 --- a/tests/logs/purple/bonjour/user@host/user2@host2/2010-04-29.140346+0100BST.html +++ /dev/null @@ -1,6 +0,0 @@ -<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation</title></head><body><h3>Conversation (bonjour)</h3> -<font color="#16569E"><font size="2">(14:03:48)</font> <b>user2:</b></font> 1<br/> -<font color="#A82F2F"><font size="2">(14:03:54)</font> <b>user1:</b></font> 2<br/> -<font color="#16569E"><font size="2">(14:03:56)</font> <b>user2:</b></font> 3<br/> -<font color="#A82F2F"><font size="2">(14:03:58)</font> <b>user1:</b></font> 4<br/> -</body></html> diff --git a/tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.html b/tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.html Binary files differdeleted file mode 100644 index 8e87f42..0000000 --- a/tests/logs/purple/icq/12345678/87654321/2010-02-06.130032+0000GMT.html +++ /dev/null diff --git a/tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html b/tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html deleted file mode 100644 index e69de29..0000000 --- a/tests/logs/purple/icq/12345678/87654321/2010-02-07.130033+0000GMT.html +++ /dev/null diff --git a/tests/logs/purple/icq/12345678/87654321/2010-02-08.130034+0000GMT.html b/tests/logs/purple/icq/12345678/87654321/2010-02-08.130034+0000GMT.html deleted file mode 100644 index 90ee742..0000000 --- a/tests/logs/purple/icq/12345678/87654321/2010-02-08.130034+0000GMT.html +++ /dev/null @@ -1,8 +0,0 @@ -<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with 87654321 at Mon 08 Feb 2010 13:00:34 GMT on 12345678 (icq)</title></head><body><h3>Conversation with 87654321 at Mon 08 Feb 2010 13:00:34 GMT on 12345678 (icq)</h3> -<font color="#A82F2F"><font size="2">(13:00:34)</font> <b>87654321:</b></font> oi<br/> -<font color="#16569E"><font size="2">(13:00:49)</font> <b>12345678:</b></font> oi<br/> -<font color="#16569E"><font size="2">(13:00:56)</font> <b>12345678:</b></font> bla bla?<br/> -<font color="#A82F2F"><font size="2">(13:01:19)</font> <b>87654321:</b></font> bla bla bla!<br/> -<font size="2">(13:03:34)</font><b> 87654321 is now known as TheUser2 -</b><br/> -</body></html> diff --git a/tests/logs/purple/icq/12345678/87654321/2010-02-08.134023+0000GMT.html b/tests/logs/purple/icq/12345678/87654321/2010-02-08.134023+0000GMT.html deleted file mode 100644 index b81f991..0000000 --- a/tests/logs/purple/icq/12345678/87654321/2010-02-08.134023+0000GMT.html +++ /dev/null @@ -1,12 +0,0 @@ -<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with 87654321 at Mon 08 Feb 2010 13:40:23 GMT on 12345678 (icq)</title></head><body><h3>Conversation with 87654321 at Mon 08 Feb 2010 13:40:23 GMT on 12345678 (icq)</h3> -<font color="#A82F2F"><font size="2">(13:40:23)</font> <b>87654321:</b></font> oi<br/> -<font size="2">(13:40:37)</font><b> 87654321 is now known as TheUser2. -</b><br/> -<font color="#A82F2F"><font size="2">(13:40:43)</font> <b>TheUser2:</b></font> gna<br/> -<font color="#16569E"><font size="2">(13:40:49)</font> <b>12345678:</b></font> gnagnagna<br/> -<font color="#A82F2F"><font size="2">(13:41:08)</font> <b>TheUser2:</b></font> just gnagna<br/> -<font color="#16569E"><font size="2">(13:41:35)</font> <b>12345678:</b></font> ok sorry<br/> -<font color="#16569E"><font size="2">(13:41:48)</font> <b>12345678:</b></font> gnagna<br/> -<font color="#A82F2F"><font size="2">(13:41:48)</font> <b>TheUser2:</b></font> np<br/> -<font color="#16569E"><font size="2">(13:41:53)</font> <b>12345678:</b></font> so, gnagna?<br/> -</body></html> diff --git a/tests/logs/purple/irc/user@irc.freenode.net/#telepathy.chat/2010-11-30.124947+0000GMT.html b/tests/logs/purple/irc/user@irc.freenode.net/#telepathy.chat/2010-11-30.124947+0000GMT.html deleted file mode 100644 index f024a0c..0000000 --- a/tests/logs/purple/irc/user@irc.freenode.net/#telepathy.chat/2010-11-30.124947+0000GMT.html +++ /dev/null @@ -1,178 +0,0 @@ -<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with #telepathy at Tue 30 Nov 2010 12:49:47 GMT on KA__@irc.freenode.net (irc)</title></head><body><h3>Conversation with #telepathy at Tue 30 Nov 2010 12:49:47 GMT on KA__@irc.freenode.net (irc)</h3> -<font size="2">(12:49:48)</font><b> The topic for #telepathy is: ICQ trouble? <a href="http://is.gd/hmEtM">http://is.gd/hmEtM</a> | Visit #empathy on GIMPnet for Empathy-specific discussion | Telepathy Real-time Communications Framework: <a href="http://telepathy.freedesktop.org">http://telepathy.freedesktop.org</a> | <a href="http://telepathy.freedesktop.org/wiki/FAQ">http://telepathy.freedesktop.org/wiki/FAQ</a> | <a href="http://git.collabora.co.uk/">http://git.collabora.co.uk/</a></b><br/> -<font size="2">(12:56:01)</font><b> MattJ [<em>~MattJ@91.85.174.192</em>] entered the room.</b><br/> -<font size="2">(13:10:27)</font><b> johanbr [<em>~j@142.12.7.28</em>] entered the room.</b><br/> -<font size="2">(13:16:13)</font><b> seiflotfy_ [<em>~seiflotfy@ip-95-223-14-124.unitymediagroup.de</em>] entered the room.</b><br/> -<font size="2">(13:16:16)</font><b> seiflotfy left the room (quit: Read error: Connection reset by peer).</b><br/> -<font color="#A82F2F"><font size="2">(13:17:58)</font> <b>smcv:</b></font> those who like contact lists: https://bugs.freedesktop.org/show_bug.cgi?id=31997<br/> -<font size="2">(13:18:39)</font><b> shiyee left the room (quit: Quit: Ex-Chat).</b><br/> -<font color="#A82F2F"><font size="2">(13:22:05)</font> <b>smcv:</b></font> and relatedly https://bugs.freedesktop.org/show_bug.cgi?id=31998<br/> -<font size="2">(13:25:18)</font><b> seb128 left the room (quit: Quit: Ex-Chat).</b><br/> -<font size="2">(13:25:34)</font><b> seb128 [<em>~seb128@ANancy-258-1-45-93.w90-39.abo.wanadoo.fr</em>] entered the room.</b><br/> -<font size="2">(13:25:34)</font><b> seb128 left the room (quit: Changing host).</b><br/> -<font size="2">(13:25:34)</font><b> seb128 [<em>~seb128@ubuntu/member/seb128</em>] entered the room.</b><br/> -<font size="2">(13:37:05)</font><b> bpepple [<em>~bpepple|l@99-186-52-80.lightspeed.clmboh.sbcglobal.net</em>] entered the room.</b><br/> -<font size="2">(13:43:15)</font><b> seiflotfy_ left the room (quit: Remote host closed the connection).</b><br/> -<font size="2">(13:44:12)</font><b> alsuren [<em>~alsuren@78-86-104-189.zone2.bethere.co.uk</em>] entered the room.</b><br/> -<font size="2">(13:44:58)</font><b> seiflotfy [<em>~seiflotfy@ip-95-223-14-124.unitymediagroup.de</em>] entered the room.</b><br/> -<font size="2">(13:47:43)</font><b> gkcn left the room ("http://quassel-irc.org - Her yerden rahatça konuş.").</b><br/> -<font size="2">(13:58:56)</font><b> seb128 left the room (quit: Quit: Ex-Chat).</b><br/> -<font color="#A82F2F"><font size="2">(14:04:34)</font> <b>wjt:</b></font> hmm. what do we actually have in Gabble that actually needs server support? besides PEP and contact search and contact info.<br/> -<font color="#A82F2F"><font size="2">(14:09:31)</font> <b>cassidy:</b></font> mucs ?<br/> -<font color="#A82F2F"><font size="2">(14:09:38)</font> <b>cassidy:</b></font> invisible<br/> -<font color="#A82F2F"><font size="2">(14:09:47)</font> <b>cassidy:</b></font> proxies<br/> -<font color="#A82F2F"><font size="2">(14:10:06)</font> <b>sjoerd:</b></font> invisible is a good one<br/> -<font color="#A82F2F"><font size="2">(14:11:22)</font> <b>cassidy:</b></font> XMPP ping maybe<br/> -<font color="#A82F2F"><font size="2">(14:11:30)</font> <b>cassidy:</b></font> not sure if we implement this one<br/> -<font size="2">(14:11:31)</font><b> seb128 [<em>~seb128@ANancy-258-1-45-93.w90-39.abo.wanadoo.fr</em>] entered the room.</b><br/> -<font size="2">(14:11:31)</font><b> seb128 left the room (quit: Changing host).</b><br/> -<font size="2">(14:11:31)</font><b> seb128 [<em>~seb128@ubuntu/member/seb128</em>] entered the room.</b><br/> -<font size="2">(14:11:41)</font><b> mikhailz left the room (quit: Quit: Ушёл).</b><br/> -<font color="#A82F2F"><font size="2">(14:11:48)</font> <b>cassidy:</b></font> the roster power saving thing<br/> -<font size="2">(14:12:11)</font><b> kaserf [<em>~felix@ppp-93-104-18-213.dynamic.mnet-online.de</em>] entered the room.</b><br/> -<font color="#A82F2F"><font size="2">(14:12:20)</font> <b>wjt:</b></font> oh yeah, dwd implemented google:queue in M-Link<br/> -<font color="#A82F2F"><font size="2">(14:12:26)</font> <b>wjt:</b></font> invisible's a good idea. we do implement xmpp ping<br/> -<font color="#A82F2F"><font size="2">(14:18:06)</font> <b>wjt:</b></font> we don't do the roster versioning thing though<br/> -<font color="#A82F2F"><font size="2">(14:18:10)</font> <b>wjt:</b></font> maybe we should. how hard could it be.<br/> -<font color="#A82F2F"><font size="2">(14:18:44)</font> <b>wjt:</b></font> there's not much to test in Ping :)<br/> -<font color="#A82F2F"><font size="2">(14:19:01)</font> <b>sjoerd:</b></font> I'd like to move to a WockyRoster first tbh, but....<br/> -<font color="#A82F2F"><font size="2">(14:19:13)</font> <b>wjt:</b></font> cassidy: proxies as in Socks5 bytestream proxies?<br/> -<font color="#A82F2F"><font size="2">(14:19:16)</font> <b>cassidy:</b></font> yep<br/> -<font size="2">(14:20:22)</font><b> bcurtiswx [<em>~bcurtis@wx.mesa.gmu.edu</em>] entered the room.</b><br/> -<font size="2">(14:20:22)</font><b> bcurtiswx left the room (quit: Changing host).</b><br/> -<font size="2">(14:20:22)</font><b> bcurtiswx [<em>~bcurtis@ubuntu/member/bcurtiswx</em>] entered the room.</b><br/> -<font size="2">(14:30:32)</font><b> jonkri [<em>~jonkri@dedikerad/admin/jonkri</em>] entered the room.</b><br/> -<font size="2">(14:36:43)</font><b> stefw_ [<em>~sean@201.138.95.188</em>] entered the room.</b><br/> -<font size="2">(14:53:14)</font><b> trupheenix left the room (quit: Ping timeout: 255 seconds).</b><br/> -<font color="#A82F2F"><font size="2">(14:55:26)</font> <b>ptlo:</b></font> kkszysiu, heya; i seem to remember you were hacking on a im-via-web-using-telepathy stuff? how's that going? i'd be interested in doing something along the same lines<br/> -<font color="#A82F2F"><font size="2">(14:55:46)</font> <b>ptlo:</b></font> (or similar)<br/> -<font color="#A82F2F"><font size="2">(15:10:05)</font> <b>wjt:</b></font> huh<br/> -<font color="#A82F2F"><font size="2">(15:10:21)</font> <b>wjt:</b></font> setting my status on Google Talk seems to take a noticable amount of time since the Shared Status stuff went in<br/> -<font color="#A82F2F"><font size="2">(15:10:43)</font> <b>sjoerd:</b></font> in gabble or in another location<br/> -<font color="#A82F2F"><font size="2">(15:11:12)</font> <b>sjoerd:</b></font> Oh, i noticed that our iq request queue somethings fill up and then doesn't seem to get unstuck<br/> -<font color="#A82F2F"><font size="2">(15:11:43)</font> <b>sjoerd:</b></font> quite noticable of you request user info<br/> -<font color="#A82F2F"><font size="2">(15:12:06)</font> <b>wjt:</b></font> in Gabble. i didn't even have GMail open<br/> -<font color="#A82F2F"><font size="2">(15:12:23)</font> <b>wjt:</b></font> invisibleness works on almost all of my accounts now! :D<br/> -<font color="#A82F2F"><font size="2">(15:12:38)</font> <b>sjoerd:</b></font> i mean does it take gabble a while to send out the presence or gmail to update it to peers<br/> -<font color="#A82F2F"><font size="2">(15:13:35)</font> <b>wjt:</b></font> MattJ: so about that xep-0186 support? ;-)<br/> -<font color="#A82F2F"><font size="2">(15:14:03)</font> <b>wjt:</b></font> heh, oh dear<br/> -<font color="#A82F2F"><font size="2">(15:14:22)</font> <b>wjt:</b></font> i fell out of jdev@ when I went invisible<br/> -<font color="#A82F2F"><font size="2">(15:14:39)</font> <b>sjoerd:</b></font> buhboh<br/> -<font color="#A82F2F"><font size="2">(15:15:10)</font> <b>wjt:</b></font> i guess the collabora xmpp server does privacy list-based invisibility, so it's only doing what i asked<br/> -<font color="#A82F2F"><font size="2">(15:16:50)</font> <b>cassidy:</b></font> wjt, how can you test if you are actually invisible? The account presence is always sync with your real status?<br/> -<font color="#A82F2F"><font size="2">(15:17:26)</font> <b>cassidy:</b></font> (I like this ghost icon :)<br/> -<font color="#A82F2F"><font size="2">(15:17:28)</font> <b>wjt:</b></font> http://telepathy.freedesktop.org/spec/Account.html#im.telepathy1.Account.CurrentPresence is based on what the CM says it is<br/> -<font color="#A82F2F"><font size="2">(15:17:37)</font> <b>wjt:</b></font> and that's what shows up in the account dialog<br/> -<font color="#A82F2F"><font size="2">(15:17:46)</font> <b>wjt:</b></font> what does the ghost look like? I use a different theme.<br/> -<font color="#A82F2F"><font size="2">(15:20:40)</font> <b>cassidy:</b></font> wjt, http://people.collabora.co.uk/~cassidy/status.jpg<br/> -<font color="#A82F2F"><font size="2">(15:22:31)</font> <b>wjt:</b></font> haha<br/> -<font color="#A82F2F"><font size="2">(15:22:39)</font> <b>wjt:</b></font> that's the only good icon in that set<br/> -<font color="#A82F2F"><font size="2">(15:22:51)</font> <b>cassidy:</b></font> totally<br/> -<font color="#A82F2F"><font size="2">(15:28:05)</font> <b>jonnylamb:</b></font> pessi: Hi, I fixed some bugs in ring: http://git.collabora.co.uk/?p=user/jonny/telepathy-ring.git;a=shortlog;h=refs/heads/trivia<br/> -<font color="#A82F2F"><font size="2">(15:29:09)</font> <b>wjt:</b></font> no gitorious merge request? <br/> -<font color="#A82F2F"><font size="2">(15:29:27)</font> <b>jonnylamb:</b></font> no gitorious merge request.<br/> -<font color="#A82F2F"><font size="2">(15:29:42)</font> <b>wjt:</b></font> no biscuit.<br/> -<font color="#A82F2F"><font size="2">(15:30:44)</font> <b>sjoerd:</b></font> bha, my register flag is sticky on an account again<br/> -<font color="#A82F2F"><font size="2">(15:30:49)</font> <b>sjoerd:</b></font> i thought we fixed that...<br/> -<font color="#A82F2F"><font size="2">(15:33:38)</font> <b>MattJ:</b></font> That's the #2 most common problem I help Empathy users with :)<br/> -<font color="#A82F2F"><font size="2">(15:34:15)</font> <b>jonnylamb:</b></font> :-/<br/> -<font color="#A82F2F"><font size="2">(15:34:21)</font> <b>jonnylamb:</b></font> What's number one?<br/> -<font color="#A82F2F"><font size="2">(15:34:26)</font> <b>cassidy:</b></font> yeah that should have be fixed in MC<br/> -<font color="#A82F2F"><font size="2">(15:34:48)</font> <b>sjoerd:</b></font> Good that a proper register interface is getting higher on the todo list<br/> -<font color="#A82F2F"><font size="2">(15:35:24)</font> <b>MattJ:</b></font> jonnylamb: debugging "Network Error" messages<br/> -<font color="#A82F2F"><font size="2">(15:35:35)</font> <b>wjt:</b></font> \o\ /o/<br/> -<font color="#A82F2F"><font size="2">(15:35:45)</font> <b>jonnylamb:</b></font> :-(<br/> -<font color="#A82F2F"><font size="2">(15:35:46)</font> <b>MattJ:</b></font> jonnylamb: which actually covers practically every account or server misconfiguration possible, so...<br/> -<font color="#A82F2F"><font size="2">(15:35:50)</font> <b>sjoerd:</b></font> that's mostly fixed though<br/> -<font color="#A82F2F"><font size="2">(15:36:00)</font> <b>smcv:</b></font> ConnectionError gives us extensible signalling<br/> -<font color="#A82F2F"><font size="2">(15:36:09)</font> <b>smcv:</b></font> not all the CMs actually provide more info yet<br/> -<font color="#A82F2F"><font size="2">(15:36:17)</font> <b>smcv:</b></font> we're getting there for Gabble<br/> -<font color="#A82F2F"><font size="2">(15:36:18)</font> <b>MattJ:</b></font> Does Gabble?<br/> -<font color="#A82F2F"><font size="2">(15:36:23)</font> <b>MattJ:</b></font> Good :)<br/> -<font color="#A82F2F"><font size="2">(15:36:34)</font> <b>smcv:</b></font> Gabble provides the un-localized debug message in all cases<br/> -<font color="#A82F2F"><font size="2">(15:36:41)</font> <b>wjt:</b></font> the UI doesn't show it though<br/> -<font color="#A82F2F"><font size="2">(15:36:44)</font> <b>MattJ:</b></font> Please use <text> from XMPP errors<br/> -<font color="#A82F2F"><font size="2">(15:36:46)</font> <b>smcv:</b></font> and a maximally good Telepathy error in some<br/> -<font size="2">(15:36:50)</font><b> alsuren_ [<em>~alsuren@78-86-104-189.zone2.bethere.co.uk</em>] entered the room.</b><br/> -<font color="#A82F2F"><font size="2">(15:36:56)</font> <b>MattJ:</b></font> I know other servers aren't helpful that way, but Prosody is<br/> -<font color="#A82F2F"><font size="2">(15:37:17)</font> <b>smcv:</b></font> MattJ: aha, I spy a use-case for the hypothetical server-message field<br/> -<font color="#A82F2F"><font size="2">(15:37:25)</font> <b>sjoerd:</b></font> dear ejabberd, why are you not showing your xep 55 in your disco response<br/> -<font color="#A82F2F"><font size="2">(15:37:31)</font> <b>MattJ:</b></font> smcv: :)<br/> -<font color="#A82F2F"><font size="2">(15:37:38)</font> <b>smcv:</b></font> (ConnectionError has a hash table of misc, debug-message is the only universally-provided key)<br/> -<font color="#A82F2F"><font size="2">(15:38:00)</font> <b>wjt:</b></font> hey<br/> -<font color="#A82F2F"><font size="2">(15:38:09)</font> <b>wjt:</b></font> you successfully convinced me to conflate the two<br/> -<font color="#A82F2F"><font size="2">(15:38:13)</font> <b>smcv:</b></font> MattJ: what language is the <text> in btw?<br/> -<font color="#A82F2F"><font size="2">(15:38:22)</font> <b>wjt:</b></font> if the server provides <text/>, use that; otherwise, use a locally-supplied debug string<br/> -<font color="#A82F2F"><font size="2">(15:38:41)</font> <b>smcv:</b></font> did I? not sure if I intended to or not, tbh<br/> -<font color="#A82F2F"><font size="2">(15:38:54)</font> <b>MattJ:</b></font> smcv: In Prosody, always (British!) English currently<br/> -<font color="#A82F2F"><font size="2">(15:38:56)</font> <b>sjoerd:</b></font> I don't really trust servers to give something more useful then gabble can tbh<br/> -<font color="#A82F2F"><font size="2">(15:38:57)</font> <b>wjt:</b></font> well, s/you/this channel/<br/> -<font color="#A82F2F"><font size="2">(15:39:06)</font> <b>MattJ:</b></font> sjoerd: lies<br/> -<font color="#A82F2F"><font size="2">(15:39:22)</font> <b>sjoerd:</b></font> MattJ: Prosody is usually the exception about being nice<br/> -<font color="#A82F2F"><font size="2">(15:39:26)</font> <b>MattJ:</b></font> Heh<br/> -<font color="#A82F2F"><font size="2">(15:39:34)</font> <b>smcv:</b></font> libpurple's localized debug messages aren't quite the same thing as <text/> from the server<br/> -<font color="#A82F2F"><font size="2">(15:39:47)</font> <b>sjoerd:</b></font> ejabberd isn't even telling me why it's disconnecting some test accounts<br/> -<font color="#A82F2F"><font size="2">(15:39:55)</font> <b>MattJ:</b></font> There are vague errors like "bad-request" or "not-authorized" where Prosody usually gives more specific information about why the error occured<br/> -<font color="#A82F2F"><font size="2">(15:40:04)</font> <b>smcv:</b></font> tbh we should probably provide our (libpurple's/wocky's) interpretation, *and* the <text/> from the server in case it's informative<br/> -<font size="2">(15:40:05)</font><b> bcurtiswx left the room (quit: Remote host closed the connection).</b><br/> -<font color="#A82F2F"><font size="2">(15:40:14)</font> <b>sjoerd:</b></font> nod<br/> -<font color="#A82F2F"><font size="2">(15:40:16)</font> <b>MattJ:</b></font> smcv: Yes, the specs say you should do that<br/> -<font color="#A82F2F"><font size="2">(15:40:25)</font> <b>MattJ:</b></font> e.g. not present solely the <text><br/> -<font color="#A82F2F"><font size="2">(15:40:36)</font> <b>smcv:</b></font> oh I wasn't suggesting that<br/> -<font color="#A82F2F"><font size="2">(15:40:55)</font> <b>smcv:</b></font> the primary thing to present is a D-Bus error code which UIs are expected to localize<br/> -<font color="#A82F2F"><font size="2">(15:41:07)</font> <b>smcv:</b></font> one of whose possible values is the dreaded NetworkError<br/> -<font color="#A82F2F"><font size="2">(15:41:12)</font> <b>MattJ:</b></font> But please don't do what Psi does and copy the XMPP spec's error text verbatim into the UI...<br/> -<font size="2">(15:41:19)</font><b> alsuren left the room (quit: Ping timeout: 272 seconds).</b><br/> -<font color="#A82F2F"><font size="2">(15:43:39)</font> <b>sjoerd:</b></font> hehe<br/> -<font size="2">(15:43:48)</font><b> nekohayo [<em>~jeff@206-248-171-113.dsl.teksavvy.com</em>] entered the room.</b><br/> -<font color="#A82F2F"><font size="2">(15:44:00)</font> <b>pessi:</b></font> jonnylamb: please rebase against latest master ... and see if e7470c3ab and f26a5c3298 are still applicable<br/> -<font color="#A82F2F"><font size="2">(15:44:45)</font> <b>sjoerd:</b></font> wjt: hrm, can you disco remote servers for their jud and does gabble do that if needed or does it rely on the given server being the jud?<br/> -<font color="#A82F2F"><font size="2">(15:45:34)</font> <b>jonnylamb:</b></font> pessi: Hm, I wonder why my checkout was so out-of-date. Did you just push those patches?<br/> -<font color="#A82F2F"><font size="2">(15:45:43)</font> <b>jonnylamb:</b></font> pessi: \o/ TpBaseChannel \o/<br/> -<font color="#A82F2F"><font size="2">(15:46:37)</font> <b>wjt:</b></font> sjoerd: oops. the latter.<br/> -<font color="#A82F2F"><font size="2">(15:46:40)</font> <b>pessi:</b></font> jonnylamb: I was just waiting for our tester to get rid of oFono bugs ;)<br/> -<font color="#A82F2F"><font size="2">(15:48:57)</font> <b>sjoerd:</b></font> wjt: we should probably cope with both cases.. i wonder if jud server correctly indicate in a disco response that they're the jud server<br/> -<font size="2">(15:49:46)</font><b> jessevdk [<em>~jessevdk@grijpc10.epfl.ch</em>] entered the room.</b><br/> -<font size="2">(15:50:09)</font><b> mattire left the room (quit: Ping timeout: 245 seconds).</b><br/> -<font color="#A82F2F"><font size="2">(15:52:40)</font> <b>jonnylamb:</b></font> pessi: Well you've destroyed my branch with your recent commits!<br/> -<font color="#A82F2F"><font size="2">(15:52:44)</font> <b>jonnylamb:</b></font> pessi: http://git.collabora.co.uk/?p=user/jonny/telepathy-ring.git;a=shortlog;h=refs/heads/trivia<br/> -<font size="2">(15:54:54)</font><b> bcurtiswx [<em>~bcurtis@wx.mesa.gmu.edu</em>] entered the room.</b><br/> -<font size="2">(15:54:54)</font><b> bcurtiswx left the room (quit: Changing host).</b><br/> -<font size="2">(15:54:54)</font><b> bcurtiswx [<em>~bcurtis@ubuntu/member/bcurtiswx</em>] entered the room.</b><br/> -<font size="2">(15:55:54)</font><b> jessevdk left the room ("Ex-Chat").</b><br/> -<font size="2">(15:57:03)</font><b> kaserf left the room (quit: Read error: Operation timed out).</b><br/> -<font size="2">(15:57:37)</font><b> ptlo left the room (quit: Quit: Ex-Chat).</b><br/> -<font size="2">(15:58:14)</font><b> mlundblad left the room (quit: Ping timeout: 260 seconds).</b><br/> -<font color="#A82F2F"><font size="2">(15:58:30)</font> <b>wjt:</b></font> so. if I were to propose adding a property alongside ValidAccounts and InvalidAccounts, which contains accounts which are not normal IM accounts—maybe they're just signed in for some kind of pubsub system—and thus should not normally be shown to the user, how many people would club me to death?<br/> -<font color="#A82F2F"><font size="2">(15:59:18)</font> <b>wjt:</b></font> assumptions: such accounts never turn into normal accounts; there would be a separate interface for them on AM; but otherwise they would behave like normal accounts; the Account objects would also have a property on a separate interface to say they're non-user-visible service accounts?<br/> -<font size="2">(15:59:33)</font><b> fledermaus left the room (quit: Quit: bbl).</b><br/> -<font color="#A82F2F"><font size="2">(16:00:38)</font> <b>wjt:</b></font> alternative possibly less-beating-worthy proposals include just adding the flag to the account and then modifying tp-{glib,qt4,...} to hide 'em by default<br/> -<font color="#A82F2F"><font size="2">(16:00:53)</font> <b>smcv:</b></font> wjt: if the account manager manages it, I think it's a valid account like any other<br/> -<font color="#A82F2F"><font size="2">(16:01:32)</font> <b>smcv:</b></font> if the libraries hide those accounts by default, that's no more compatible than changing the D-Bus API<br/> -<font color="#A82F2F"><font size="2">(16:01:44)</font> <b>smcv:</b></font> you're just moving the incompatibility into the client libraries<br/> -<font color="#A82F2F"><font size="2">(16:01:46)</font> <b>wjt:</b></font> but if it's not meant to be used for IM, then IM UIs shouldn't show it<br/> -<font color="#A82F2F"><font size="2">(16:01:59)</font> <b>wjt:</b></font> yes, that's why i didn't want to put it in the client libraries :)<br/> -<font color="#A82F2F"><font size="2">(16:02:24)</font> <b>wjt:</b></font> i want to be able to make stealth service accounts exist without modifying literally every existing and future application not to show them<br/> -<font color="#A82F2F"><font size="2">(16:02:57)</font> <b>smcv:</b></font> wjt: if you want them to be that stealthy, put the new property on a different interface<br/> -<font color="#A82F2F"><font size="2">(16:03:11)</font> <b>smcv:</b></font> AccountManager.I.AndAlso.SecretNinjaAccounts<br/> -<font color="#A82F2F"><font size="2">(16:03:37)</font> <b>wjt:</b></font> that's exactly what I just proposed? :)<br/> -<font color="#A82F2F"><font size="2">(16:03:55)</font> <b>smcv:</b></font> oh right I thought by "alongside" you meant in o.fd.T.AM<br/> -<font size="2">(16:03:59)</font><b> seb128 left the room (quit: Quit: Ex-Chat).</b><br/> -<font color="#A82F2F"><font size="2">(16:04:07)</font> <b>wjt:</b></font> nono, i meant on ja.ninja.AccountManager<br/> -<font color="#A82F2F"><font size="2">(16:04:57)</font> <b>smcv:</b></font> I think that's better than modifying the client libraries<br/> -<font color="#A82F2F"><font size="2">(16:05:24)</font> <b>wjt:</b></font> but implemented in MC (yeah yeah, adding weird extensions considered harmful, but i also don't want to use the libmissioncontrol-server6 API and subclass shit)<br/> -<font color="#A82F2F"><font size="2">(16:07:01)</font> <b>smcv:</b></font> oh yeah having weird extensions live in MC where we can keep an eye on them is better than having them in misc subclasses :-)<br/> -<font color="#A82F2F"><font size="2">(16:07:34)</font> <b>smcv:</b></font> tbh it's not necessarily too niche to have in telepathy-spec<br/> -<font color="#A82F2F"><font size="2">(16:07:41)</font> <b>smcv:</b></font> it's just too weird to have in the core interface<br/> -<font color="#A82F2F"><font size="2">(16:07:45)</font> <b>wjt:</b></font> exactly :)<br/> -<font color="#A82F2F"><font size="2">(16:08:09)</font> <b>wjt:</b></font> ugh. so after empathy crashed and this MUC i'm in respawned, all the scrollback messages turned up in 1-1 channels<br/> -<font size="2">(16:08:18)</font><b> seb128 [<em>~seb128@ANancy-258-1-45-93.w90-39.abo.wanadoo.fr</em>] entered the room.</b><br/> -<font size="2">(16:08:18)</font><b> seb128 left the room (quit: Changing host).</b><br/> -<font size="2">(16:08:18)</font><b> seb128 [<em>~seb128@ubuntu/member/seb128</em>] entered the room.</b><br/> -<font size="2">(16:08:25)</font><b> seb128 left the room (quit: Remote host closed the connection).</b><br/> -<font size="2">(16:09:15)</font><b> seb128 [<em>~seb128@ANancy-258-1-45-93.w90-39.abo.wanadoo.fr</em>] entered the room.</b><br/> -<font size="2">(16:09:18)</font><b> seb128 left the room (quit: Changing host).</b><br/> -<font size="2">(16:09:18)</font><b> seb128 [<em>~seb128@ubuntu/member/seb128</em>] entered the room.</b><br/> -<font color="#A82F2F"><font size="2">(16:10:13)</font> <b>sjoerd:</b></font> wjt: yeah that still happens from time to time, although i thought it was fixed :(<br/> -<font size="2">(16:10:27)</font><b> The account has disconnected and you are no longer in this chat. You will automatically rejoin the chat when the account reconnects.</b><br/> -</body></html> diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/.system/2010-12-10.162531+0000GMT.txt b/tests/logs/purple/jabber/user@collabora.co.uk/.system/2010-12-10.162531+0000GMT.txt deleted file mode 100644 index e3dfac5..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/.system/2010-12-10.162531+0000GMT.txt +++ /dev/null @@ -1,5 +0,0 @@ -System log for account ka.test2@test.collabora.co.uk/TEST (jabber) connected at Fri 10 Dec 2010 16:25:31 GMT ----- +++ ka.test2@test.collabora.co.uk/TEST signed on @ 10/12/10 16:25:31 ---- ----- cosimo.alfarano@collabora.co.uk (cosimo.alfarano@collabora.co.uk) is now Offline @ 10/12/10 16:26:50 ---- ----- cosimo.alfarano@collabora.co.uk (cosimo.alfarano@collabora.co.uk) changed status from Offline to Available @ 10/12/10 16:26:54 ---- ----- +++ ka.test2@test.collabora.co.uk/TEST signed off @ 10/12/10 16:27:15 ---- diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/test@conference.collabora.co.uk.chat/2010-04-12.122703+0100BST.html b/tests/logs/purple/jabber/user@collabora.co.uk/test@conference.collabora.co.uk.chat/2010-04-12.122703+0100BST.html deleted file mode 100644 index faf97fe..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/test@conference.collabora.co.uk.chat/2010-04-12.122703+0100BST.html +++ /dev/null @@ -1,12 +0,0 @@ -<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with test@conference.collabora.co.uk at Thu 12 Apr 2010 12:27:03 BST on user@collabora.co.uk/TEST (jabber)</title></head><body><h3>Conversation with test@conference.collabora.co.uk at Thu 12 Apr 2010 12:27:03 BST on user@collabora.co.uk/TEST (jabber)</h3> -<font size="2">(12:27:03)</font><b> user@collabora.co.uk/TEST</em>] entered the room.</b><br/> -<font size="2">(12:28:22)</font><b> user@collabora.co.uk/empathy</em>] entered the room.</b><br/> -<font color="#16569E"><font size="2">(12:28:46)</font> <b>user2:</b></font> <body>1</body><br/> -<font color="#16569E"><font size="2">(12:29:31)</font> <b>user2:</b></font> <body>2</body><br/> -<font color="#A82F2F"><font size="2">(12:30:37)</font> <b>user@collabora.co.uk:</b></font> <body>1</body><br/> -<font color="#16569E"><font size="2">(12:30:47)</font> <b>user2:</b></font> <body>3</body><br/> -<font color="#16569E"><font size="2">(12:32:36)</font> <b>user2:</b></font> <body>3</body><br/> -<font color="#16569E"><font size="2">(12:33:25)</font> <b>user2:</b></font> <body>4</body><br/> -<font size="2">(12:46:06)</font><b> user@collabora.co.uk left the room.</b><br/> -<font size="2">(12:46:46)</font><b> user@collabora.co.uk/empathy</em>] entered the room.</b><br/> -<font size="2">(13:49:01)</font><b> user@collabora.co.uk left the room.</b><br/> diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/test@conference.collabora.co.uk.chat/2010-04-29.140846+0100BST.html b/tests/logs/purple/jabber/user@collabora.co.uk/test@conference.collabora.co.uk.chat/2010-04-29.140846+0100BST.html deleted file mode 100644 index 2018a1e..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/test@conference.collabora.co.uk.chat/2010-04-29.140846+0100BST.html +++ /dev/null @@ -1,11 +0,0 @@ -<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Conversation with test@conference.collabora.co.uk at Thu 29 Apr 2010 14:08:46 BST on user@collabora.co.uk/TEST (jabber)</title></head><body><h3>Conversation with test@conference.collabora.co.uk at Thu 29 Apr 2010 14:08:46 BST on user@collabora.co.uk/TEST (jabber)</h3> -<font size="2">(14:08:46)</font><b> User1 [<em>user@collabora.co.uk/TEST</em>] entered the room.</b><br/> -<font color="#16569E"><font size="2">(14:08:55)</font> <b>User1:</b></font> <body>retest</body><br/> -<font color="#16569E"><font size="2">(14:09:04)</font> <b>User1:</b></font> <body>ahah</body><br/> -<font size="2">(14:09:44)</font><b> User2 [<em>User2@collabora.co.uk/Kazoo</em>] entered the room.</b><br/> -<font color="#A82F2F"><font size="2">(14:10:11)</font> <b>User2:</b></font> <body>1</body><br/> -<font color="#A82F2F"><font size="2">(14:10:11)</font> <b>User2:</b></font> <body>2</body><br/> -<font color="#A82F2F"><font size="2">(14:10:11)</font> <b>User2:</b></font> <body>3</body><br/> -<font color="#A82F2F"><font size="2">(14:10:20)</font> <b>User2:</b></font> <body>4</body><br/> -<font color="#16569E"><font size="2">(14:10:26)</font> <b>User1:</b></font> <body>5</body><br/> -</body></html> diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/user2@collabora.co.uk/2010-12-10.162702+0000GMT.txt b/tests/logs/purple/jabber/user@collabora.co.uk/user2@collabora.co.uk/2010-12-10.162702+0000GMT.txt deleted file mode 100644 index 8a15801..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/user2@collabora.co.uk/2010-12-10.162702+0000GMT.txt +++ /dev/null @@ -1,3 +0,0 @@ -Conversation with user2@collabora.co.uk at Fri 10 Dec 2010 16:27:02 GMT on user@test.collabora.co.uk/TEST (jabber) -(16:27:02) User1: hi -(16:27:07) user@test.collabora.co.uk/TEST: hey you diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-10.000101+0000GMT.txt b/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-10.000101+0000GMT.txt deleted file mode 100644 index d67ac56..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-10.000101+0000GMT.txt +++ /dev/null @@ -1,3 +0,0 @@ -Conversation with user5@collabora.co.uk at Sun 10 Jan 2010 00:01:01 GMT on user@test.collabora.co.uk/TEST (jabber) -(00:01:01) User5: A -(00:01:02) user@test.collabora.co.uk/TEST: B diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-11.000101+0000GMT.txt b/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-11.000101+0000GMT.txt deleted file mode 100644 index 3bf802d..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-11.000101+0000GMT.txt +++ /dev/null @@ -1,17 +0,0 @@ -Conversation with user5@collabora.co.uk at Mon 11 Jan 2010 00:01:01 GMT on user@test.collabora.co.uk/TEST (jabber) -(00:01:01) User5: C -(00:01:02) user@test.collabora.co.uk/TEST: D -(00:01:02) user@test.collabora.co.uk/TEST: D' -(00:01:02) user@test.collabora.co.uk/TEST: D'' -(00:01:03) User5: E -(00:01:04) User5: F -(00:01:04) User5: F' -(00:01:04) User5: F'' -(00:01:05) user@test.collabora.co.uk/TEST: G -(00:01:05) user@test.collabora.co.uk/TEST: G' -(00:01:05) user@test.collabora.co.uk/TEST: G'' -(00:01:05) user@test.collabora.co.uk/TEST: G''' -(00:01:06) User5: H -(00:01:06) User5: H' -(00:01:06) User5: H'' -(00:01:06) User5: H''' diff --git a/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-14.000101+0000GMT.txt b/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-14.000101+0000GMT.txt deleted file mode 100644 index fa0ff80..0000000 --- a/tests/logs/purple/jabber/user@collabora.co.uk/user5@collabora.co.uk/2010-01-14.000101+0000GMT.txt +++ /dev/null @@ -1,12 +0,0 @@ -Conversation with user5@collabora.co.uk at Thu 14 Jan 2010 00:01:01 GMT on user@test.collabora.co.uk/TEST (jabber) -(00:01:01) User5: I -(00:01:01) User5: I' -(00:01:01) User5: I'' -(00:01:01) User5: I''' -(00:01:02) user@test.collabora.co.uk/TEST: J -(00:01:02) user@test.collabora.co.uk/TEST: J' -(00:01:03) User5: K -(00:01:04) User5: L -(00:01:04) User5: L' -(00:01:04) User5: L'' -(00:01:04) User5: L''' diff --git a/tests/suppressions/Makefile.am b/tests/suppressions/Makefile.am deleted file mode 100644 index 691047d..0000000 --- a/tests/suppressions/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = tpl.supp diff --git a/tests/suppressions/tpl.supp b/tests/suppressions/tpl.supp deleted file mode 100644 index a395e82..0000000 --- a/tests/suppressions/tpl.supp +++ /dev/null @@ -1,321 +0,0 @@ -# Valgrind error suppression file - - -# ============================= selinux ================================== - -{ - selinux getdelim - Memcheck:Leak - fun:malloc - fun:getdelim - obj:/lib/libselinux.so.1 - obj:/lib/libselinux.so.1 - obj:/lib/libselinux.so.1 -} - - - -# ============================= libc ================================== - -{ - ld.so initialization + selinux - Memcheck:Leak - ... - fun:_dl_init - obj:/lib/ld-*.so -} - -{ - 64bit ld.so initialization + selinux - Memcheck:Leak - ... - fun:_dl_init - obj:/lib64/ld-*.so -} - -{ - ld.so start - Memcheck:Cond - ... - fun:_dl_start - obj:/lib/ld-*.so -} - -{ - 64bit ld.so start - Memcheck:Cond - ... - fun:_dl_start - obj:/lib64/ld-*.so -} - -{ - dlopen initialization, triggered by handle-leak-debug code - Memcheck:Leak - ... - fun:__libc_dlopen_mode - fun:init - fun:backtrace - fun:handle_leak_debug_bt - fun:dynamic_ensure_handle - fun:tp_handle_ensure -} - -# ============================= GLib ================================== - -{ - g_set_prgname copies its argument - Memcheck:Leak - ... - fun:g_set_prgname -} - -{ - one g_get_charset per child^Wprocess - Memcheck:Leak - ... - fun:g_get_charset -} - -{ - GQuarks can't be freed - Memcheck:Leak - ... - fun:g_quark_from_static_string -} - -{ - GQuarks can't be freed - Memcheck:Leak - ... - fun:g_quark_from_string -} - -{ - interned strings can't be freed - Memcheck:Leak - ... - fun:g_intern_string -} - -{ - interned strings can't be freed - Memcheck:Leak - ... - fun:g_intern_static_string -} - -{ - shared global default g_main_context - Memcheck:Leak - ... - fun:g_main_context_new - fun:g_main_context_default -} - -{ - GTest initialization - Memcheck:Leak - ... - fun:g_test_init - fun:main -} - -{ - GTest admin - Memcheck:Leak - ... - fun:g_test_add_vtable -} - -{ - GTest pseudorandomness - Memcheck:Leak - ... - fun:g_rand_new_with_seed_array - fun:test_run_seed - ... - fun:g_test_run -} - -{ - GSLice initialization - Memcheck:Leak - ... - fun:g_malloc0 - fun:g_slice_init_nomessage - fun:g_slice_alloc -} - -# ============================= GObject =============================== - -{ - g_type_init - Memcheck:Leak - ... - fun:g_type_init -} - -{ - g_type_init_with_debug_flags - Memcheck:Leak - ... - fun:g_type_init_with_debug_flags -} - -{ - g_type_register_static - Memcheck:Leak - ... - fun:g_type_register_static -} - -{ - g_type_create_instance - Memcheck:Leak - ... - fun:g_type_create_instance -} - -{ - g_type_add_interface_static - Memcheck:Leak - ... - fun:g_type_add_interface_static -} - -{ - g_object_do_class_init - Memcheck:Leak - ... - fun:g_object_do_class_init -} - -# ============================= dbus-glib ============================= - -{ - dbus-glib, https://bugs.freedesktop.org/show_bug.cgi?id=14125 - Memcheck:Addr4 - fun:g_hash_table_foreach - obj:/usr/lib/libdbus-glib-1.so.2.1.0 - fun:g_object_run_dispose -} - -{ - registering marshallers is permanent - Memcheck:Leak - ... - fun:dbus_g_object_register_marshaller_array - fun:dbus_g_object_register_marshaller -} - -{ - dbus-glib specialized GTypes are permanent - Memcheck:Leak - ... - fun:dbus_g_type_specialized_init -} - -{ - libdbus shared connection - Memcheck:Leak - ... - fun:dbus_g_bus_get -} - -{ - dbus-gobject registrations aren't freed unless we fall off the bus - Memcheck:Leak - ... - fun:g_slist_append - fun:dbus_g_connection_register_g_object -} - -{ - DBusGProxy slots aren't freed unless we fall off the bus - Memcheck:Leak - ... - fun:dbus_connection_allocate_data_slot - ... - fun:dbus_g_proxy_constructor -} - -{ - error registrations are for life, not just for Christmas - Memcheck:Leak - ... - fun:dbus_g_error_domain_register -} - -# ============================= telepathy-glib ======================== - -{ - tp_dbus_daemon_constructor @daemons once per DBusConnection - Memcheck:Leak - ... - fun:g_slice_alloc - fun:tp_dbus_daemon_constructor -} - -{ - tp_proxy_subclass_add_error_mapping refs the enum - Memcheck:Leak - ... - fun:g_type_class_ref - fun:tp_proxy_subclass_add_error_mapping -} - -{ - tp_proxy_or_subclass_hook_on_interface_add never frees its list - Memcheck:Leak - ... - fun:tp_proxy_or_subclass_hook_on_interface_add -} - -{ - tp_dbus_daemon_constructor filter not freed til we fall off the bus - Memcheck:Leak - ... - fun:dbus_connection_add_filter - fun:tp_dbus_daemon_constructor -} - -{ - Leak in tp-glib 0.11.16 (Fedora 14) - Memcheck:Leak - ... - fun:g_simple_async_result_new - fun:tp_proxy_prepare_async -} - -# ============================= tp-logger-tests ========================== - -{ - tp_tests_object_new_static_class - Memcheck:Leak - ... - fun:tp_tests_object_new_static_class -} - -# ============================= unclassified ========================== - -{ - ld.so initialization on glibc 2.9 - Memcheck:Cond - fun:_dl_relocate_object - fun:dl_main - fun:_dl_sysdep_start - fun:_dl_start - obj:/lib/ld-2.9.so -} - -{ - ld.so initialization on glibc 2.9 - Memcheck:Cond - fun:strlen - fun:_dl_init_paths - fun:dl_main - fun:_dl_sysdep_start - fun:_dl_start - obj:/lib/ld-2.9.so -} diff --git a/tests/test-basic-connect.sh b/tests/test-basic-connect.sh deleted file mode 100644 index 93af74d..0000000 --- a/tests/test-basic-connect.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./run-with-tmp-session-bus.sh `pwd`/test-basic-connect.py BasicConnectTest diff --git a/tests/test-tpl-conf.c b/tests/test-tpl-conf.c deleted file mode 100644 index 5736356..0000000 --- a/tests/test-tpl-conf.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "config.h" - -#include <telepathy-logger/conf-internal.h> - -int -main (int argc, char **argv) -{ - TplConf *conf, *conf2; - - g_type_init (); - - conf = _tpl_conf_dup (); - - /* TplConf is a singleton, be sure both point to the same memory */ - conf2 = _tpl_conf_dup (); - g_assert (conf == conf2); - - /* unref the second singleton pointer and check that the it is still - * valid: checking correct object ref-counting after each _dup () call */ - g_object_unref (conf2); - g_assert (TPL_IS_CONF (conf)); - - /* it points to the same mem area, it should be still valid */ - g_assert (TPL_IS_CONF (conf2)); - - /* proper disposal for the singleton when no references are present */ - g_object_unref (conf); - - return 0; -} - |