Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
nsAppRootAccessible.cpp File Reference
#include "nsCOMPtr.h"
#include "nsMai.h"
#include "nsAppRootAccessible.h"
#include "prlink.h"
#include "nsIServiceManager.h"
#include <gtk/gtk.h>
#include <atk/atk.h>

Go to the source code of this file.

Classes

struct  _MaiUtil
struct  MaiKeyListenerInfo
struct  GnomeAccessibilityModule
struct  _MaiUtilClass
struct  _MaiUtilListenerInfo

Defines

#define MAI_TYPE_UTIL   (mai_util_get_type ())
#define MAI_UTIL(obj)
#define MAI_UTIL_CLASS(klass)
#define MAI_IS_UTIL(obj)
#define MAI_IS_UTIL_CLASS(klass)
#define MAI_UTIL_GET_CLASS(obj)
#define MAI_VERSION   MOZILLA_VERSION
#define MAI_NAME   "Gecko"

Typedefs

typedef struct _MaiUtilListenerInfo
typedef struct _MaiUtil
typedef struct _MaiUtilClass
typedef void(* GnomeAccessibilityShutdown )(void)

Functions

static guint mai_util_add_global_event_listener (GSignalEmissionHook listener, const gchar *event_type)
static void mai_util_remove_global_event_listener (guint remove_listener)
static guint mai_util_add_key_event_listener (AtkKeySnoopFunc listener, gpointer data)
static void mai_util_remove_key_event_listener (guint remove_listener)
static AtkObject * mai_util_get_root (void)
static G_CONST_RETURN gchar * mai_util_get_toolkit_name (void)
static G_CONST_RETURN gchar * mai_util_get_toolkit_version (void)
static void _listener_info_destroy (gpointer data)
static guint add_listener (GSignalEmissionHook listener, const gchar *object_type, const gchar *signal, const gchar *hook_data)
static AtkKeyEventStruct * atk_key_event_from_gdk_event_key (GdkEventKey *key)
static gboolean notify_hf (gpointer key, gpointer value, gpointer data)
static void insert_hf (gpointer key, gpointer value, gpointer data)
static gboolean remove_hf (gpointer key, gpointer value, gpointer data)
static gint mai_key_snooper (GtkWidget *the_widget, GdkEventKey *event, gpointer func_data)
static void value_destroy_func (gpointer data)
GType mai_util_get_type (void)
static void mai_util_class_init (MaiUtilClass *klass)
static nsresult LoadGtkModule (GnomeAccessibilityModule &aModule)

Variables

G_BEGIN_DECLS typedef void(* GnomeAccessibilityInit )(void)
static nsAppRootAccessiblesAppRoot = nsnull
static GHashTable * listener_list = NULL
static gint listener_idx = 1
static GHashTable * key_listener_list = NULL
static guint key_snooper_id = 0
PRLogModuleInfogMaiLog = NULL
static GnomeAccessibilityModule sAtkBridge
nsRootAccessibleWrapsOnlyChild = nsnull

Class Documentation

struct _MaiUtil

Definition at line 111 of file nsAppRootAccessible.cpp.

Class Members
GList * listener_list
AtkUtil parent
struct MaiKeyListenerInfo

Definition at line 117 of file nsAppRootAccessible.cpp.

Class Members
gpointer data
AtkKeySnoopFunc listener
struct GnomeAccessibilityModule

Definition at line 123 of file nsAppRootAccessible.cpp.

Collaboration diagram for GnomeAccessibilityModule:
Class Members
GnomeAccessibilityInit init
const char * initName
PRLibrary * lib
const char * libName
GnomeAccessibilityShutdown shutdown
const char * shutdownName
struct _MaiUtilClass

Definition at line 136 of file nsAppRootAccessible.cpp.

Class Members
AtkUtilClass parent_class
struct _MaiUtilListenerInfo

Definition at line 147 of file nsAppRootAccessible.cpp.

Class Members
gulong hook_id
gint key
guint signal_id

