summaryrefslogtreecommitdiff
path: root/mate-session/gsm-client.h
blob: b623742ca48cabd26c651cb287240d0df00944fc (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2007 Novell, Inc.
 * Copyright (C) 2008 Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program 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 General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

#ifndef __GSM_CLIENT_H__
#define __GSM_CLIENT_H__

#include <glib.h>
#include <glib-object.h>
#include <sys/types.h>

G_BEGIN_DECLS

#define GSM_TYPE_CLIENT            (gsm_client_get_type ())
G_DECLARE_DERIVABLE_TYPE (GsmClient, gsm_client, GSM, CLIENT, GObject)

typedef enum {
        GSM_CLIENT_UNREGISTERED = 0,
        GSM_CLIENT_REGISTERED,
        GSM_CLIENT_FINISHED,
        GSM_CLIENT_FAILED
} GsmClientStatus;

typedef enum {
        GSM_CLIENT_RESTART_NEVER = 0,
        GSM_CLIENT_RESTART_IF_RUNNING,
        GSM_CLIENT_RESTART_ANYWAY,
        GSM_CLIENT_RESTART_IMMEDIATELY
} GsmClientRestartStyle;

typedef enum {
        GSM_CLIENT_END_SESSION_FLAG_FORCEFUL = 1 << 0,
        GSM_CLIENT_END_SESSION_FLAG_SAVE     = 1 << 1,
        GSM_CLIENT_END_SESSION_FLAG_LAST     = 1 << 2
} GsmClientEndSessionFlag;

struct _GsmClientClass
{
        GObjectClass parent_class;

        /* signals */
        void         (*disconnected)               (GsmClient  *client);
        void         (*end_session_response)       (GsmClient  *client,
                                                    gboolean    ok,
                                                    gboolean    do_last,
                                                    gboolean    cancel,
                                                    const char *reason);

        /* virtual methods */
        char *                (*impl_get_app_name)           (GsmClient *client);
        GsmClientRestartStyle (*impl_get_restart_style_hint) (GsmClient *client);
        guint                 (*impl_get_unix_process_id)    (GsmClient *client);
        gboolean              (*impl_query_end_session)      (GsmClient *client,
                                                              guint      flags,
                                                              GError   **error);
        gboolean              (*impl_end_session)            (GsmClient *client,
                                                              guint      flags,
                                                              GError   **error);
        gboolean              (*impl_cancel_end_session)     (GsmClient *client,
                                                              GError   **error);
        gboolean              (*impl_stop)                   (GsmClient *client,
                                                              GError   **error);
        GKeyFile *            (*impl_save)                   (GsmClient *client,
                                                              GError   **error);
};

typedef enum
{
        GSM_CLIENT_ERROR_GENERAL = 0,
        GSM_CLIENT_ERROR_NOT_REGISTERED,
        GSM_CLIENT_NUM_ERRORS
} GsmClientError;

#define GSM_CLIENT_ERROR gsm_client_error_quark ()
#define GSM_CLIENT_TYPE_ERROR (gsm_client_error_get_type ())

GType                 gsm_client_error_get_type             (void);
GQuark                gsm_client_error_quark                (void);
GType                 gsm_client_get_type                   (void) G_GNUC_CONST;

const char           *gsm_client_peek_id                    (GsmClient  *client);


const char *          gsm_client_peek_startup_id            (GsmClient  *client);
const char *          gsm_client_peek_app_id                (GsmClient  *client);
guint                 gsm_client_peek_restart_style_hint    (GsmClient  *client);
guint                 gsm_client_peek_status                (GsmClient  *client);


char                 *gsm_client_get_app_name               (GsmClient  *client);
void                  gsm_client_set_app_id                 (GsmClient  *client,
                                                             const char *app_id);
void                  gsm_client_set_status                 (GsmClient  *client,
                                                             guint       status);

gboolean              gsm_client_end_session                (GsmClient  *client,
                                                             guint       flags,
                                                             GError    **error);
gboolean              gsm_client_query_end_session          (GsmClient  *client,
                                                             guint       flags,
                                                             GError    **error);
gboolean              gsm_client_cancel_end_session         (GsmClient  *client,
                                                             GError    **error);

void                  gsm_client_disconnected               (GsmClient  *client);

GKeyFile             *gsm_client_save                       (GsmClient  *client,
                                                             GError    **error);
/* exported to bus */
gboolean              gsm_client_stop                       (GsmClient  *client,
                                                             GError    **error);
gboolean              gsm_client_get_startup_id             (GsmClient  *client,
                                                             char      **startup_id,
                                                             GError    **error);
gboolean              gsm_client_get_app_id                 (GsmClient  *client,
                                                             char      **app_id,
                                                             GError    **error);
gboolean              gsm_client_get_restart_style_hint     (GsmClient  *client,
                                                             guint      *hint,
                                                             GError    **error);
gboolean              gsm_client_get_status                 (GsmClient  *client,
                                                             guint      *status,
                                                             GError    **error);
gboolean              gsm_client_get_unix_process_id        (GsmClient  *client,
                                                             guint      *pid,
                                                             GError    **error);

/* private */

void                  gsm_client_end_session_response       (GsmClient  *client,
                                                             gboolean    is_ok,
                                                             gboolean    do_last,
                                                             gboolean    cancel,
                                                             const char *reason);

G_END_DECLS

#endif /* __GSM_CLIENT_H__ */