1 #ifndef __G_VFS_DAEMON_PROTOCOL_H__
2 #define __G_VFS_DAEMON_PROTOCOL_H__
3 
4 #include <gio/gio.h>
5 
6 G_BEGIN_DECLS
7 
8 /* The well known name of the main daemon */
9 #define G_VFS_DBUS_DAEMON_NAME "org.gtk.vfs.Daemon"
10 
11 #define G_VFS_DBUS_MOUNTTRACKER_PATH "/org/gtk/vfs/mounttracker"
12 #define G_VFS_DBUS_MOUNTABLE_PATH "/org/gtk/vfs/mountable"
13 #define G_VFS_DBUS_DAEMON_PATH "/org/gtk/vfs/Daemon"
14 #define G_VFS_DBUS_METADATA_NAME "org.gtk.vfs.Metadata"
15 #define G_VFS_DBUS_METADATA_PATH "/org/gtk/vfs/metadata"
16 
17 /* Mounts time out in 30 minutes, since they can be slow, with auth, etc */
18 #define G_VFS_DBUS_MOUNT_TIMEOUT_MSECS (1000*60*30)
19 /* Normal ops are faster, one minute timeout */
20 #define G_VFS_DBUS_TIMEOUT_MSECS (1000*60)
21 
22 /* Flags for the OpenForWriteFlags method */
23 #define OPEN_FOR_WRITE_FLAG_CAN_SEEK     (1<<0)
24 #define OPEN_FOR_WRITE_FLAG_CAN_TRUNCATE (1<<1)
25 
26 typedef struct {
27   guint32 command;
28   guint32 seq_nr;
29   guint32 arg1;
30   guint32 arg2;
31   guint32 data_len;
32 } GVfsDaemonSocketProtocolRequest;
33 
34 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SIZE sizeof(GVfsDaemonSocketProtocolRequest)
35 
36 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_READ 0
37 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_WRITE 1
38 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_CLOSE 2
39 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_CANCEL 3
40 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SEEK_SET 4
41 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_SEEK_END 5
42 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_QUERY_INFO 6
43 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REQUEST_TRUNCATE 7
44 
45 /*
46 read, readahead reply:
47 type, seek_generation, size, data
48 
49 seek reply:
50 type, pos (64),
51 
52 error:
53 type, code, size, data (size bytes, 2 strings: domain, message)
54 
55 info:
56 type,    0, size, data
57 
58 */
59 
60 typedef struct {
61   guint32 type;
62   guint32 seq_nr;
63   guint32 arg1;
64   guint32 arg2;
65 } GVfsDaemonSocketProtocolReply;
66 
67 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SIZE 16
68 
69 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_DATA     0
70 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_ERROR    1
71 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_SEEK_POS 2
72 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_WRITTEN  3
73 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_CLOSED   4
74 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_INFO     5
75 #define G_VFS_DAEMON_SOCKET_PROTOCOL_REPLY_TRUNCATED 6
76 
77 
78 typedef union {
79   gboolean boolean;
80   guint32 uint32;
81   guint64 uint64;
82   gpointer ptr;
83 } GDBusAttributeValue;
84 
85 void       _g_dbus_attribute_value_destroy       (GFileAttributeType          type,
86 						  GDBusAttributeValue        *value);
87 gpointer   _g_dbus_attribute_as_pointer          (GFileAttributeType          type,
88 						  GDBusAttributeValue        *value);
89 GVariant * _g_dbus_append_file_attribute         (const char                 *attribute,
90 						  GFileAttributeStatus        status,
91 						  GFileAttributeType          type,
92 						  gpointer                    value_p);
93 GVariant * _g_dbus_append_file_info              (GFileInfo                  *file_info);
94 gboolean   _g_dbus_get_file_attribute            (GVariant                   *value,
95 						  gchar                     **attribute,
96 						  GFileAttributeStatus       *status,
97 						  GFileAttributeType         *type,
98 						  GDBusAttributeValue        *attr_value);
99 GFileInfo *_g_dbus_get_file_info                 (GVariant                   *value,
100 						  GError                    **error);
101 
102 GFileAttributeInfoList *_g_dbus_get_attribute_info_list    (GVariant                *value,
103 							    GError                 **error);
104 GVariant *              _g_dbus_append_attribute_info_list (GFileAttributeInfoList  *list);
105 
106 G_END_DECLS
107 
108 #endif /* __G_VFS_DAEMON_PROTOCOL_H__ */
109