summaryrefslogtreecommitdiff
path: root/src/spice-session.h
blob: d54ad410a8bb1d0b7fe65e9fda6ea62c95bfdcd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
   Copyright (C) 2010 Red Hat, Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This 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
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __SPICE_CLIENT_SESSION_H__
#define __SPICE_CLIENT_SESSION_H__

#if !defined(__SPICE_CLIENT_H_INSIDE__) && !defined(SPICE_COMPILATION)
#warning "Only <spice-client.h> can be included directly"
#endif

#include <glib-object.h>
#include "spice-types.h"
#include "spice-uri.h"
#include "spice-glib-enums.h"
#include "spice-util.h"

G_BEGIN_DECLS

#define SPICE_TYPE_SESSION            (spice_session_get_type ())
#define SPICE_SESSION(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPICE_TYPE_SESSION, SpiceSession))
#define SPICE_SESSION_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SPICE_TYPE_SESSION, SpiceSessionClass))
#define SPICE_IS_SESSION(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SPICE_TYPE_SESSION))
#define SPICE_IS_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SPICE_TYPE_SESSION))
#define SPICE_SESSION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SPICE_TYPE_SESSION, SpiceSessionClass))

#define SPICE_WEBDAV_CLIPBOARD_FOLDER_PATH "/.spice-clipboard"

/**
 * SpiceSessionVerify:
 * @SPICE_SESSION_VERIFY_PUBKEY: verify certificate public key matching
 * @SPICE_SESSION_VERIFY_HOSTNAME: verify certificate hostname matching
 * @SPICE_SESSION_VERIFY_SUBJECT: verify certificate subject matching
 *
 * Peer certificate verification parameters flags.
 **/
typedef enum {
    SPICE_SESSION_VERIFY_PUBKEY   = (1 << 0),
    SPICE_SESSION_VERIFY_HOSTNAME = (1 << 1),
    SPICE_SESSION_VERIFY_SUBJECT  = (1 << 2),
} SpiceSessionVerify;

/**
 * SpiceSessionMigration:
 * @SPICE_SESSION_MIGRATION_NONE: no migration going on
 * @SPICE_SESSION_MIGRATION_SWITCHING: the session is switching host (destroy and reconnect)
 * @SPICE_SESSION_MIGRATION_MIGRATING: the session is migrating seamlessly (reconnect)
 * @SPICE_SESSION_MIGRATION_CONNECTING: the migration is connecting to destination (Since: 0.27)
 *
 * Session migration state.
 **/
typedef enum {
    SPICE_SESSION_MIGRATION_NONE,
    SPICE_SESSION_MIGRATION_SWITCHING,
    SPICE_SESSION_MIGRATION_MIGRATING,
    SPICE_SESSION_MIGRATION_CONNECTING,
} SpiceSessionMigration;

/**
 * SpiceSession:
 *
 * The #SpiceSession struct is opaque and should not be accessed directly.
 */
struct _SpiceSession
{
    GObject parent;
    SpiceSessionPrivate *priv;
    /* Do not add fields to this struct */
};

/**
 * SpiceSessionClass:
 * @parent_class: Parent class.
 * @channel_new: Signal class handler for the #SpiceSession::channel_new signal.
 * @channel_destroy: Signal class handler for the #SpiceSession::channel_destroy signal.
 *
 * Class structure for #SpiceSession.
 */
struct _SpiceSessionClass
{
    GObjectClass parent_class;

    /* signals */
    void (*channel_new)(SpiceSession *session, SpiceChannel *channel);
    void (*channel_destroy)(SpiceSession *session, SpiceChannel *channel);

    /*< private >*/
    /*
     * If adding fields to this struct, remove corresponding
     * amount of padding to avoid changing overall struct size
     */
    gpointer  _spice_reserved[10];
};

GType spice_session_get_type(void);

SpiceSession *spice_session_new(void);
gboolean spice_session_connect(SpiceSession *session);
gboolean spice_session_open_fd(SpiceSession *session, int fd);
void spice_session_disconnect(SpiceSession *session);
GList *spice_session_get_channels(SpiceSession *session);
gboolean spice_session_has_channel_type(SpiceSession *session, gint type);
gboolean spice_session_get_read_only(SpiceSession *session);
SpiceURI *spice_session_get_proxy_uri(SpiceSession *session);
gboolean spice_session_is_for_migration(SpiceSession *session);

G_END_DECLS

#endif /* __SPICE_CLIENT_SESSION_H__ */