Blame telepathy-account-widgets/tp-account-widgets/tpaw-utils.h

Packit 79f644
/*
Packit 79f644
 * Copyright (C) 2007-2013 Collabora Ltd.
Packit 79f644
 * Copyright (C) 2005-2006 Imendio AB
Packit 79f644
 * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com>
Packit 79f644
 * Copyright (C) 2009 Steve Frécinaux <code@istique.net>
Packit 79f644
 *
Packit 79f644
 * Authors: Marco Barisione <marco.barisione@collabora.co.uk>
Packit 79f644
 *          Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Packit 79f644
 *          Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Packit 79f644
 *          Xavier Claessens <xavier.claessens@collabora.co.uk>
Packit 79f644
 *          Mikael Hallendal <micke@imendio.com>
Packit 79f644
 *          Richard Hult <richard@imendio.com>
Packit 79f644
 *          Martyn Russell <martyn@imendio.com>
Packit 79f644
 *          Steve Frécinaux <code@istique.net>
Packit 79f644
 *          Emanuele Aina <emanuele.aina@collabora.co.uk>
Packit 79f644
 *
Packit 79f644
 * This library is free software; you can redistribute it and/or
Packit 79f644
 * modify it under the terms of the GNU Lesser General Public
Packit 79f644
 * License as published by the Free Software Foundation; either
Packit 79f644
 * version 2.1 of the License, or (at your option) any later version.
Packit 79f644
 *
Packit 79f644
 * This library is distributed in the hope that it will be useful,
Packit 79f644
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 79f644
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 79f644
 * Lesser General Public License for more details.
Packit 79f644
 *
Packit 79f644
 * You should have received a copy of the GNU Lesser General Public
Packit 79f644
 * License along with this library; if not, write to the Free Software
Packit 79f644
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
Packit 79f644
 */
Packit 79f644
Packit 79f644
#ifndef __TPAW_UTILS_H__
Packit 79f644
#define __TPAW_UTILS_H__
Packit 79f644
Packit 79f644
#include <glib.h>
Packit 79f644
#include <gtk/gtk.h>
Packit 79f644
#include <libxml/tree.h>
Packit 79f644
#include <telepathy-glib/telepathy-glib.h>
Packit 79f644
Packit 79f644
G_BEGIN_DECLS
Packit 79f644
Packit 79f644
#define TPAW_STR_EMPTY(s) ((s) == NULL || (s)[0] == '\0')
Packit 79f644
Packit 79f644
#define TPAW_ACCOUNT_WIDGETS_RESOURCES_PREFIX "/org/gnome/AccountWidgets"
Packit 79f644
Packit 79f644
void tpaw_connect_new_account (TpAccount *account,
Packit 79f644
    TpAccountManager *account_manager);
Packit 79f644
Packit 79f644
gchar *tpaw_protocol_icon_name (const gchar *protocol);
Packit 79f644
const gchar *tpaw_protocol_name_to_display_name (const gchar *proto_name);
Packit 79f644
const gchar *tpaw_service_name_to_display_name (const gchar *proto_name);
Packit 79f644
Packit 79f644
/* XML */
Packit 79f644
gboolean tpaw_xml_validate_from_resource (xmlDoc *doc,
Packit 79f644
    const gchar *dtd_resourcename);
Packit 79f644
Packit 79f644
/* Windows */
Packit 79f644
void tpaw_window_present (GtkWindow *window);
Packit 79f644
void tpaw_window_present_with_time (GtkWindow *window,
Packit 79f644
    guint32 timestamp);
Packit 79f644
GtkWindow * tpaw_get_toplevel_window (GtkWidget *widget);
Packit 79f644
Packit 79f644
/* URL */
Packit 79f644
gchar * tpaw_make_absolute_url (const gchar *url);
Packit 79f644
gchar * tpaw_make_absolute_url_len (const gchar *url,
Packit 79f644
    guint len);
Packit 79f644
Packit 79f644
/* Copied from wocky/wocky-utils.h */
Packit 79f644
Packit 79f644
#define tpaw_implement_finish_void(source, tag) \
Packit 79f644
    if (g_simple_async_result_propagate_error (\
Packit 79f644
      G_SIMPLE_ASYNC_RESULT (result), error)) \
Packit 79f644
      return FALSE; \
Packit 79f644
    g_return_val_if_fail (g_simple_async_result_is_valid (result, \
Packit 79f644
            G_OBJECT(source), tag), \
Packit 79f644
        FALSE); \
Packit 79f644
    return TRUE;
Packit 79f644
Packit 79f644
#define tpaw_implement_finish_copy_pointer(source, tag, copy_func, \
Packit 79f644
    out_param) \
Packit 79f644
    GSimpleAsyncResult *_simple; \
Packit 79f644
    _simple = (GSimpleAsyncResult *) result; \
Packit 79f644
    if (g_simple_async_result_propagate_error (_simple, error)) \
Packit 79f644
      return FALSE; \
Packit 79f644
    g_return_val_if_fail (g_simple_async_result_is_valid (result, \
Packit 79f644
            G_OBJECT (source), tag), \
Packit 79f644
        FALSE); \
Packit 79f644
    if (out_param != NULL) \
Packit 79f644
      *out_param = copy_func ( \
Packit 79f644
          g_simple_async_result_get_op_res_gpointer (_simple)); \
Packit 79f644
    return TRUE;
Packit 79f644
Packit 79f644
#define tpaw_implement_finish_return_copy_pointer(source, tag, copy_func) \
Packit 79f644
    GSimpleAsyncResult *_simple; \
Packit 79f644
    _simple = (GSimpleAsyncResult *) result; \
Packit 79f644
    if (g_simple_async_result_propagate_error (_simple, error)) \
Packit 79f644
      return NULL; \
Packit 79f644
    g_return_val_if_fail (g_simple_async_result_is_valid (result, \
Packit 79f644
            G_OBJECT (source), tag), \
Packit 79f644
        NULL); \
Packit 79f644
    return copy_func (g_simple_async_result_get_op_res_gpointer (_simple));
Packit 79f644
Packit 79f644
#define tpaw_implement_finish_return_pointer(source, tag) \
Packit 79f644
    GSimpleAsyncResult *_simple; \
Packit 79f644
    _simple = (GSimpleAsyncResult *) result; \
Packit 79f644
    if (g_simple_async_result_propagate_error (_simple, error)) \
Packit 79f644
      return NULL; \
Packit 79f644
    g_return_val_if_fail (g_simple_async_result_is_valid (result, \
Packit 79f644
            G_OBJECT (source), tag), \
Packit 79f644
        NULL); \
Packit 79f644
    return g_simple_async_result_get_op_res_gpointer (_simple);
Packit 79f644
Packit 79f644
G_END_DECLS
Packit 79f644
Packit 79f644
#endif /*  __TPAW_UTILS_H__ */