Logo Search packages:      
Sourcecode: nautilus-cd-burner version File versions  Download package

mapping-protocol.h

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
 *
 * mapping-protocol.h - code to talk with the mapping daemon
 *
 * Copyright (C) 2002 Red Hat Inc,
 * Copyright (C) 2005-2006 William Jon McCann <mccann@jhu.edu>
 *
 * The Gnome Library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * The Gnome 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with the Gnome Library; see the file COPYING.LIB.  If not,
 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Authors: Alexander Larsson <alexl@redhat.com>
 *          William Jon McCann <mccann@jhu.edu>
*/
#include <glib.h>

typedef struct {
      guint32  serial;
      gint32   operation;
      char    *root;
      char    *path1;
      char    *path2;
      gboolean option;
      void    *userdata;
} MappingProtocolRequest;

typedef struct {
      guint32  serial;
      gint32   result;
      char    *path;
      gboolean option;
      /* FIXME: int too small for this? */
      int      n_strings;
      char   **strings;
} MappingProtocolReply;

typedef struct {
      guint32 serial;
      gint32  type;
      char   *path;
      void   *userdata;
} MappingProtocolMonitorEvent;

typedef enum {
      MAPPING_PROTOCOL_MESSAGE_REQUEST = 1 << 0,
      MAPPING_PROTOCOL_MESSAGE_REPLY   = 1 << 1,
      MAPPING_PROTOCOL_MESSAGE_MONITOR_EVENT   = 1 << 2,
} MappingProtocolMessageType;

#define MAPPING_PROTOCOL_REQUEST(m) ((MappingProtocolRequest *)(m))
#define MAPPING_PROTOCOL_REPLY(m) ((MappingProtocolReply *)(m))
#define MAPPING_PROTOCOL_MONITOR_EVENT(m) ((MappingProtocolMonitorEvent *)(m))

typedef struct {
      union {
            MappingProtocolRequest      request;
            MappingProtocolReply        reply;
            MappingProtocolMonitorEvent event;
      } message;
      MappingProtocolMessageType type;
      gint ref_count;
} MappingProtocolMessage;

typedef struct MappingProtocolChannel MappingProtocolChannel;

typedef void (* MappingProtocolHandleMessageFunction) (MappingProtocolChannel *channel,
                                           MappingProtocolMessage *message,
                                           gpointer                user_data);

typedef enum {
      MAPPING_PROTOCOL_OP_GET_BACKING_FILE,
      MAPPING_PROTOCOL_OP_CREATE_DIR,
      MAPPING_PROTOCOL_OP_REMOVE_DIR,
      MAPPING_PROTOCOL_OP_REMOVE_FILE,
      MAPPING_PROTOCOL_OP_CREATE_FILE,
      MAPPING_PROTOCOL_OP_CREATE_LINK,
      MAPPING_PROTOCOL_OP_MOVE_FILE,
      MAPPING_PROTOCOL_OP_LIST_DIR,
      MAPPING_PROTOCOL_OP_MONITOR_ADD,
      MAPPING_PROTOCOL_OP_MONITOR_CANCEL,
} MappingProtocolOps;

char                   *mapping_protocol_get_unix_name               (void);

MappingProtocolChannel *mapping_protocol_channel_new                 (int                          fd);

void                    mapping_protocol_channel_ref                 (MappingProtocolChannel      *channel);
void                    mapping_protocol_channel_unref               (MappingProtocolChannel      *channel);

void                    mapping_protocol_channel_set_message_handler (MappingProtocolChannel      *channel,
                                                      MappingProtocolHandleMessageFunction function,
                                                      gpointer                     user_data);

gboolean                mapping_protocol_channel_send                (MappingProtocolChannel      *channel,
                                                      MappingProtocolMessage      *message);
gboolean                mapping_protocol_channel_send_with_reply     (MappingProtocolChannel      *channel,
                                                      MappingProtocolMessage      *message,
                                                      MappingProtocolMessage     **reply);


MappingProtocolMessage *mapping_protocol_message_new_reply           (MappingProtocolMessage      *message);
MappingProtocolMessage *mapping_protocol_message_new_monitor_event   (void);
MappingProtocolMessage *mapping_protocol_message_new_request         (void);

MappingProtocolMessage *mapping_protocol_message_ref                 (MappingProtocolMessage      *message);
void                    mapping_protocol_message_unref               (MappingProtocolMessage      *message);

guint32                 mapping_protocol_message_get_serial          (MappingProtocolMessage      *message);
void                    mapping_protocol_message_set_serial          (MappingProtocolMessage      *message,
                                                      guint32                      serial);

Generated by  Doxygen 1.6.0   Back to index