Define Documentation

Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
                                    MAI_TYPE_UTIL))

Definition at line 93 of file nsAppRootAccessible.cpp.

#define MAI_IS_UTIL_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
                                    MAI_TYPE_UTIL))

Definition at line 95 of file nsAppRootAccessible.cpp.

#define MAI_NAME   "Gecko"

Definition at line 145 of file nsAppRootAccessible.cpp.

Definition at line 88 of file nsAppRootAccessible.cpp.

Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
                                    MAI_TYPE_UTIL, MaiUtil))

Definition at line 89 of file nsAppRootAccessible.cpp.

#define MAI_UTIL_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass), \
                                    MAI_TYPE_UTIL, MaiUtilClass))

Definition at line 91 of file nsAppRootAccessible.cpp.

Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
                                    MAI_TYPE_UTIL, MaiUtilClass))

Definition at line 97 of file nsAppRootAccessible.cpp.

#define MAI_VERSION   MOZILLA_VERSION

Definition at line 144 of file nsAppRootAccessible.cpp.


Typedef Documentation

typedef struct _MaiUtil

Definition at line 100 of file nsAppRootAccessible.cpp.

typedef struct _MaiUtilClass

Definition at line 101 of file nsAppRootAccessible.cpp.

typedef struct _MaiUtilListenerInfo

Definition at line 85 of file nsAppRootAccessible.cpp.

Definition at line 108 of file nsAppRootAccessible.cpp.


Function Documentation

void _listener_info_destroy ( gpointer  data) [static]

Definition at line 432 of file nsAppRootAccessible.cpp.

{
    g_free(data);
}

Here is the caller graph for this function:

guint add_listener ( GSignalEmissionHook  listener,
const gchar *  object_type,
const gchar *  signal,
const gchar *  hook_data 
) [static]

Definition at line 438 of file nsAppRootAccessible.cpp.

{
    GType type;
    guint signal_id;
    gint rc = 0;

    type = g_type_from_name(object_type);
    if (type) {
        signal_id = g_signal_lookup(signal, type);
        if (signal_id > 0) {
            MaiUtilListenerInfo *listener_info;

            rc = listener_idx;

            listener_info =  (MaiUtilListenerInfo *)
                g_malloc(sizeof(MaiUtilListenerInfo));
            listener_info->key = listener_idx;
            listener_info->hook_id =
                g_signal_add_emission_hook(signal_id, 0, listener,
                                           g_strdup(hook_data),
                                           (GDestroyNotify)g_free);
            listener_info->signal_id = signal_id;

            g_hash_table_insert(listener_list, &(listener_info->key),
                                listener_info);
            listener_idx++;
        }
        else {
            g_warning("Invalid signal type %s\n", signal);
        }
    }
    else {
        g_warning("Invalid object type %s\n", object_type);
    }
    return rc;
}

Here is the caller graph for this function:

static AtkKeyEventStruct * atk_key_event_from_gdk_event_key ( GdkEventKey *  key) [static]

Definition at line 290 of file nsAppRootAccessible.cpp.

