No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | shell-mount-operation.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /*
3 * Copyright (C) 2011 Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 * 02111-1307, USA.
19 *
20 * Author: Cosimo Cecchi <cosimoc@redhat.com>
21 *
22 */
23
24 #include "shell-mount-operation.h"
25
26 /* This is a dummy class; we would like to be able to subclass the
27 * object from JS but we can't yet; the default GMountOperation impl
28 * automatically calls g_mount_operation_reply(UNHANDLED) after an idle,
29 * in interactive methods. We want to handle the reply outselves
30 * instead, so we just override the default methods with empty ones,
31 * except for ask-password, as we don't want to handle that.
32 *
33 * Also, we need to workaround the fact that gjs doesn't support type
34 * annotations for signals yet (so we can't effectively forward e.g.
35 * the GPid array to JS).
36 * See https://bugzilla.gnome.org/show_bug.cgi?id=645978
37 */
38 G_DEFINE_TYPE (ShellMountOperation, shell_mount_operation, G_TYPE_MOUNT_OPERATION);
39
40 enum {
41 SHOW_PROCESSES_2,
42 NUM_SIGNALS
43 };
44
45 static guint signals[NUM_SIGNALS] = { 0, };
46
47 struct _ShellMountOperationPrivate {
48 GArray *pids;
49 gchar **choices;
50 gchar *message;
51 };
52
53 static void
54 shell_mount_operation_init (ShellMountOperation *self)
55 {
56 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, SHELL_TYPE_MOUNT_OPERATION,
57 ShellMountOperationPrivate);
58 }
59
60 static void
61 shell_mount_operation_ask_password (GMountOperation *op,
62 const char *message,
63 const char *default_user,
64 const char *default_domain,
65 GAskPasswordFlags flags)
66 {
67 /* do nothing */
68 }
69
70 static void
71 shell_mount_operation_ask_question (GMountOperation *op,
72 const char *message,
73 const char *choices[])
74 {
75 /* do nothing */
76 }
77
78 static void
79 shell_mount_operation_show_processes (GMountOperation *operation,
80 const gchar *message,
81 GArray *processes,
82 const gchar *choices[])
83 {
84 ShellMountOperation *self = SHELL_MOUNT_OPERATION (operation);
85
86 if (self->priv->pids != NULL)
87 {
88 g_array_unref (self->priv->pids);
89 self->priv->pids = NULL;
90 }
91
92 g_free (self->priv->message);
93 g_strfreev (self->priv->choices);
94
95 /* save the parameters */
96 self->priv->pids = g_array_ref (processes);
97 self->priv->choices = g_strdupv ((gchar **) choices);
98 self->priv->message = g_strdup (message);
99
100 g_signal_emit (self, signals[SHOW_PROCESSES_2], 0);
101 }
102
103 static void
104 shell_mount_operation_finalize (GObject *obj)
105 {
106 ShellMountOperation *self = SHELL_MOUNT_OPERATION (obj);
107
108 g_strfreev (self->priv->choices);
109 g_free (self->priv->message);
110
111 if (self->priv->pids != NULL)
112 {
113 g_array_unref (self->priv->pids);
114 self->priv->pids = NULL;
115 }
116
117 G_OBJECT_CLASS (shell_mount_operation_parent_class)->finalize (obj);
118 }
119
120 static void
121 shell_mount_operation_class_init (ShellMountOperationClass *klass)
122 {
123 GMountOperationClass *mclass;
124 GObjectClass *oclass;
125
126 mclass = G_MOUNT_OPERATION_CLASS (klass);
127 mclass->show_processes = shell_mount_operation_show_processes;
128 mclass->ask_question = shell_mount_operation_ask_question;
129 mclass->ask_password = shell_mount_operation_ask_password;
130
131 oclass = G_OBJECT_CLASS (klass);
132 oclass->finalize = shell_mount_operation_finalize;
133
134 signals[SHOW_PROCESSES_2] =
135 g_signal_new ("show-processes-2",
136 G_TYPE_FROM_CLASS (klass),
137 G_SIGNAL_RUN_LAST,
138 0, NULL, NULL, NULL,
139 G_TYPE_NONE, 0);
140
141 g_type_class_add_private (klass, sizeof (ShellMountOperationPrivate));
142 }
143
144 GMountOperation *
145 shell_mount_operation_new (void)
146 {
147 return g_object_new (SHELL_TYPE_MOUNT_OPERATION, NULL);
148 }
149
150 /**
151 * shell_mount_operation_get_show_processes_pids:
152 * @self: a #ShellMountOperation
153 *
154 * Returns: (transfer full) (element-type GPid): a #GArray
155 */
156 GArray *
157 shell_mount_operation_get_show_processes_pids (ShellMountOperation *self)
158 {
159 return g_array_ref (self->priv->pids);
160 }
161
162 /**
163 * shell_mount_operation_get_show_processes_choices:
164 * @self: a #ShellMountOperation
165 *
166 * Returns: (transfer full):
167 */
168 gchar **
169 shell_mount_operation_get_show_processes_choices (ShellMountOperation *self)
170 {
171 return g_strdupv (self->priv->choices);
172 }
173
174 /**
175 * shell_mount_operation_get_show_processes_message:
176 * @self: a #ShellMountOperation
177 *
178 * Returns: (transfer full):
179 */
180 gchar *
181 shell_mount_operation_get_show_processes_message (ShellMountOperation *self)
182 {
183 return g_strdup (self->priv->message);
184 }