gsm-client.h 6.6 KB
Newer Older
1 2
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
3
 * Copyright (C) 2007 Novell, Inc.
4
 * Copyright (C) 2008 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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
17
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 19 20 21 22
 */

#ifndef __GSM_CLIENT_H__
#define __GSM_CLIENT_H__

23
#include <glib.h>
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include <glib-object.h>
#include <sys/types.h>

G_BEGIN_DECLS

#define GSM_TYPE_CLIENT            (gsm_client_get_type ())
#define GSM_CLIENT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSM_TYPE_CLIENT, GsmClient))
#define GSM_CLIENT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GSM_TYPE_CLIENT, GsmClientClass))
#define GSM_IS_CLIENT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSM_TYPE_CLIENT))
#define GSM_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSM_TYPE_CLIENT))
#define GSM_CLIENT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GSM_TYPE_CLIENT, GsmClientClass))

typedef struct _GsmClient        GsmClient;
typedef struct _GsmClientClass   GsmClientClass;

39 40
typedef struct GsmClientPrivate GsmClientPrivate;

41
typedef enum {
42 43
        GSM_CLIENT_UNREGISTERED = 0,
        GSM_CLIENT_REGISTERED,
44
        GSM_CLIENT_FINISHED,
45
        GSM_CLIENT_FAILED
46 47
} GsmClientStatus;

48 49 50 51
typedef enum {
        GSM_CLIENT_RESTART_NEVER = 0,
        GSM_CLIENT_RESTART_IF_RUNNING,
        GSM_CLIENT_RESTART_ANYWAY,
52
        GSM_CLIENT_RESTART_IMMEDIATELY
53 54
} GsmClientRestartStyle;

55
typedef enum {
56
        GSM_CLIENT_END_SESSION_FLAG_FORCEFUL = 1 << 0,
57 58
        GSM_CLIENT_END_SESSION_FLAG_SAVE     = 1 << 1,
        GSM_CLIENT_END_SESSION_FLAG_LAST     = 1 << 2
59 60
} GsmClientEndSessionFlag;

61 62
struct _GsmClient
{
63 64
        GObject           parent;
        GsmClientPrivate *priv;
65 66 67 68
};

struct _GsmClientClass
{
69 70 71
        GObjectClass parent_class;

        /* signals */
72 73 74
        void         (*disconnected)               (GsmClient  *client);
        void         (*end_session_response)       (GsmClient  *client,
                                                    gboolean    ok,
75
                                                    gboolean    do_last,
76
                                                    gboolean    cancel,
77
                                                    const char *reason);
78 79

        /* virtual methods */
80 81
        char *                (*impl_get_app_name)           (GsmClient *client);
        GsmClientRestartStyle (*impl_get_restart_style_hint) (GsmClient *client);
82
        guint                 (*impl_get_unix_process_id)    (GsmClient *client);
83
        gboolean              (*impl_query_end_session)      (GsmClient *client,
84
                                                              GsmClientEndSessionFlag flags,
85 86
                                                              GError   **error);
        gboolean              (*impl_end_session)            (GsmClient *client,
87
                                                              GsmClientEndSessionFlag flags,
88 89 90
                                                              GError   **error);
        gboolean              (*impl_cancel_end_session)     (GsmClient *client,
                                                              GError   **error);
91 92
        gboolean              (*impl_stop)                   (GsmClient *client,
                                                              GError   **error);
93 94
        GKeyFile *            (*impl_save)                   (GsmClient *client,
                                                              GError   **error);
95 96
};

97 98 99 100 101 102 103 104 105 106
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 ()
GQuark                gsm_client_error_quark                (void);

107
GType                 gsm_client_get_type                   (void) G_GNUC_CONST;
108

109 110 111 112 113 114 115 116
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);

117

118
char                 *gsm_client_get_app_name               (GsmClient  *client);
119 120 121
void                  gsm_client_set_app_id                 (GsmClient  *client,
                                                             const char *app_id);
void                  gsm_client_set_status                 (GsmClient  *client,
122
                                                             guint       status);
123

124 125 126 127 128 129 130 131
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);
132

133 134
void                  gsm_client_disconnected               (GsmClient  *client);

135 136
GKeyFile             *gsm_client_save                       (GsmClient  *client,
                                                             GError    **error);
137

138 139
gboolean              gsm_client_stop                       (GsmClient  *client,
                                                             GError    **error);
140 141 142

/* private */

143
void                  gsm_client_end_session_response       (GsmClient  *client,
144
                                                             gboolean    is_ok,
145
                                                             gboolean    do_last,
146
                                                             gboolean    cancel,
147
                                                             const char *reason);
148

149 150 151
G_END_DECLS

#endif /* __GSM_CLIENT_H__ */