{
    AtkKeyEventStruct *event = g_new0(AtkKeyEventStruct, 1);
    switch (key->type) {
    case GDK_KEY_PRESS:
        event->type = ATK_KEY_EVENT_PRESS;
        break;
    case GDK_KEY_RELEASE:
        event->type = ATK_KEY_EVENT_RELEASE;
        break;
    default:
        g_assert_not_reached ();
        return NULL;
    }
    event->state = key->state;
    event->keyval = key->keyval;
    event->length = key->length;
    if (key->string && key->string [0] && 
        (key->state & GDK_CONTROL_MASK ||
         g_unichar_isgraph (g_utf8_get_char (key->string)))) {
        event->string = key->string;
    }
    else if (key->type == GDK_KEY_PRESS ||
             key->type == GDK_KEY_RELEASE) {
        event->string = gdk_keyval_name (key->keyval);      
    }
    event->keycode = key->hardware_keycode;
    event->timestamp = key->time;

    MAI_LOG_DEBUG(("MaiKey:\tsym %u\n\tmods %x\n\tcode %u\n\ttime %lx\n",
                   (unsigned int) event->keyval,
                   (unsigned int) event->state,
                   (unsigned int) event->keycode,
                   (unsigned long int) event->timestamp));
    return event;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void insert_hf ( gpointer  key,
gpointer  value,
gpointer  data 
) [static]

Definition at line 343 of file nsAppRootAccessible.cpp.

{
    GHashTable *new_table = (GHashTable *) data;
    g_hash_table_insert (new_table, key, value);
}

Here is the caller graph for this function:

static nsresult LoadGtkModule ( GnomeAccessibilityModule aModule) [static]

Definition at line 791 of file nsAppRootAccessible.cpp.

{
    NS_ENSURE_ARG(aModule.libName);

    if (!(aModule.lib = PR_LoadLibrary(aModule.libName))) {

        MAI_LOG_DEBUG(("Fail to load lib: %s in default path\n", aModule.libName));

        //try to load the module with "gtk-2.0/modules" appended
        char *curLibPath = PR_GetLibraryPath();
        nsCAutoString libPath(curLibPath);
        libPath.Append(":/usr/lib");
        MAI_LOG_DEBUG(("Current Lib path=%s\n", libPath.get()));
        PR_FreeLibraryName(curLibPath);

        PRInt16 loc1 = 0, loc2 = 0;
        PRInt16 subLen = 0;
        while (loc2 >= 0) {
            loc2 = libPath.FindChar(':', loc1);
            if (loc2 < 0)
                subLen = libPath.Length() - loc1;
            else
                subLen = loc2 - loc1;
            nsCAutoString sub(Substring(libPath, loc1, subLen));
            sub.Append("/gtk-2.0/modules/");
            sub.Append(aModule.libName);
            aModule.lib = PR_LoadLibrary(sub.get());
            if (aModule.lib) {
                MAI_LOG_DEBUG(("Ok, load %s from %s\n", aModule.libName, sub.get()));
                break;
            }
            loc1 = loc2+1;
        }
        if (!aModule.lib) {
            MAI_LOG_DEBUG(("Fail to load %s\n", aModule.libName));
            return NS_ERROR_FAILURE;
        }
    }

    //we have loaded the library, try to get the function ptrs
    if (!(aModule.init = PR_FindFunctionSymbol(aModule.lib,
                                               aModule.initName)) ||
        !(aModule.shutdown = PR_FindFunctionSymbol(aModule.lib,
                                                   aModule.shutdownName))) {

        //fail, :(
        MAI_LOG_DEBUG(("Fail to find symbol %s in %s",
                       aModule.init ? aModule.shutdownName : aModule.initName,
                       aModule.libName));
        PR_UnloadLibrary(aModule.lib);
        aModule.lib = NULL;
        return NS_ERROR_FAILURE;
    }
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gint mai_key_snooper ( GtkWidget *  the_widget,
GdkEventKey *  event,
gpointer  func_data 
) [static]

Definition at line 360 of file nsAppRootAccessible.cpp.

{
    /* notify each AtkKeySnoopFunc in turn... */

    gint consumed = 0;
    if (key_listener_list) {
        AtkKeyEventStruct *keyEvent = atk_key_event_from_gdk_event_key(event);
        GHashTable *new_hash = g_hash_table_new(NULL, NULL);
        g_hash_table_foreach (key_listener_list, insert_hf, new_hash);
        consumed = g_hash_table_foreach_steal (new_hash, notify_hf, keyEvent);
        g_hash_table_destroy (new_hash);
        g_free (keyEvent);
    }
    return (consumed ? 1 : 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static guint mai_util_add_global_event_listener ( GSignalEmissionHook  listener,
const gchar *  event_type 
) [static]

Definition at line 217 of file nsAppRootAccessible.cpp.

{
    guint rc = 0;
    gchar **split_string;

    split_string = g_strsplit (event_type, ":", 3);

    if (split_string) {
        if (!strcmp ("window", split_string[0])) {
            /*  ???
                static gboolean initialized = FALSE;

                if (!initialized) {
                do_window_event_initialization ();
                initialized = TRUE;
                }
                rc = add_listener (listener, "MaiWindow",
                split_string[1], event_type);
            */
            rc = add_listener (listener, "MaiAtkObject", split_string[1], event_type);
        }
        else {
            rc = add_listener (listener, split_string[1], split_string[2],
                               event_type);
        }
    }
    return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static guint mai_util_add_key_event_listener ( AtkKeySnoopFunc  listener,
gpointer  data 
) [static]

Definition at line 377 of file nsAppRootAccessible.cpp.

{
    NS_ENSURE_TRUE(listener, 0);

    static guint key=0;
    MaiKeyListenerInfo *info = g_new0(MaiKeyListenerInfo, 1);
    NS_ENSURE_TRUE(info, 0);

    info->listener = listener;
    info->data = data;

    if (!key_listener_list) {
        key_listener_list = g_hash_table_new_full(NULL, NULL, NULL,
                                                  value_destroy_func);
        key_snooper_id = gtk_key_snooper_install(mai_key_snooper, NULL);
    }
    g_hash_table_insert(key_listener_list, GUINT_TO_POINTER (key++),
                        (gpointer)info);
    return key;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void mai_util_class_init ( MaiUtilClass *  klass) [static]

Definition at line 194 of file nsAppRootAccessible.cpp.

{
    AtkUtilClass *atk_class;
    gpointer data;

    data = g_type_class_peek(ATK_TYPE_UTIL);
    atk_class = ATK_UTIL_CLASS(data);

    atk_class->add_global_event_listener =
        mai_util_add_global_event_listener;
    atk_class->remove_global_event_listener =
        mai_util_remove_global_event_listener;
    atk_class->add_key_event_listener = mai_util_add_key_event_listener;
    atk_class->remove_key_event_listener = mai_util_remove_key_event_listener;
    atk_class->get_root = mai_util_get_root;
    atk_class->get_toolkit_name = mai_util_get_toolkit_name;
    atk_class->get_toolkit_version = mai_util_get_toolkit_version;

    listener_list = g_hash_table_new_full(g_int_hash, g_int_equal, NULL,
                                          _listener_info_destroy);
}

Here is the call graph for this function:

Here is the caller graph for this function:

AtkObject * mai_util_get_root ( void  ) [static]

Definition at line 410 of file nsAppRootAccessible.cpp.

{
    nsAppRootAccessible *root = nsAppRootAccessible::Create();

    if (!root)
        return nsnull;
    return root->GetAtkObject();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 420 of file nsAppRootAccessible.cpp.

{
    return MAI_NAME;
}

Here is the caller graph for this function:

Definition at line 426 of file nsAppRootAccessible.cpp.

{
    return MAI_VERSION;
}

Here is the caller graph for this function:

GType mai_util_get_type ( void  )

Definition at line 166 of file nsAppRootAccessible.cpp.

{
    static GType type = 0;

    if (!type) {
        static const GTypeInfo tinfo = {
            sizeof(MaiUtilClass),
            (GBaseInitFunc) NULL, /* base init */
            (GBaseFinalizeFunc) NULL, /* base finalize */
            (GClassInitFunc) mai_util_class_init, /* class init */
            (GClassFinalizeFunc) NULL, /* class finalize */
            NULL, /* class data */
            sizeof(MaiUtil), /* instance size */
            0, /* nb preallocs */
            (GInstanceInitFunc) NULL, /* instance init */
            NULL /* value table */
        };

        type = g_type_register_static(ATK_TYPE_UTIL,
                                      "MaiUtil", &tinfo, GTypeFlags(0));
    }
    return type;
}

Here is the call graph for this function:

static void mai_util_remove_global_event_listener ( guint  remove_listener) [static]

Definition at line 248 of file nsAppRootAccessible.cpp.

{
    if (remove_listener > 0) {
        MaiUtilListenerInfo *listener_info;
        gint tmp_idx = remove_listener;

        listener_info = (MaiUtilListenerInfo *)
            g_hash_table_lookup(listener_list, &tmp_idx);

        if (listener_info != NULL) {
            /* Hook id of 0 and signal id of 0 are invalid */
            if (listener_info->hook_id != 0 && listener_info->signal_id != 0) {
                /* Remove the emission hook */
                g_signal_remove_emission_hook(listener_info->signal_id,
                                              listener_info->hook_id);

                /* Remove the element from the hash */
                g_hash_table_remove(listener_list, &tmp_idx);
            }
            else {
                /* do not use g_warning with such complex format args, */
                /* Forte CC can not preprocess it correctly */
                g_log((gchar *)0, G_LOG_LEVEL_WARNING,
                      "Invalid listener hook_id %ld or signal_id %d\n",
                      listener_info->hook_id, listener_info->signal_id);

            }
        }
        else {
            /* do not use g_warning with such complex format args, */
            /* Forte CC can not preprocess it correctly */
            g_log((gchar *)0, G_LOG_LEVEL_WARNING,
                  "No listener with the specified listener id %d",
                  remove_listener);
        }
    }
    else {
        g_warning("Invalid listener_id %d", remove_listener);
    }
}

Here is the caller graph for this function:

static void mai_util_remove_key_event_listener ( guint  remove_listener) [static]

Definition at line 400 of file nsAppRootAccessible.cpp.

{
    g_hash_table_foreach_remove(key_listener_list, remove_hf,
                                (gpointer)remove_listener);
    if (g_hash_table_size(key_listener_list) == 0) {
        gtk_key_snooper_remove(key_snooper_id);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean notify_hf ( gpointer  key,
gpointer  value,
gpointer  data 
) [static]

Definition at line 328 of file nsAppRootAccessible.cpp.

{
    AtkKeyEventStruct *event = (AtkKeyEventStruct *) data;
    MaiKeyListenerInfo *info = (MaiKeyListenerInfo *)value;

    return (*(info->listener))(event, info->data) ? TRUE : FALSE;
}

Here is the caller graph for this function:

static gboolean remove_hf ( gpointer  key,
gpointer  value,
gpointer  data 
) [static]

Definition at line 350 of file nsAppRootAccessible.cpp.

{
    AtkKeySnoopFunc listener = (AtkKeySnoopFunc)data;
    MaiKeyListenerInfo *info = (MaiKeyListenerInfo *)value;
    if (info->listener == listener)
        return TRUE;
    return FALSE;
}

Here is the caller graph for this function:

static void value_destroy_func ( gpointer  data) [static]

Definition at line 337 of file nsAppRootAccessible.cpp.

{
    g_free(data);
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 142 of file nsAppRootAccessible.cpp.

G_BEGIN_DECLS typedef void(* GnomeAccessibilityInit)(void)

Definition at line 107 of file nsAppRootAccessible.cpp.

GHashTable* key_listener_list = NULL [static]

Definition at line 103 of file nsAppRootAccessible.cpp.

guint key_snooper_id = 0 [static]

Definition at line 104 of file nsAppRootAccessible.cpp.

gint listener_idx = 1 [static]

Definition at line 83 of file nsAppRootAccessible.cpp.

GHashTable* listener_list = NULL [static]

Definition at line 82 of file nsAppRootAccessible.cpp.

Definition at line 52 of file nsAppRootAccessible.cpp.

Initial value:
 {



    "libatk-bridge.so", NULL,

    "gnome_accessibility_module_init", NULL,

    "gnome_accessibility_module_shutdown", NULL,
}

Definition at line 154 of file nsAppRootAccessible.cpp.

Definition at line 482 of file nsAppRootAccessible.cpp.