[telepathy-doc/master] Remove more old examples
Davyd Madeley
davyd at madeley.id.au
Sun Apr 5 19:56:04 PDT 2009
---
docs/examples/connect/Makefile.am | 7 -
docs/examples/connect/main.c | 224 ----------------
docs/examples/list_contacts/Makefile.am | 7 -
docs/examples/list_contacts/main.c | 439 -------------------------------
docs/examples/send_message/Makefile.am | 7 -
docs/examples/send_message/main.c | 411 -----------------------------
docs/examples/set_presence/Makefile.am | 7 -
docs/examples/set_presence/main.c | 272 -------------------
8 files changed, 0 insertions(+), 1374 deletions(-)
delete mode 100644 docs/examples/connect/Makefile.am
delete mode 100644 docs/examples/connect/main.c
delete mode 100644 docs/examples/list_contacts/Makefile.am
delete mode 100644 docs/examples/list_contacts/main.c
delete mode 100644 docs/examples/send_message/Makefile.am
delete mode 100644 docs/examples/send_message/main.c
delete mode 100644 docs/examples/set_presence/Makefile.am
delete mode 100644 docs/examples/set_presence/main.c
diff --git a/docs/examples/connect/Makefile.am b/docs/examples/connect/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/connect/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/connect/main.c b/docs/examples/connect/main.c
deleted file mode 100644
index 4c6eb22..0000000
--- a/docs/examples/connect/main.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* Copyright 2008 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <telepathy-glib/connection-manager.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/util.h>
-#include <glib/gprintf.h>
-
-GMainLoop *mainloop = NULL;
-TpDBusDaemon *bus_daemon = NULL;
-TpConnection *connection = NULL;
-
-/* A utility function to make our debug output easier to read. */
-const gchar* get_reason_description (TpConnectionStatusReason reason)
-{
- switch (reason)
- {
- case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
- return "None specified";
- case TP_CONNECTION_STATUS_REASON_REQUESTED:
- return "Requested";
- case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
- return "Network error";
- case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
- return "Authentication failed";
- case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
- return "Encryption Error";
- case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
- return "Name in use";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
- return "Certificate not provided";
- case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
- return "Certificate untrusted";
- case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
- return "Certificate expired";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
- return "Certificate not activated";
- case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
- return "Certificate hostname mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
- return "Certificate fingerprint mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
- return "Cerficate is self signed";
- case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
- return "Other certificate error";
- default:
- return "Unknown reason";
- }
-}
-
-void on_connection_status_changed(TpConnection *proxy,
- guint arg_Status,
- guint arg_Reason,
- gpointer user_data,
- GObject *weak_object)
-{
- switch(arg_Status)
- {
- case TP_CONNECTION_STATUS_CONNECTED:
- g_printf ("Connection status: Connected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Disconnect the connection.
- Otherwise it will be orphaned. */
- g_printf ("DEBUG: Disconnecting.\n");
- tp_cli_connection_call_disconnect (connection, -1, NULL, NULL,
- NULL, NULL); /* Also destroys the connection object. */
- connection = NULL;
-
- break;
-
- case TP_CONNECTION_STATUS_CONNECTING:
- g_printf ("Connection status: Connecting (reason: %s)\n", get_reason_description (arg_Reason));
-
- break;
-
- case TP_CONNECTION_STATUS_DISCONNECTED:
- g_printf ("Connection status: Disconnected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Finish with the connection object: */
- if (connection)
- {
- g_object_unref (connection);
- connection = NULL;
- }
-
- /* Stop the application: */
- g_main_loop_quit (mainloop);
-
- break;
-
- default:
- g_printf ("Connection status: Unknown status.\n");
- break;
- }
-}
-
-void
-got_connection (TpConnectionManager *connection_manager,
- const gchar *service_name,
- const gchar *object_path,
- const GError *request_connection_error,
- gpointer user_data,
- GObject *weak_object)
-{
- TpProxySignalConnection *signal_connection;
- GError *error = NULL;
-
- if (request_connection_error != NULL)
- {
- g_printf ("RequestConnection failed: %s\n",
- request_connection_error->message);
- g_main_loop_quit (mainloop);
- return;
- }
-
- connection = tp_connection_new (bus_daemon, service_name, object_path, &error);
-
- if (error != NULL)
- {
- g_printf ("tp_connection_new() failed: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- g_printf("DEBUG: Connection created.\n");
-
- /* React to connection status changes,
- * including errors when we try to connect: */
- signal_connection = tp_cli_connection_connect_to_status_changed (connection,
- &on_connection_status_changed,
- NULL, /* user_data */
- NULL, /* destroy_callback */
- NULL, /* weak_object */
- &error);
-
- if (error)
- {
- g_printf ("couldn't connect to StatusChanged: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- /* Connect the connection: */
- g_printf ("DEBUG: Calling Connect().\n");
- tp_cli_connection_call_connect (connection, -1, NULL, NULL, NULL, NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- g_type_init ();
-
- /* Create the main loop: */
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus_daemon = tp_dbus_daemon_new (tp_get_bus ());
-
- /* Get the connection manager: */
- GError *error = NULL;
- TpConnectionManager *connection_manager =
- tp_connection_manager_new (bus_daemon, "gabble", NULL, &error);
- if (error)
- {
- g_printf ("tp_connection_manager_new() failed: %s\n", error->message);
- g_clear_error (&error);
- return 1;
- }
-
- /* Get the connection : */
- GHashTable *parameters = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "murrayc at murrayc.com");
- g_hash_table_insert (parameters, "account", value);
-
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "passwordTODO");
- g_hash_table_insert (parameters, "password", value);
-
- /* This jabber-specific parameter can avoid clashes with
- other telepathy clients that use the default jabber
- resource name. */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "telepathy-doc connect example");
- g_hash_table_insert (parameters, "resource", value);
-
- /* Call RequestConnection; it will return asynchronously by calling got_connection */
- tp_cli_connection_manager_call_request_connection (connection_manager, -1,
- "jabber", parameters, got_connection, NULL, NULL, NULL);
-
- g_hash_table_unref (parameters);
- parameters = NULL;
-
-
- /* Run the main loop,
- * to keep our application alive while we wait for responses from telepathy.
- * This function returns when we call g_main_loop_quit() from elsewhere.
- */
- g_main_loop_run (mainloop);
-
- /* Clean up: */
- g_object_unref (connection_manager);
- g_main_loop_unref (mainloop);
- g_object_unref (bus_daemon);
-
- return 0;
-}
diff --git a/docs/examples/list_contacts/Makefile.am b/docs/examples/list_contacts/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/list_contacts/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/list_contacts/main.c b/docs/examples/list_contacts/main.c
deleted file mode 100644
index bbcb341..0000000
--- a/docs/examples/list_contacts/main.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/* Copyright 2008 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <telepathy-glib/connection-manager.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/contact.h>
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/interfaces.h>
-#include <telepathy-glib/util.h>
-#include <glib/gprintf.h>
-
-//TODO: Pass these around in user_data:
-GMainLoop *mainloop = NULL;
-TpDBusDaemon *bus_daemon = NULL;
-TpConnection *connection = NULL;
-guint contact_list_handle = 0;
-const TpIntSet* channel_members_set = NULL;
-
-void disconnect ()
-{
- if (!connection)
- return;
-
- g_printf ("DEBUG: Disconnecting.\n");
- tp_cli_connection_call_disconnect (connection, -1, NULL, NULL,
- NULL, NULL); /* Also destroys the connection object. */
- connection = NULL;
-}
-
-void show_contact_information (TpContact *contact)
-{
- g_printf ("Contact: Identifier=%s\n",
- tp_contact_get_identifier (contact));
-
- g_printf (" Alias=%s\n",
- tp_contact_get_alias (contact));
-
- g_printf (" Presence Status=%s\n",
- tp_contact_get_presence_status (contact));
-}
-
-void on_connection_get_contacts_by_handle (TpConnection *connection,
- guint n_contacts,
- TpContact * const *contacts,
- guint n_failed,
- const TpHandle *failed,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- g_printf ("tp_connection_get_contacts_by_handle() failed: %s\n", error->message);
-
- guint i = 0;
- for (i = 0; i < n_contacts; ++i)
- {
- TpContact *contact = contacts[i];
-
- if (contact)
- show_contact_information (contact);
- }
-
- /* Disconnect the connection.
- Otherwise it will be orphaned. */
- disconnect();
-}
-
-
-void on_connection_ready (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- if (error)
- {
- g_printf ("tp_connection_call_when_ready() failed: %s\n", error->message);
- return;
- }
-
- /* Actually get the information now that the connection is ready: */
-
-
- /* Get a GArray instead of a TpIntSet,
- * so we can easily create a normal array: */
- GArray *members_array = g_array_new (FALSE, TRUE, sizeof(guint));
- TpIntSetIter iter = TP_INTSET_ITER_INIT (channel_members_set );
- while (tp_intset_iter_next (&iter))
- {
- g_array_append_val (members_array, iter.element);
- g_printf("DEBUG: handle: %d\n", iter.element);
- }
- channel_members_set = NULL; /* We don't need this anymore. */
-
- g_printf("DEBUG: members_array size=%u\n", members_array->len);
-
-
- /* Get information about each contact: */
- guint n_handles = members_array->len;
- TpHandle* handles = (TpHandle*)g_array_free (members_array, FALSE);
- members_array = NULL;
-
- /* The extra optional information that we are interested in: */
- TpContactFeature features[] = {TP_CONTACT_FEATURE_ALIAS,
- TP_CONTACT_FEATURE_AVATAR_TOKEN, TP_CONTACT_FEATURE_PRESENCE};
-
- g_printf ("DEBUG: Calling tp_connection_get_contacts_by_handle()\n");
-
- tp_connection_get_contacts_by_handle (connection,
- n_handles, handles,
- sizeof (features) / sizeof(TpContactFeature), features,
- &on_connection_get_contacts_by_handle,
- NULL, /* user_data */
- NULL, /* destroy */
- NULL /* weak_object */);
- g_free (handles);
-}
-
-void on_channel_ready (TpChannel *channel,
- const GError *error,
- gpointer user_data)
-{
- if (error)
- {
- g_printf ("tp_channel_call_when_ready() failed: %s\n", error->message);
- return;
- }
-
-
- /* List the channel members: */
- channel_members_set = tp_channel_group_get_members (channel);
- if (!channel_members_set )
- {
- g_printf ("tp_channel_group_get_members() returned NULL.\n");
- return;
- }
-
- g_printf("DEBUG: Number of members: %u\n", tp_intset_size (channel_members_set ));
-
-
- /* tp_connection_get_contacts_by_handle() requires the connection to be
- * ready: */
- tp_connection_call_when_ready (connection,
- &on_connection_ready,
- NULL);
-}
-
-void on_connection_request_channel (TpConnection *proxy,
- const gchar *channel_dbus_path,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- {
- g_printf ("tp_cli_connection_call_request_channel() failed: %s\n", error->message);
- return;
- }
-
- g_printf("DEBUG: channel D-Bus path received: %s\n", channel_dbus_path);
-
-
- /* Create the channel proxy for the ContactList's Group interface: */
- GError *error_inner = NULL;
- TpChannel *channel = tp_channel_new (connection,
- channel_dbus_path, /* object_path */
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, /* optional_channel_type */
- TP_HANDLE_TYPE_LIST, /* optional_handle_type */
- contact_list_handle, /* optional_handle */
- &error_inner);
-
- if (error_inner)
- {
- g_printf ("tp_channel_new() failed: %s\n", error_inner->message);
- g_clear_error (&error_inner);
- return;
- }
-
- /* Wait until the channel is ready for use: */
- tp_channel_call_when_ready (channel,
- &on_channel_ready,
- NULL);
-}
-
-void on_connection_request_handles (TpConnection *proxy,
- const GArray *handles_array,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- {
- g_printf ("tp_cli_connection_call_request_handles() failed: %s\n", error->message);
- return;
- }
-
- if (!handles_array || handles_array->len == 0)
- {
- g_printf ("No handles received.\n");
- return;
- }
-
- contact_list_handle = g_array_index (handles_array, guint, 0);
- g_printf("DEBUG: Count of handles received: %u\n", handles_array->len);
- g_printf("DEBUG: subscribe handle received: %u\n", contact_list_handle);
-
-
- /* Request the channel: */
- tp_cli_connection_call_request_channel (connection,
- -1, /* timeout */
- TP_IFACE_CHANNEL_TYPE_CONTACT_LIST, /* in_Type */
- TP_HANDLE_TYPE_LIST, /* in_Handle_Type - the correct type for ContactList */
- contact_list_handle, /* in_Handle */
- TRUE, /* in_Suppress_Handler */
- &on_connection_request_channel, NULL, /* user_data */
- NULL, /* destroy */
- NULL /* weak_ref */);
-}
-
-
-/* A utility function to make our debug output easier to read. */
-const gchar* get_reason_description (TpConnectionStatusReason reason)
-{
- switch (reason)
- {
- case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
- return "None specified";
- case TP_CONNECTION_STATUS_REASON_REQUESTED:
- return "Requested";
- case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
- return "Network error";
- case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
- return "Authentication failed";
- case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
- return "Encryption Error";
- case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
- return "Name in use";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
- return "Certificate not provided";
- case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
- return "Certificate untrusted";
- case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
- return "Certificate expired";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
- return "Certificate not activated";
- case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
- return "Certificate hostname mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
- return "Certificate fingerprint mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
- return "Cerficate is self signed";
- case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
- return "Other certificate error";
- default:
- return "Unknown reason";
- }
-}
-
-void on_connection_status_changed (TpConnection *proxy,
- guint arg_Status,
- guint arg_Reason,
- gpointer user_data,
- GObject *weak_object)
-{
- switch(arg_Status)
- {
- case TP_CONNECTION_STATUS_CONNECTED:
- g_printf ("Connection status: Connected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Get the contacts information for this connection,
- * and then disconnect the connection: */
-
- /* Request the handle for the ContactList, which lists.
- * We need this handle to request the Group channel: */
- const gchar **identifier_names = (const gchar **)g_malloc0(2 * sizeof(char*));
- identifier_names[0] = "subscribe";
- tp_cli_connection_call_request_handles (connection,
- -1, /* timeout */
- TP_HANDLE_TYPE_LIST, /* in_Handle_Type - the correct type for ContactList for server-defined lists, such as "subscribe". */
- identifier_names, /* in_Names */
- &on_connection_request_handles, NULL, /* user_data */
- NULL, /* destroy */
- NULL /* weak_ref */);
-
- break;
-
- case TP_CONNECTION_STATUS_CONNECTING:
- g_printf ("Connection status: Connecting (reason: %s)\n", get_reason_description (arg_Reason));
-
- break;
-
- case TP_CONNECTION_STATUS_DISCONNECTED:
- g_printf ("Connection status: Disconnected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Finish with the connection object: */
- if (connection)
- {
- g_object_unref (connection);
- connection = NULL;
- }
-
- /* Stop the application: */
- g_main_loop_quit (mainloop);
-
- break;
-
- default:
- g_printf ("Connection status: Unknown status.\n");
- break;
- }
-}
-
-void
-got_connection (TpConnectionManager *connection_manager,
- const gchar *service_name,
- const gchar *object_path,
- const GError *request_connection_error,
- gpointer user_data,
- GObject *weak_object)
-{
- TpProxySignalConnection *signal_connection;
- GError *error = NULL;
-
- if (request_connection_error != NULL)
- {
- g_printf ("RequestConnection failed: %s\n",
- request_connection_error->message);
- g_main_loop_quit (mainloop);
- return;
- }
-
- connection = tp_connection_new (bus_daemon, service_name, object_path, &error);
-
- if (error != NULL)
- {
- g_printf ("tp_connection_new() failed: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- g_printf("DEBUG: Connection created.\n");
-
- /* React to connection status changes,
- * including errors when we try to connect: */
- signal_connection = tp_cli_connection_connect_to_status_changed (connection,
- &on_connection_status_changed,
- NULL, /* user_data */
- NULL, /* destroy_callback */
- NULL, /* weak_object */
- &error);
-
- if (error)
- {
- g_printf ("couldn't connect to StatusChanged: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- /* Connect the connection: */
- g_printf ("DEBUG: Calling Connect().\n");
- tp_cli_connection_call_connect (connection, -1, NULL, NULL, NULL, NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- g_type_init ();
-
- /* Create the main loop: */
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus_daemon = tp_dbus_daemon_new (tp_get_bus ());
-
- /* Get the connection manager: */
- GError *error = NULL;
- TpConnectionManager *connection_manager =
- tp_connection_manager_new (bus_daemon, "gabble", NULL, &error);
- if (error)
- {
- g_printf ("tp_connection_manager_new() failed: %s\n", error->message);
- g_clear_error (&error);
- return 1;
- }
-
- /* Get the connection : */
- GHashTable *parameters = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "murrayc at murrayc.com");
- g_hash_table_insert (parameters, "account", value);
-
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "passwordTODO");
- g_hash_table_insert (parameters, "password", value);
-
- /* This jabber-specific parameter can avoid clashes with
- other telepathy clients that use the default jabber
- resource name. */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "telepathy-doc list_contacts example");
- g_hash_table_insert (parameters, "resource", value);
-
- /* Call RequestConnection; it will return asynchronously by calling got_connection */
- tp_cli_connection_manager_call_request_connection (connection_manager, -1,
- "jabber", parameters, got_connection, NULL, NULL, NULL);
-
- g_hash_table_unref (parameters);
- parameters = NULL;
-
-
- /* Run the main loop,
- * to keep our application alive while we wait for responses from telepathy.
- * This function returns when we call g_main_loop_quit() from elsewhere.
- */
- g_main_loop_run (mainloop);
-
-
- /* Clean up: */
- g_object_unref (connection_manager);
- g_main_loop_unref (mainloop);
- g_object_unref (bus_daemon);
-
- return 0;
-}
diff --git a/docs/examples/send_message/Makefile.am b/docs/examples/send_message/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/send_message/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/send_message/main.c b/docs/examples/send_message/main.c
deleted file mode 100644
index 24f219b..0000000
--- a/docs/examples/send_message/main.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/* Copyright 2008 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <telepathy-glib/connection-manager.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/contact.h>
-#include <telepathy-glib/channel.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/interfaces.h> /* For TP_IFACE_CHANNEL_TYPE_TEXT */
-#include <glib/gprintf.h>
-
-GMainLoop *mainloop = NULL;
-TpDBusDaemon *bus_daemon = NULL;
-TpConnection *connection = NULL;
-TpContact *contact = NULL;
-TpChannel *text_channel = NULL;
-
-/* A utility function to make our debug output easier to read. */
-const gchar* get_reason_description (TpConnectionStatusReason reason)
-{
- switch (reason)
- {
- case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
- return "None specified";
- case TP_CONNECTION_STATUS_REASON_REQUESTED:
- return "Requested";
- case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
- return "Network error";
- case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
- return "Authentication failed";
- case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
- return "Encryption Error";
- case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
- return "Name in use";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
- return "Certificate not provided";
- case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
- return "Certificate untrusted";
- case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
- return "Certificate expired";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
- return "Certificate not activated";
- case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
- return "Certificate hostname mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
- return "Certificate fingerprint mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
- return "Cerficate is self signed";
- case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
- return "Other certificate error";
- default:
- return "Unknown reason";
- }
-}
-
-void on_send (TpChannel *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- {
- g_printf ("tp_cli_channel_type_text_call_send () failed: %s\n", error->message);
- return;
- }
-
- g_printf("DEBUG: Message sent.\n");
-
- /* Disconnect the connection.
- Otherwise it will be orphaned. */
- g_printf ("DEBUG: Disconnecting.\n");
- tp_cli_connection_call_disconnect (connection, -1, NULL, NULL,
- NULL, NULL); /* Also destroys the connection object. */
- connection = NULL;
-}
-
-void on_text_channel_is_ready (TpChannel *channel,
- const GError *error,
- gpointer user_data)
-{
- g_printf("DEBUG: on_text_channel_is_ready().\n");
-
-
- if (error)
- {
- g_printf ("tp_channel_call_when_ready () failed: %s\n", error->message);
- return;
- }
-
- g_printf("DEBUG: Text channel is ready.\n");
-
- //Send a message:
-
- TpProxyPendingCall* pending = tp_cli_channel_type_text_call_send (channel,
- -1, /* timeout */
- 0, /* Channel_Text_Message_Type_Normal */
- "Hello from Murray's telepathy example. Send murrayc at openismus.com an email if this arrived.",
- &on_send,
- NULL, NULL, NULL);
-}
-
-void on_connection_create_channel(TpConnection *proxy,
- const gchar *object_path,
- GHashTable *out_Properties,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- {
- g_printf ("tp_cli_connection_interface_requests_call_create_channel () failed: %s\n", error->message);
- return;
- }
-
- g_printf("DEBUG: Text channel created.\n");
-
- /* Create the proxy object for the channel: */
- GError *inner_error = NULL;
- int handle = tp_contact_get_handle (contact);
- text_channel = tp_channel_new (connection,
- object_path,
- TP_IFACE_CHANNEL_TYPE_TEXT,
- TP_HANDLE_TYPE_CONTACT,
- handle,
- &inner_error);
-
- if (inner_error)
- {
- g_printf ("tp_channel_new () failed: %s\n", error->message);
- g_clear_error (&inner_error);
- return;
- }
-
- /* Wait for the channel to be ready: */
- tp_channel_call_when_ready (text_channel, on_text_channel_is_ready, NULL);
-}
-
-void on_get_contacts_by_id (TpConnection *connection,
- guint n_contacts,
- TpContact * const *contacts,
- const gchar * const *requested_ids,
- GHashTable *failed_id_errors,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error)
- {
- g_printf ("tp_connection_get_contacts_by_id () failed: %s\n", error->message);
- return;
- }
-
- /* We only requested one contact: */
- if(n_contacts < 1)
- {
- g_printf ("tp_connection_get_contacts_by_id () returned no contacts\n");
- return;
- }
-
- contact = contacts[0];
- if(!contact)
- {
- g_printf ("tp_connection_get_contacts_by_id () returned NULL contact\n");
- return;
- }
-
- /* Reference this because we use it later: */
- g_object_ref(contact);
-
- g_printf("DEBUG: Contact found: %p: %s.\n", contact, tp_contact_get_identifier (contact));
-
-
- //Get a text Channel for this contact:
- GHashTable* properties = g_hash_table_new (NULL, NULL);
-
- GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_TEXT); /* Rather than streamed media, or a contact list, for instance. */
- g_hash_table_insert (properties, TP_IFACE_CHANNEL ".ChannelType", value);
-
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, tp_contact_get_identifier (contact));
- g_hash_table_insert (properties, TP_IFACE_CHANNEL ".TargetID", value);
-
- /* Note that we must use g_value_set_int() instead of g_value_set_enum()
- * because these enums have no GTypes:
- * https://bugs.freedesktop.org/show_bug.cgi?id=18055
- */
- GValue *value_enum = tp_g_value_slice_new (G_TYPE_INT);
- g_printf("DEBUG: TP_HANDLE_TYPE_CONTACT=%d\n", TP_HANDLE_TYPE_CONTACT);
- g_value_set_int (value_enum, TP_HANDLE_TYPE_CONTACT); /* Rather than a ROOM. */
- g_hash_table_insert (properties, TP_IFACE_CHANNEL ".TargetHandleType", value_enum);
-
- /* Note that this uses the new Requests interface, which is not yet
- * implemented by all Telepathy ConnectionManagers.
- * The old way (working with all ConnectionManagers), was the RequestChannel
- * interface, via tp_cli_connection_call_request_channel().
- */
- g_printf("DEBUG: Calling tp_cli_connection_interface_requests_call_create_channel().\n");
- tp_cli_connection_interface_requests_call_create_channel (connection,
- -1, /* timeout */
- properties,
- &on_connection_create_channel,
- NULL, NULL, NULL);
- g_printf("DEBUG: Called tp_cli_connection_interface_requests_call_create_channel().\n");
-}
-
-void on_connection_ready (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- if (error)
- {
- g_printf ("tp_connection_call_when_ready() failed: %s\n", error->message);
- return;
- }
-
- //This crashes:
- const gchar * ids[1];
- ids[0] = "someoneorother at jabber.org";
- tp_connection_get_contacts_by_id (connection,
- 1, ids,
- 0, NULL, /* features */
- &on_get_contacts_by_id,
- NULL, NULL, NULL);
-}
-
-void on_connection_status_changed(TpConnection *proxy,
- guint arg_Status,
- guint arg_Reason,
- gpointer user_data,
- GObject *weak_object)
-{
- switch(arg_Status)
- {
- case TP_CONNECTION_STATUS_CONNECTED:
- g_printf ("Connection status: Connected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Set the presence: */
-
- /* Most functions require the connection to be ready: */
- tp_connection_call_when_ready (connection,
- &on_connection_ready,
- NULL);
-
- break;
-
- case TP_CONNECTION_STATUS_CONNECTING:
- g_printf ("Connection status: Connecting (reason: %s)\n", get_reason_description (arg_Reason));
-
- break;
-
- case TP_CONNECTION_STATUS_DISCONNECTED:
- g_printf ("Connection status: Disconnected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Finish with the connection object: */
- if (connection)
- {
- g_object_unref (connection);
- connection = NULL;
- }
-
- /* Stop the application: */
- g_main_loop_quit (mainloop);
-
- break;
-
- default:
- g_printf ("Connection status: Unknown status.\n");
- break;
- }
-}
-
-void
-got_connection (TpConnectionManager *connection_manager,
- const gchar *service_name,
- const gchar *object_path,
- const GError *request_connection_error,
- gpointer user_data,
- GObject *weak_object)
-{
- TpProxySignalConnection *signal_connection;
- GError *error = NULL;
-
- if (request_connection_error != NULL)
- {
- g_printf ("RequestConnection failed: %s\n",
- request_connection_error->message);
- g_main_loop_quit (mainloop);
- return;
- }
-
- connection = tp_connection_new (bus_daemon, service_name, object_path, &error);
-
- if (error != NULL)
- {
- g_printf ("tp_connection_new() failed: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- g_printf("DEBUG: Connection created.\n");
-
- /* React to connection status changes,
- * including errors when we try to connect: */
- signal_connection = tp_cli_connection_connect_to_status_changed (connection,
- &on_connection_status_changed,
- NULL, /* user_data */
- NULL, /* destroy_callback */
- NULL, /* weak_object */
- &error);
-
- if (error)
- {
- g_printf ("couldn't connect to StatusChanged: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- /* Connect the connection: */
- g_printf ("DEBUG: Calling Connect().\n");
- tp_cli_connection_call_connect (connection, -1, NULL, NULL, NULL, NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- g_type_init ();
-
- /* Create the main loop: */
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus_daemon = tp_dbus_daemon_new (tp_get_bus ());
-
- /* Get the connection manager: */
- GError *error = NULL;
- TpConnectionManager *connection_manager =
- tp_connection_manager_new (bus_daemon, "gabble", NULL, &error);
- if (error)
- {
- g_printf ("tp_connection_manager_new() failed: %s\n", error->message);
- g_clear_error (&error);
- return 1;
- }
-
- /* Get the connection : */
- GHashTable *parameters = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "murrayc at murrayc.com");
- g_hash_table_insert (parameters, "account", value);
-
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "passwordTODO");
- g_hash_table_insert (parameters, "password", value);
-
- /* This jabber-specific parameter can avoid clashes with
- other telepathy clients that use the default jabber
- resource name. */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "telepathy-doc send_message example");
- g_hash_table_insert (parameters, "resource", value);
-
-
- /* Call RequestConnection; it will return asynchronously by calling got_connection */
- tp_cli_connection_manager_call_request_connection (connection_manager, -1,
- "jabber", parameters, got_connection, NULL, NULL, NULL);
-
- g_hash_table_unref (parameters);
- parameters = NULL;
-
-
- /* Run the main loop,
- * to keep our application alive while we wait for responses from telepathy.
- * This function returns when we call g_main_loop_quit() from elsewhere.
- */
- g_main_loop_run (mainloop);
-
-
- /* Clean up: */
- if (text_channel)
- g_object_unref (text_channel);
-
- if (contact)
- g_object_unref (contact);
-
- if (connection)
- g_object_unref (connection);
-
- g_object_unref (connection_manager);
- g_main_loop_unref (mainloop);
- g_object_unref (bus_daemon);
-
- return 0;
-}
diff --git a/docs/examples/set_presence/Makefile.am b/docs/examples/set_presence/Makefile.am
deleted file mode 100644
index d0a304f..0000000
--- a/docs/examples/set_presence/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-include $(top_srcdir)/docs/examples/Makefile.am_fragment
-
-#Build the executable, but don't install it.
-noinst_PROGRAMS = example
-
-example_SOURCES = main.c
-
diff --git a/docs/examples/set_presence/main.c b/docs/examples/set_presence/main.c
deleted file mode 100644
index 9d80f01..0000000
--- a/docs/examples/set_presence/main.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/* Copyright 2008 Collabora Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <telepathy-glib/connection-manager.h>
-#include <telepathy-glib/connection.h>
-#include <telepathy-glib/util.h>
-#include <glib/gprintf.h>
-
-GMainLoop *mainloop = NULL;
-TpDBusDaemon *bus_daemon = NULL;
-TpConnection *connection = NULL;
-
-/* A utility function to make our debug output easier to read. */
-const gchar* get_reason_description (TpConnectionStatusReason reason)
-{
- switch (reason)
- {
- case TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED:
- return "None specified";
- case TP_CONNECTION_STATUS_REASON_REQUESTED:
- return "Requested";
- case TP_CONNECTION_STATUS_REASON_NETWORK_ERROR:
- return "Network error";
- case TP_CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED:
- return "Authentication failed";
- case TP_CONNECTION_STATUS_REASON_ENCRYPTION_ERROR:
- return "Encryption Error";
- case TP_CONNECTION_STATUS_REASON_NAME_IN_USE:
- return "Name in use";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_PROVIDED:
- return "Certificate not provided";
- case TP_CONNECTION_STATUS_REASON_CERT_UNTRUSTED:
- return "Certificate untrusted";
- case TP_CONNECTION_STATUS_REASON_CERT_EXPIRED:
- return "Certificate expired";
- case TP_CONNECTION_STATUS_REASON_CERT_NOT_ACTIVATED:
- return "Certificate not activated";
- case TP_CONNECTION_STATUS_REASON_CERT_HOSTNAME_MISMATCH:
- return "Certificate hostname mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_FINGERPRINT_MISMATCH:
- return "Certificate fingerprint mismatch";
- case TP_CONNECTION_STATUS_REASON_CERT_SELF_SIGNED:
- return "Cerficate is self signed";
- case TP_CONNECTION_STATUS_REASON_CERT_OTHER_ERROR:
- return "Other certificate error";
- default:
- return "Unknown reason";
- }
-}
-
-void on_connection_set_presence(TpConnection *proxy,
- const GError *error,
- gpointer user_data,
- GObject *weak_object)
-{
- if (error != NULL)
- {
- g_printf ("tp_cli_connection_interface_simple_presence_call_set_presence() failed: %s\n", error->message);
- g_main_loop_quit (mainloop);
- return;
- }
-
- g_printf ("Presence set.\n");
-
-
- /* Disconnect the connection now that our example has finished.
- Otherwise it will be orphaned. */
- g_printf ("DEBUG: Disconnecting.\n");
- tp_cli_connection_call_disconnect (connection, -1, NULL, NULL,
- NULL, NULL); /* Also destroys the connection object. */
- connection = NULL;
-}
-
-
-void on_connection_ready (TpConnection *connection,
- const GError *error,
- gpointer user_data)
-{
- if (error)
- {
- g_printf ("tp_connection_call_when_ready() failed: %s\n", error->message);
- return;
- }
-
- /* Actually set the presence: */
- /* See https://bugs.freedesktop.org/show_bug.cgi?id=19097 about the
- * difficulty of discovering valid status strings.
- */
- tp_cli_connection_interface_simple_presence_call_set_presence (
- connection,
- -1, /* timeout */
- "away",
- "Gone fishing",
- &on_connection_set_presence,
- NULL, NULL, NULL);
-}
-
-void on_connection_status_changed(TpConnection *proxy,
- guint arg_Status,
- guint arg_Reason,
- gpointer user_data,
- GObject *weak_object)
-{
- switch(arg_Status)
- {
- case TP_CONNECTION_STATUS_CONNECTED:
- g_printf ("Connection status: Connected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Set the presence: */
-
- /* tp_cli_connection_interface_simple_presence_call_set_presence() requires the connection to be
- * ready: */
- tp_connection_call_when_ready (connection,
- &on_connection_ready,
- NULL);
-
- break;
-
- case TP_CONNECTION_STATUS_CONNECTING:
- g_printf ("Connection status: Connecting (reason: %s)\n", get_reason_description (arg_Reason));
-
- break;
-
- case TP_CONNECTION_STATUS_DISCONNECTED:
- g_printf ("Connection status: Disconnected (reason: %s)\n", get_reason_description (arg_Reason));
-
- /* Finish with the connection object: */
- if (connection)
- {
- g_object_unref (connection);
- connection = NULL;
- }
-
- /* Stop the application: */
- g_main_loop_quit (mainloop);
-
- break;
-
- default:
- g_printf ("Connection status: Unknown status.\n");
- break;
- }
-}
-
-void
-got_connection (TpConnectionManager *connection_manager,
- const gchar *service_name,
- const gchar *object_path,
- const GError *request_connection_error,
- gpointer user_data,
- GObject *weak_object)
-{
- TpProxySignalConnection *signal_connection;
- GError *error = NULL;
-
- if (request_connection_error != NULL)
- {
- g_printf ("RequestConnection failed: %s\n",
- request_connection_error->message);
- g_main_loop_quit (mainloop);
- return;
- }
-
- connection = tp_connection_new (bus_daemon, service_name, object_path, &error);
-
- if (error != NULL)
- {
- g_printf ("tp_connection_new() failed: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- g_printf("DEBUG: Connection created.\n");
-
- /* React to connection status changes,
- * including errors when we try to connect: */
- signal_connection = tp_cli_connection_connect_to_status_changed (connection,
- &on_connection_status_changed,
- NULL, /* user_data */
- NULL, /* destroy_callback */
- NULL, /* weak_object */
- &error);
-
- if (error)
- {
- g_printf ("couldn't connect to StatusChanged: %s\n", error->message);
- g_clear_error (&error);
- g_main_loop_quit (mainloop);
- return;
- }
-
- /* Connect the connection: */
- g_printf ("DEBUG: Calling Connect().\n");
- tp_cli_connection_call_connect (connection, -1, NULL, NULL, NULL, NULL);
-}
-
-
-int
-main (int argc, char **argv)
-{
- g_type_init ();
-
- /* Create the main loop: */
- mainloop = g_main_loop_new (NULL, FALSE);
-
- bus_daemon = tp_dbus_daemon_new (tp_get_bus ());
-
- /* Get the connection manager: */
- GError *error = NULL;
- TpConnectionManager *connection_manager =
- tp_connection_manager_new (bus_daemon, "gabble", NULL, &error);
- if (error)
- {
- g_printf ("tp_connection_manager_new() failed: %s\n", error->message);
- g_clear_error (&error);
- return 1;
- }
-
- /* Get the connection : */
- GHashTable *parameters = g_hash_table_new_full (NULL, NULL, NULL,
- (GDestroyNotify) tp_g_value_slice_free);
-
- GValue *value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "murrayc at murrayc.com");
- g_hash_table_insert (parameters, "account", value);
-
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "passwordTODO");
- g_hash_table_insert (parameters, "password", value);
-
- /* This jabber-specific parameter can avoid clashes with
- other telepathy clients that use the default jabber
- resource name. */
- value = tp_g_value_slice_new (G_TYPE_STRING);
- g_value_set_static_string (value, "telepathy-doc set_presence example");
- g_hash_table_insert (parameters, "resource", value);
-
- /* Call RequestConnection; it will return asynchronously by calling got_connection */
- tp_cli_connection_manager_call_request_connection (connection_manager, -1,
- "jabber", parameters, got_connection, NULL, NULL, NULL);
-
- g_hash_table_unref (parameters);
- parameters = NULL;
-
-
- /* Run the main loop,
- * to keep our application alive while we wait for responses from telepathy.
- * This function returns when we call g_main_loop_quit() from elsewhere.
- */
- g_main_loop_run (mainloop);
-
- /* Clean up: */
- g_object_unref (connection_manager);
- g_main_loop_unref (mainloop);
- g_object_unref (bus_daemon);
-
- return 0;
-}
--
1.5.6.5
More information about the telepathy-commits
mailing list