From dea7b930918892e2140eeaba37deacfbe089239c Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Fri, 16 Feb 2024 17:31:37 +0000 Subject: Deploy mate-desktop/mate-session-manager to github.com/mate-desktop/mate-session-manager.git:gh-pages --- .../0.html | 1445 ++++ .../1.html | 339 + .../10.html | 483 ++ .../11.html | 437 + .../12.html | 867 ++ .../13.html | 1239 +++ .../14.html | 341 + .../15.html | 1315 +++ .../16.html | 477 ++ .../17.html | 609 ++ .../18.html | 403 + .../19.html | 543 ++ .../2.html | 2079 +++++ .../20.html | 469 ++ .../21.html | 2717 ++++++ .../22.html | 353 + .../23.html | 383 + .../24.html | 1401 ++++ .../25.html | 315 + .../26.html | 571 ++ .../27.html | 2389 ++++++ .../28.html | 427 + .../29.html | 1625 ++++ .../3.html | 315 + .../30.html | 2499 ++++++ .../31.html | 341 + .../32.html | 425 + .../33.html | 1441 ++++ .../34.html | 473 ++ .../35.html | 1311 +++ .../36.html | 341 + .../37.html | 355 + .../38.html | 431 + .../39.html | 8747 ++++++++++++++++++++ .../4.html | 277 + .../40.html | 1419 ++++ .../41.html | 397 + .../42.html | 381 + .../43.html | 315 + .../44.html | 575 ++ .../45.html | 1407 ++++ .../46.html | 567 ++ .../47.html | 747 ++ .../48.html | 1097 +++ .../49.html | 2279 +++++ .../5.html | 365 + .../50.html | 1723 ++++ .../51.html | 3063 +++++++ .../52.html | 1683 ++++ .../53.html | 315 + .../54.html | 1831 ++++ .../55.html | 333 + .../56.html | 349 + .../57.html | 651 ++ .../58.html | 1335 +++ .../59.html | 1231 +++ .../6.html | 419 + .../60.html | 621 ++ .../61.html | 777 ++ .../62.html | 613 ++ .../63.html | 541 ++ .../64.html | 3385 ++++++++ .../65.html | 3055 +++++++ .../66.html | 453 + .../67.html | 327 + .../68.html | 1523 ++++ .../69.html | 1071 +++ .../7.html | 1477 ++++ .../70.html | 381 + .../71.html | 1271 +++ .../72.html | 707 ++ .../73.html | 893 ++ .../74.html | 733 ++ .../75.html | 811 ++ .../8.html | 2633 ++++++ .../9.html | 373 + .../index.html | 793 ++ .../stats.html | 195 + .../style.css | 177 + 79 files changed, 83475 insertions(+) create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/0.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/1.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/10.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/11.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/12.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/13.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/14.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/15.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/16.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/17.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/18.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/19.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/2.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/20.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/21.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/22.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/23.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/24.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/25.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/26.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/27.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/28.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/29.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/3.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/30.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/31.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/32.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/33.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/34.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/35.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/36.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/37.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/38.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/39.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/4.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/40.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/41.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/42.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/43.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/44.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/45.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/46.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/47.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/48.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/49.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/5.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/50.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/51.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/52.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/53.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/54.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/55.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/56.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/57.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/58.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/59.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/6.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/60.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/61.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/62.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/63.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/64.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/65.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/66.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/67.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/68.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/69.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/7.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/70.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/71.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/72.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/73.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/74.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/75.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/8.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/9.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/index.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/stats.html create mode 100644 2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/style.css (limited to '2024-01-23-114035-8717-cppcheck@861c50b8d78a_master') diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/0.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/0.html new file mode 100644 index 0000000..f2552a9 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/0.html @@ -0,0 +1,1445 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-util.h"<--- Include file: "gsm-util.h" not found.
+
+#include "gsm-app-dialog.h"
+
+#define GTKBUILDER_FILE "session-properties.ui"
+
+#define CAPPLET_NAME_ENTRY_WIDGET_NAME    "session_properties_name_entry"
+#define CAPPLET_COMMAND_ENTRY_WIDGET_NAME "session_properties_command_entry"
+#define CAPPLET_COMMENT_ENTRY_WIDGET_NAME "session_properties_comment_entry"
+#define CAPPLET_DELAY_SPIN_WIDGET_NAME    "session_properties_delay_spin"
+#define CAPPLET_BROWSE_WIDGET_NAME        "session_properties_browse_button"
+
+#ifdef __GNUC__
+#define UNUSED_VARIABLE __attribute__ ((unused))
+#else
+#define UNUSED_VARIABLE
+#endif
+
+struct _GsmAppDialog
+{
+        GtkDialog  parent;
+        GtkWidget *name_entry;
+        GtkWidget *command_entry;
+        GtkWidget *comment_entry;
+        GtkWidget *delay_spin;
+        GtkWidget *browse_button;
+        char      *name;
+        char      *command;
+        char      *comment;
+        guint      delay;
+};
+
+enum {
+        PROP_0,
+        PROP_NAME,
+        PROP_COMMAND,
+        PROP_COMMENT,
+        PROP_DELAY
+};
+
+G_DEFINE_TYPE (GsmAppDialog, gsm_app_dialog, GTK_TYPE_DIALOG)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static char *
+make_exec_uri (const char *exec)
+{
+        GString    *str;
+        const char *c;
+
+        if (exec == NULL) {
+                return g_strdup ("");
+        }
+
+        if (strchr (exec, ' ') == NULL) {
+                return g_strdup (exec);
+        }
+
+        str = g_string_new_len (NULL, strlen (exec));
+
+        str = g_string_append_c (str, '"');
+        for (c = exec; *c != '\0'; c++) {
+                /* FIXME: GKeyFile will add an additional backslach so we'll
+                 * end up with toto\\" instead of toto\"
+                 * We could use g_key_file_set_value(), but then we don't
+                 * benefit from the other escaping that glib is doing...
+                 */
+                if (*c == '"') {
+                        str = g_string_append (str, "\\\"");
+                } else {
+                        str = g_string_append_c (str, *c);
+                }
+        }
+        str = g_string_append_c (str, '"');
+
+        return g_string_free (str, FALSE);
+}
+
+static void
+on_browse_button_clicked (GtkWidget    *widget,
+                          GsmAppDialog *dialog)
+{
+        GtkWidget *chooser;
+        int        response;
+
+        chooser = gtk_file_chooser_dialog_new ("",
+                                               GTK_WINDOW (dialog),
+                                               GTK_FILE_CHOOSER_ACTION_OPEN,
+                                               "gtk-cancel",
+                                               GTK_RESPONSE_CANCEL,
+                                               "gtk-open",
+                                               GTK_RESPONSE_ACCEPT,
+                                               NULL);
+
+        gtk_window_set_transient_for (GTK_WINDOW (chooser),
+                                      GTK_WINDOW (dialog));
+
+        gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
+
+        gtk_window_set_title (GTK_WINDOW (chooser), _("Select Command"));
+
+        gtk_widget_show (chooser);
+
+        response = gtk_dialog_run (GTK_DIALOG (chooser));
+
+        if (response == GTK_RESPONSE_ACCEPT) {
+                char *text;
+                char *uri;
+
+                text = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+
+                uri = make_exec_uri (text);
+
+                g_free (text);
+
+                gtk_entry_set_text (GTK_ENTRY (dialog->command_entry), uri);
+
+                g_free (uri);
+        }
+
+        gtk_widget_destroy (chooser);
+}
+
+static void
+on_entry_activate (GtkEntry     *entry,
+                   GsmAppDialog *dialog)
+{
+        gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+}
+
+static gboolean
+on_spin_output (GtkSpinButton *spin, GsmAppDialog *dialog)
+{
+        GtkAdjustment *adjustment;
+        gchar *text;
+        int value;
+
+        adjustment = gtk_spin_button_get_adjustment (spin);
+        value = gtk_adjustment_get_value (adjustment);
+        dialog->delay = value;
+
+        if (value == 1)
+                text = g_strdup_printf ("%d %s", value, _("second"));
+        else if (value > 1)
+                text = g_strdup_printf ("%d %s", value, _("seconds"));
+        else
+                text = g_strdup_printf ("%d", value);
+
+        gtk_entry_set_text (GTK_ENTRY (spin), text);
+        g_free (text);
+
+        return TRUE;
+}
+
+static void
+setup_dialog (GsmAppDialog *dialog)
+{
+        GtkWidget  *content_area;
+        GtkWidget  *widget;
+        GtkBuilder *xml;
+        GError     *error;
+
+        xml = gtk_builder_new ();
+#ifdef ENABLE_NLS
+        gtk_builder_set_translation_domain (xml, GETTEXT_PACKAGE);
+#endif /* ENABLE_NLS */
+
+        error = NULL;
+        if (!gtk_builder_add_from_file (xml,
+                                        GTKBUILDER_DIR "/" GTKBUILDER_FILE,
+                                        &error)) {
+                if (error) {
+                        g_warning ("Could not load capplet UI file: %s",
+                                   error->message);
+                        g_error_free (error);
+                } else {
+                        g_warning ("Could not load capplet UI file.");
+                }
+        }
+
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+        widget = GTK_WIDGET (gtk_builder_get_object (xml, "main-table"));
+        gtk_container_add (GTK_CONTAINER (content_area), widget);
+
+        gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+        gtk_window_set_icon_name (GTK_WINDOW (dialog), "mate-session-properties");
+
+        g_object_set (dialog,
+                      "resizable", FALSE,
+                      NULL);
+
+        gsm_util_dialog_add_button (GTK_DIALOG (dialog),
+                                    _("_Cancel"), "process-stop",
+                                    GTK_RESPONSE_CANCEL);
+
+        if (dialog->name == NULL
+            && dialog->command == NULL
+            && dialog->comment == NULL) {
+                gtk_window_set_title (GTK_WINDOW (dialog), _("Add Startup Program"));
+                gsm_util_dialog_add_button (GTK_DIALOG (dialog),
+                                            _("_Add"), "list-add",
+                                            GTK_RESPONSE_OK);
+        } else {
+                gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Startup Program"));
+                gsm_util_dialog_add_button (GTK_DIALOG (dialog),
+                                            _("_Save"), "document-save",
+                                            GTK_RESPONSE_OK);
+        }
+
+        dialog->name_entry = GTK_WIDGET (gtk_builder_get_object (xml, CAPPLET_NAME_ENTRY_WIDGET_NAME));
+        g_signal_connect (dialog->name_entry,
+                          "activate",
+                          G_CALLBACK (on_entry_activate),
+                          dialog);
+        if (dialog->name != NULL) {
+                gtk_entry_set_text (GTK_ENTRY (dialog->name_entry), dialog->name);
+        }
+
+        dialog->browse_button = GTK_WIDGET (gtk_builder_get_object (xml, CAPPLET_BROWSE_WIDGET_NAME));
+        g_signal_connect (dialog->browse_button,
+                          "clicked",
+                          G_CALLBACK (on_browse_button_clicked),
+                          dialog);
+
+        dialog->command_entry = GTK_WIDGET (gtk_builder_get_object (xml, CAPPLET_COMMAND_ENTRY_WIDGET_NAME));
+        g_signal_connect (dialog->command_entry,
+                          "activate",
+                          G_CALLBACK (on_entry_activate),
+                          dialog);
+        if (dialog->command != NULL) {
+                gtk_entry_set_text (GTK_ENTRY (dialog->command_entry), dialog->command);
+        }
+
+        dialog->comment_entry = GTK_WIDGET (gtk_builder_get_object (xml, CAPPLET_COMMENT_ENTRY_WIDGET_NAME));
+        g_signal_connect (dialog->comment_entry,
+                          "activate",
+                          G_CALLBACK (on_entry_activate),
+                          dialog);
+        if (dialog->comment != NULL) {
+                gtk_entry_set_text (GTK_ENTRY (dialog->comment_entry), dialog->comment);
+        }
+
+        dialog->delay_spin = GTK_WIDGET(gtk_builder_get_object (xml, CAPPLET_DELAY_SPIN_WIDGET_NAME));
+        g_signal_connect (dialog->delay_spin,
+                          "output",
+                          G_CALLBACK (on_spin_output),
+                          dialog);
+        if (dialog->delay > 0) {
+                GtkAdjustment *adjustment;
+                adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON(dialog->delay_spin));
+                gtk_adjustment_set_value (adjustment, (gdouble) dialog->delay);
+        }
+
+        if (xml != NULL) {
+                g_object_unref (xml);
+        }
+}
+
+static GObject *
+gsm_app_dialog_constructor (GType                  type,
+                            guint                  n_construct_app,
+                            GObjectConstructParam *construct_app)
+{
+        GsmAppDialog *dialog;
+
+        dialog = GSM_APP_DIALOG (G_OBJECT_CLASS (gsm_app_dialog_parent_class)->constructor (type,
+                                                                                            n_construct_app,
+                                                                                            construct_app));
+
+        setup_dialog (dialog);
+
+        return G_OBJECT (dialog);
+}
+
+static void
+gsm_app_dialog_dispose (GObject *object)
+{
+        GsmAppDialog *dialog;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_APP_DIALOG (object));
+
+        dialog = GSM_APP_DIALOG (object);
+
+        g_free (dialog->name);
+        dialog->name = NULL;
+        g_free (dialog->command);
+        dialog->command = NULL;
+        g_free (dialog->comment);
+        dialog->comment = NULL;
+
+        G_OBJECT_CLASS (gsm_app_dialog_parent_class)->dispose (object);
+}
+
+static void
+gsm_app_dialog_set_name (GsmAppDialog *dialog,
+                         const char   *name)
+{
+        g_return_if_fail (GSM_IS_APP_DIALOG (dialog));
+
+        g_free (dialog->name);
+
+        dialog->name = g_strdup (name);
+        g_object_notify (G_OBJECT (dialog), "name");
+}
+
+static void
+gsm_app_dialog_set_command (GsmAppDialog *dialog,
+                            const char   *name)
+{
+        g_return_if_fail (GSM_IS_APP_DIALOG (dialog));
+
+        g_free (dialog->command);
+
+        dialog->command = g_strdup (name);
+        g_object_notify (G_OBJECT (dialog), "command");
+}
+
+static void
+gsm_app_dialog_set_comment (GsmAppDialog *dialog,
+                            const char   *name)
+{
+        g_return_if_fail (GSM_IS_APP_DIALOG (dialog));
+
+        g_free (dialog->comment);
+
+        dialog->comment = g_strdup (name);
+        g_object_notify (G_OBJECT (dialog), "comment");
+}
+
+static void
+gsm_app_dialog_set_delay (GsmAppDialog *dialog,
+                          guint delay)
+{
+        g_return_if_fail (GSM_IS_APP_DIALOG (dialog));
+
+        dialog->delay = delay;
+        g_object_notify (G_OBJECT (dialog), "delay");
+}
+
+const char *
+gsm_app_dialog_get_name (GsmAppDialog *dialog)
+{
+        g_return_val_if_fail (GSM_IS_APP_DIALOG (dialog), NULL);
+        return gtk_entry_get_text (GTK_ENTRY (dialog->name_entry));
+}
+
+const char *
+gsm_app_dialog_get_command (GsmAppDialog *dialog)
+{
+        g_return_val_if_fail (GSM_IS_APP_DIALOG (dialog), NULL);
+        return gtk_entry_get_text (GTK_ENTRY (dialog->command_entry));
+}
+
+const char *
+gsm_app_dialog_get_comment (GsmAppDialog *dialog)
+{
+        g_return_val_if_fail (GSM_IS_APP_DIALOG (dialog), NULL);
+        return gtk_entry_get_text (GTK_ENTRY (dialog->comment_entry));
+}
+
+guint
+gsm_app_dialog_get_delay (GsmAppDialog *dialog)
+{
+        g_return_val_if_fail (GSM_IS_APP_DIALOG (dialog), 0);
+        return dialog->delay;
+}
+
+static void
+gsm_app_dialog_set_property (GObject        *object,
+                             guint           prop_id,
+                             const GValue   *value,
+                             GParamSpec     *pspec)
+{
+        GsmAppDialog *dialog = GSM_APP_DIALOG (object);
+
+        switch (prop_id) {
+        case PROP_NAME:
+                gsm_app_dialog_set_name (dialog, g_value_get_string (value));
+                break;
+        case PROP_COMMAND:
+                gsm_app_dialog_set_command (dialog, g_value_get_string (value));
+                break;
+        case PROP_COMMENT:
+                gsm_app_dialog_set_comment (dialog, g_value_get_string (value));
+                break;
+        case PROP_DELAY:
+                gsm_app_dialog_set_delay (dialog, g_value_get_uint (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_app_dialog_get_property (GObject        *object,
+                             guint           prop_id,
+                             GValue         *value,
+                             GParamSpec     *pspec)
+{
+        GsmAppDialog *dialog = GSM_APP_DIALOG (object);
+
+        switch (prop_id) {
+        case PROP_NAME:
+                g_value_set_string (value, dialog->name);
+                break;
+        case PROP_COMMAND:
+                g_value_set_string (value, dialog->command);
+                break;
+        case PROP_COMMENT:
+                g_value_set_string (value, dialog->comment);
+                break;
+        case PROP_DELAY:
+                g_value_set_uint (value, dialog->delay);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_app_dialog_class_init (GsmAppDialogClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsm_app_dialog_get_property;
+        object_class->set_property = gsm_app_dialog_set_property;
+        object_class->constructor = gsm_app_dialog_constructor;
+        object_class->dispose = gsm_app_dialog_dispose;
+
+        g_object_class_install_property (object_class,
+                                         PROP_NAME,
+                                         g_param_spec_string ("name",
+                                                              "name",
+                                                              "name",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_COMMAND,
+                                         g_param_spec_string ("command",
+                                                              "command",
+                                                              "command",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_COMMENT,
+                                         g_param_spec_string ("comment",
+                                                              "comment",
+                                                              "comment",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_DELAY,
+                                         g_param_spec_uint ("delay",
+                                                            "delay",
+                                                            "delay",
+                                                             0,
+                                                             100,
+                                                             0,
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+static void
+gsm_app_dialog_init (GsmAppDialog *dialog)
+{
+
+}
+
+GtkWidget *
+gsm_app_dialog_new (const char *name,
+                    const char *command,
+                    const char *comment,
+                    guint delay)
+{
+        GObject *object;
+
+        object = g_object_new (GSM_TYPE_APP_DIALOG,
+                               "name", name,
+                               "command", command,
+                               "comment", comment,
+                               "delay", delay,
+                               NULL);
+
+        return GTK_WIDGET (object);
+}
+
+gboolean
+gsm_app_dialog_run (GsmAppDialog  *dialog,
+                    char         **name_p,
+                    char         **command_p,
+                    char         **comment_p,
+                    guint         *delay_p)
+{
+        gboolean retval;
+
+        retval = FALSE;
+
+        while (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
+                const char *name;
+                const char *exec;
+                const char *comment;
+                guint       delay;
+                const char *error_msg;
+                GError     *error;
+                char      **argv;
+                int         argc;
+
+                name = gsm_app_dialog_get_name (GSM_APP_DIALOG (dialog));
+                exec = gsm_app_dialog_get_command (GSM_APP_DIALOG (dialog));
+                comment = gsm_app_dialog_get_comment (GSM_APP_DIALOG (dialog));
+                delay = gsm_app_dialog_get_delay (GSM_APP_DIALOG (dialog));
+
+                error = NULL;
+                error_msg = NULL;
+
+                if (gsm_util_text_is_blank (exec)) {
+                        error_msg = _("The startup command cannot be empty");
+                } else {
+                        if (!g_shell_parse_argv (exec, &argc, &argv, &error)) {
+                                if (error != NULL) {
+                                        error_msg = error->message;
+                                } else {
+                                        error_msg = _("The startup command is not valid");
+                                }
+                        }
+                }
+
+                if (error_msg != NULL) {
+                        GtkWidget *msgbox;
+
+                        msgbox = gtk_message_dialog_new (GTK_WINDOW (dialog),
+                                                         GTK_DIALOG_MODAL,
+                                                         GTK_MESSAGE_ERROR,
+                                                         GTK_BUTTONS_CLOSE,
+                                                         "%s", error_msg);
+
+                        if (error != NULL) {
+                                g_error_free (error);
+                        }
+
+                        gtk_dialog_run (GTK_DIALOG (msgbox));
+
+                        gtk_widget_destroy (msgbox);
+
+                        continue;
+                }
+
+                if (gsm_util_text_is_blank (name)) {
+                        name = argv[0];
+                }
+
+                if (name_p) {
+                        *name_p = g_strdup (name);
+                }
+
+                g_strfreev (argv);
+
+                if (command_p) {
+                        *command_p = g_strdup (exec);
+                }
+
+                if (comment_p) {
+                        *comment_p = g_strdup (comment);
+                }
+
+                if (delay_p) {
+                        *delay_p = delay;
+                }
+
+                retval = TRUE;
+                break;
+        }
+
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+
+        return retval;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/1.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/1.html new file mode 100644 index 0000000..082bf83 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/1.html @@ -0,0 +1,339 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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_APP_DIALOG_H
+#define __GSM_APP_DIALOG_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_APP_DIALOG              (gsm_app_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (GsmAppDialog, gsm_app_dialog, GSM, APP_DIALOG, GtkDialog)
+
+GtkWidget            * gsm_app_dialog_new                (const char   *name,
+                                                          const char   *command,
+                                                          const char   *comment,
+                                                          guint         delay);
+
+gboolean               gsm_app_dialog_run               (GsmAppDialog  *dialog,
+                                                         char         **name_p,
+                                                         char         **command_p,
+                                                         char         **comment_p,
+                                                         guint         *delay);
+
+const char *           gsm_app_dialog_get_name           (GsmAppDialog *dialog);
+const char *           gsm_app_dialog_get_command        (GsmAppDialog *dialog);
+const char *           gsm_app_dialog_get_comment        (GsmAppDialog *dialog);
+guint                  gsm_app_dialog_get_delay          (GsmAppDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GSM_APP_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/10.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/10.html new file mode 100644 index 0000000..c975e3d --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/10.html @@ -0,0 +1,483 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/*
+ * gsp-keyfile.c: GKeyFile extensions
+ *
+ * Copyright (C) 2008, 2009 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Based on code from panel-keyfile.c (from mate-panel)
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *        Vincent Untz <vuntz@gnome.org>
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsp-keyfile.h"
+
+void
+gsp_key_file_populate (GKeyFile *keyfile)
+{
+        gsp_key_file_set_string (keyfile,
+                                 G_KEY_FILE_DESKTOP_KEY_TYPE,
+                                 "Application");
+
+        gsp_key_file_set_string (keyfile,
+                                 G_KEY_FILE_DESKTOP_KEY_EXEC,
+                                 "/bin/false");
+}
+
+gboolean
+gsp_key_file_get_boolean (GKeyFile    *keyfile,
+                          const gchar *key,
+                          gboolean     default_value)
+{
+        GError   *error;
+        gboolean  retval;
+
+        error = NULL;
+        retval = g_key_file_get_boolean (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+                                         key, &error);
+        if (error != NULL) {
+                retval = default_value;
+                g_error_free (error);
+        }
+
+        return retval;
+}
+
+void
+gsp_key_file_set_locale_string (GKeyFile    *keyfile,
+                                const gchar *key,
+                                const gchar *value)
+{
+        const char         *locale;
+        const char * const *langs_pointer;
+        int                 i;
+
+        if (value == NULL) {
+                value = "";
+        }
+
+        locale = NULL;
+        langs_pointer = g_get_language_names ();
+        for (i = 0; langs_pointer[i] != NULL; i++) {
+                /* find first without encoding  */
+                if (strchr (langs_pointer[i], '.') == NULL) {
+                        locale = langs_pointer[i];
+                        break;
+                }
+        }
+
+        if (locale != NULL) {
+                g_key_file_set_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+                                              key, locale, value);
+        } else {
+                g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+                                       key, value);
+        }
+}
+
+void
+gsp_key_file_ensure_C_key (GKeyFile   *keyfile,
+                           const char *key)
+{
+        char *C_value;
+        char *buffer;
+
+        /* Make sure we set the "C" locale strings to the terms we set here.
+         * This is so that if the user logs into another locale they get their
+         * own description there rather then empty. It is not the C locale
+         * however, but the user created this entry herself so it's OK */
+        C_value = gsp_key_file_get_string (keyfile, key);
+        if (C_value == NULL || C_value [0] == '\0') {
+                buffer = gsp_key_file_get_locale_string (keyfile, key);
+                if (buffer) {
+                        gsp_key_file_set_string (keyfile, key, buffer);
+                        g_free (buffer);
+                }
+        }
+        g_free (C_value);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/11.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/11.html new file mode 100644 index 0000000..755e020 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/11.html @@ -0,0 +1,437 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * main.c
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-properties-dialog.h"
+
+static gboolean show_version = FALSE;
+
+static GOptionEntry options[] = {
+	{"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
+	{NULL, 0, 0, 0, NULL, NULL, NULL}
+};
+
+static void dialog_response(GsmPropertiesDialog* dialog, guint response_id, gpointer data)
+{
+	GError* error;
+
+	if (response_id == GTK_RESPONSE_HELP)
+	{
+		error = NULL;
+		gtk_show_uri_on_window (GTK_WINDOW (dialog), "help:mate-user-guide/gosstartsession-2",
+					gtk_get_current_event_time (), &error);
+
+		if (error != NULL)
+		{
+			GtkWidget* d = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", _("Could not display help document"));
+			gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(d), "%s", error->message);
+			g_error_free(error);
+
+			gtk_dialog_run(GTK_DIALOG (d));
+			gtk_widget_destroy(d);
+		}
+	}
+	else
+	{
+		gtk_widget_destroy(GTK_WIDGET (dialog));
+		gtk_main_quit();
+	}
+}
+
+int main(int argc, char* argv[])
+{
+	GError* error;
+	GtkWidget* dialog;
+
+#ifdef ENABLE_NLS
+	bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
+	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+	textdomain(GETTEXT_PACKAGE);
+#endif /* ENABLE_NLS */
+
+	error = NULL;
+
+	if (!gtk_init_with_args(&argc, &argv, _("- MATE Session Properties"), options, GETTEXT_PACKAGE, &error))
+	{
+		g_warning("Unable to start: %s", error->message);
+		g_error_free(error);
+		return 1;
+	}
+
+	if (show_version)
+	{
+		g_print("%s %s\n", argv[0], VERSION);
+		return 0;
+	}
+
+	dialog = gsm_properties_dialog_new();
+	g_signal_connect(dialog, "response", G_CALLBACK(dialog_response), NULL);
+	gtk_widget_show(dialog);
+
+	gtk_main();
+
+	return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/12.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/12.html new file mode 100644 index 0000000..efea93a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/12.html @@ -0,0 +1,867 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
#include "config.h"<--- Include file: "config.h" not found.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "msm-desktop-app-dialog.h"
+
+struct _MsmDesktopAppDialog
+{
+    GtkDialog  parent;
+
+    GtkWidget  *entry;
+    GtkWidget  *listbox;
+};
+
+G_DEFINE_TYPE (MsmDesktopAppDialog, msm_desktop_app_dialog, GTK_TYPE_DIALOG)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void
+on_search_entry_changed (GtkSearchEntry      *entry,
+                         MsmDesktopAppDialog *dialog)
+{
+    GtkListBoxRow *selected;
+
+    gtk_list_box_invalidate_filter (GTK_LIST_BOX (dialog->listbox));
+    selected = gtk_list_box_get_selected_row (GTK_LIST_BOX (dialog->listbox));
+
+    if (selected != NULL && gtk_widget_get_mapped (GTK_WIDGET (selected)))
+    {
+        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
+    }
+    else
+    {
+        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
+    }
+}
+
+static gint
+list_sort_app_func (GtkListBoxRow *row1, GtkListBoxRow *row2, gpointer user_data)
+{
+    GAppInfo *app1, *app2;
+
+    app1 = g_object_get_data (G_OBJECT (row1), "appinfo");
+    app2 = g_object_get_data (G_OBJECT (row2), "appinfo");
+
+    return g_utf8_collate (g_app_info_get_name (app1), g_app_info_get_name (app2));
+}
+
+static void
+list_header_app_func (GtkListBoxRow *row, GtkListBoxRow *before, gpointer user_data)
+{
+
+    if (before != NULL && (gtk_list_box_row_get_header (row) == NULL))
+    {
+        gtk_list_box_row_set_header (row,
+                                     gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
+    }
+}
+
+static gboolean
+list_filter_app_func (GtkListBoxRow *row,
+                      gpointer       user_data)
+{
+    MsmDesktopAppDialog *dialog = MSM_DESKTOP_APP_DIALOG (user_data);
+    GAppInfo *app;
+    GString  *s1, *s2;
+
+    app = g_object_get_data (G_OBJECT (row), "appinfo");
+
+    s1 = g_string_new (gtk_entry_get_text (GTK_ENTRY (dialog->entry)));
+    s2 = g_string_new (g_app_info_get_name (app));
+
+    g_string_ascii_up (s1);
+    g_string_ascii_up (s2);
+
+    if (strstr (s2->str, s1->str) != NULL)
+        return TRUE;
+
+    return FALSE;
+}
+
+static void
+on_row_selected (GtkListBox          *box,
+                 GtkListBoxRow       *row,
+                 MsmDesktopAppDialog *dialog)
+{
+    if (row != NULL && gtk_widget_get_mapped (GTK_WIDGET (row)))
+    {
+        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);
+    }
+    else
+    {
+        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
+    }
+}
+
+static void
+setup_dialog (MsmDesktopAppDialog *dialog)
+{
+    GtkStyleContext *context;
+    GtkWidget   *content_area;
+    GtkWidget   *searchbar;
+    GtkWidget   *searchbutton;
+    GtkWidget   *searchimage;
+    GtkWidget   *headerbar;
+    GtkWidget   *sw;
+
+    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+    gtk_container_set_border_width (GTK_CONTAINER (content_area), 6);
+    gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+    gtk_widget_set_size_request (GTK_WIDGET (dialog), 600, 400);
+    gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+    dialog->entry = gtk_search_entry_new ();
+    g_signal_connect (dialog->entry,
+                     "search-changed",
+                      G_CALLBACK (on_search_entry_changed),
+                      dialog);
+
+    gtk_entry_set_placeholder_text (GTK_ENTRY (dialog->entry), _("Search Applications…"));
+    gtk_entry_set_width_chars (GTK_ENTRY (dialog->entry), 30);
+    gtk_entry_set_activates_default (GTK_ENTRY (dialog->entry), TRUE);
+    gtk_entry_set_input_hints (GTK_ENTRY (dialog->entry), GTK_INPUT_HINT_NO_EMOJI);
+
+    searchbar = gtk_search_bar_new ();
+    gtk_container_add (GTK_CONTAINER (searchbar), dialog->entry);
+    gtk_widget_set_hexpand (searchbar, TRUE);
+    gtk_box_pack_start (GTK_BOX (content_area), searchbar, FALSE, FALSE, 0);
+
+    dialog->listbox = gtk_list_box_new ();
+    gtk_list_box_set_activate_on_single_click (GTK_LIST_BOX (dialog->listbox), FALSE);
+    gtk_list_box_set_sort_func (GTK_LIST_BOX (dialog->listbox), list_sort_app_func, dialog, NULL);
+    gtk_list_box_set_header_func (GTK_LIST_BOX (dialog->listbox), list_header_app_func, dialog, NULL);
+    gtk_list_box_set_filter_func (GTK_LIST_BOX (dialog->listbox), list_filter_app_func, dialog, NULL);
+    g_signal_connect (dialog->listbox,
+                     "row-selected",
+                      G_CALLBACK (on_row_selected),
+                      dialog);
+
+    gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Close"), GTK_RESPONSE_CANCEL);
+    gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Add"), GTK_RESPONSE_OK);
+    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+    gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
+
+    sw = gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
+                                    GTK_POLICY_NEVER,
+                                    GTK_POLICY_AUTOMATIC);
+    gtk_container_add (GTK_CONTAINER (sw), dialog->listbox);
+    gtk_box_pack_start (GTK_BOX (content_area), sw, TRUE, TRUE, 0);
+
+    searchbutton = gtk_toggle_button_new ();
+    gtk_widget_set_valign (searchbutton, GTK_ALIGN_CENTER);
+    searchimage = gtk_image_new_from_icon_name ("edit-find", GTK_ICON_SIZE_MENU);
+    gtk_container_add (GTK_CONTAINER (searchbutton), searchimage);
+
+    context = gtk_widget_get_style_context (searchbutton);
+    gtk_style_context_add_class (context, "image-button");
+    gtk_style_context_remove_class (context, "text-button");
+
+    headerbar = gtk_dialog_get_header_bar (GTK_DIALOG (dialog));
+    gtk_header_bar_pack_end (GTK_HEADER_BAR (headerbar), searchbutton);
+    g_object_bind_property (searchbutton, "active", searchbar, "search-mode-enabled", G_BINDING_BIDIRECTIONAL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (searchbutton), TRUE);
+}
+
+static GObject *
+msm_desktop_app_dialog_constructor (GType                  type,
+                                    guint                  n_construct_app,
+                                    GObjectConstructParam *construct_app)
+{
+    MsmDesktopAppDialog *dialog;
+
+    dialog = MSM_DESKTOP_APP_DIALOG (G_OBJECT_CLASS (msm_desktop_app_dialog_parent_class)->constructor (type,
+                                                                                            n_construct_app,
+                                                                                            construct_app));
+
+    setup_dialog (dialog);
+
+    return G_OBJECT (dialog);
+}
+
+static void
+msm_desktop_app_dialog_dispose (GObject *object)
+{
+    g_return_if_fail (object != NULL);
+    g_return_if_fail (MSM_IS_DESKTOP_APP_DIALOG (object));
+
+    G_OBJECT_CLASS (msm_desktop_app_dialog_parent_class)->dispose (object);
+}
+
+static void
+msm_desktop_app_dialog_class_init (MsmDesktopAppDialogClass *klass)
+{
+    GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->constructor = msm_desktop_app_dialog_constructor;
+    object_class->dispose = msm_desktop_app_dialog_dispose;
+}
+
+static void
+msm_desktop_app_dialog_init (MsmDesktopAppDialog *dialog)
+{
+
+}
+
+static GtkWidget *
+create_app_info_row (GAppInfo *app)
+{
+    GtkWidget  *row;
+    GtkWidget  *grid;
+    GtkWidget  *image = NULL;
+    GtkWidget  *label, *label2;
+    gint        height;
+    const char *app_name;
+    const char *app_summary;
+    GIcon      *app_icon;
+
+    row = gtk_list_box_row_new ();
+    grid = gtk_grid_new ();
+    gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
+    gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+
+    app_name = g_app_info_get_name (app);
+    app_icon = g_app_info_get_icon (app);
+    app_summary = g_app_info_get_description (app);
+
+    if (app_name == NULL)
+        return NULL;
+
+    if (app_icon != NULL)
+    {
+        image = gtk_image_new_from_gicon (app_icon, GTK_ICON_SIZE_DIALOG);
+        gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, NULL, &height);
+        gtk_image_set_pixel_size (GTK_IMAGE (image), height);
+        gtk_grid_attach (GTK_GRID (grid), image, 0, 0, 2, 2);
+        gtk_widget_set_hexpand (image, FALSE);
+    }
+
+    label = gtk_label_new (app_name);
+    gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+    gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+    gtk_widget_set_hexpand (label, TRUE);
+    gtk_widget_set_halign (label, GTK_ALIGN_START);
+    gtk_widget_set_vexpand (label, FALSE);
+    gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
+    gtk_grid_attach_next_to (GTK_GRID (grid), label, image, GTK_POS_RIGHT, 1, 1);
+
+    label2 = gtk_label_new (app_summary);
+    gtk_label_set_ellipsize (GTK_LABEL (label2), PANGO_ELLIPSIZE_END);
+    gtk_label_set_max_width_chars (GTK_LABEL (label2), 50);
+    gtk_widget_set_hexpand (label2, TRUE);
+    gtk_widget_set_halign (label2, GTK_ALIGN_START);
+    gtk_widget_set_vexpand (label2, FALSE);
+    gtk_widget_set_valign (label2, GTK_ALIGN_CENTER);
+    gtk_grid_attach_next_to (GTK_GRID (grid), label2, label, GTK_POS_BOTTOM, 1, 1);
+
+    gtk_container_add (GTK_CONTAINER (row), grid);
+    g_object_set_data (G_OBJECT (row), "appinfo", app);
+
+    return row;
+}
+
+GtkWidget *
+msm_desktop_app_dialog_new (GspAppManager *manager)
+{
+    MsmDesktopAppDialog *dialog;
+    gboolean   use_header;
+    GList     *apps, *l;
+
+    g_object_get (gtk_settings_get_default (),
+                 "gtk-dialogs-use-header", &use_header,
+                  NULL);
+
+    dialog = g_object_new (MSM_TYPE_DESKTOP_APP_DIALOG,
+                           "use-header-bar", use_header,
+                           NULL);
+
+    apps = g_app_info_get_all ();
+    for (l = apps; l != NULL; l = l->next)
+    {
+        GAppInfo   *info = l->data;
+        GtkWidget  *row;
+        const char *id;
+
+        id = g_app_info_get_id (info);
+        if (id != NULL && gsp_app_manager_find_app_with_basename (manager, id) == NULL)
+        {
+            if (g_app_info_should_show (info))
+            {
+                row = create_app_info_row (info);
+                if (row != NULL)
+                {
+                    gtk_list_box_prepend (GTK_LIST_BOX (dialog->listbox), row);
+                }
+            }
+        }
+    }
+
+    return GTK_WIDGET (dialog);
+}
+
+const char *
+msm_dektop_app_dialog_get_selected (MsmDesktopAppDialog *dialog)
+{
+    GtkListBoxRow *selected = NULL;
+    GAppInfo *app;
+
+    selected = gtk_list_box_get_selected_row (GTK_LIST_BOX (dialog->listbox));
+    if (selected != NULL)
+    {
+        app = g_object_get_data (G_OBJECT (selected), "appinfo");
+        return g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (app));
+    }
+
+    return NULL;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/13.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/13.html new file mode 100644 index 0000000..114b8d4 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/13.html @@ -0,0 +1,1239 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ * Authors: William Jon McCann <mccann@jhu.edu>
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/extensions/sync.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_XTEST
+#include <X11/keysym.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/extensions/XTest.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_XTEST */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gs-idle-monitor.h"
+
+static void gs_idle_monitor_finalize   (GObject             *object);
+
+struct _GSIdleMonitor {
+        GObject      parent;
+        GHashTable  *watches;
+        int          sync_event_base;
+        XSyncCounter counter;
+
+        /* For use with XTest */
+        int         *keycode;
+        int          keycode1;
+        int          keycode2;
+        gboolean     have_xtest;
+};
+
+typedef struct
+{
+        guint                  id;
+        XSyncValue             interval;
+        GSIdleMonitorWatchFunc callback;
+        gpointer               user_data;
+        XSyncAlarm             xalarm_positive;
+        XSyncAlarm             xalarm_negative;
+} GSIdleMonitorWatch;
+
+static guint32 watch_serial = 1;
+
+G_DEFINE_TYPE (GSIdleMonitor, gs_idle_monitor, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static gint64
+_xsyncvalue_to_int64 (XSyncValue value)
+{
+        return ((guint64) XSyncValueHigh32 (value)) << 32
+                | (guint64) XSyncValueLow32 (value);
+}
+
+static XSyncValue
+_int64_to_xsyncvalue (gint64 value)
+{
+        XSyncValue ret;
+
+        XSyncIntsToValue (&ret, value, ((guint64)value) >> 32);
+
+        return ret;
+}
+
+static void
+gs_idle_monitor_dispose (GObject *object)
+{
+        GSIdleMonitor *monitor;
+
+        g_return_if_fail (GS_IS_IDLE_MONITOR (object));
+
+        monitor = GS_IDLE_MONITOR (object);
+
+        if (monitor->watches != NULL) {
+                g_hash_table_destroy (monitor->watches);
+                monitor->watches = NULL;
+        }
+
+        G_OBJECT_CLASS (gs_idle_monitor_parent_class)->dispose (object);
+}
+
+static gboolean
+_find_alarm (gpointer            key,
+             GSIdleMonitorWatch *watch,
+             XSyncAlarm         *alarm)
+{
+        g_debug ("Searching for %d in %d,%d", (int)*alarm, (int)watch->xalarm_positive, (int)watch->xalarm_negative);
+        if (watch->xalarm_positive == *alarm
+            || watch->xalarm_negative == *alarm) {
+                return TRUE;
+        }
+        return FALSE;
+}
+
+static GSIdleMonitorWatch *
+find_watch_for_alarm (GSIdleMonitor *monitor,
+                      XSyncAlarm     alarm)
+{
+        GSIdleMonitorWatch *watch;
+
+        watch = g_hash_table_find (monitor->watches,
+                                   (GHRFunc)_find_alarm,
+                                   &alarm);
+        return watch;
+}
+
+#ifdef HAVE_XTEST
+static gboolean
+send_fake_event (GSIdleMonitor *monitor)
+{
+        if (! monitor->have_xtest) {
+                return FALSE;
+        }
+
+        g_debug ("GSIdleMonitor: sending fake key");
+
+        XLockDisplay (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+        XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+                           *monitor->keycode,
+                           True,
+                           CurrentTime);
+        XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+                           *monitor->keycode,
+                           False,
+                           CurrentTime);
+        XUnlockDisplay (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+
+        /* Swap the keycode */
+        if (monitor->keycode == &monitor->keycode1) {
+                monitor->keycode = &monitor->keycode2;
+        } else {
+                monitor->keycode = &monitor->keycode1;
+        }
+
+        return TRUE;
+}
+#endif /* HAVE_XTEST */
+
+void
+gs_idle_monitor_reset (GSIdleMonitor *monitor)
+{
+        g_return_if_fail (GS_IS_IDLE_MONITOR (monitor));
+
+#ifdef HAVE_XTEST
+        /* FIXME: is there a better way to reset the IDLETIME? */
+        send_fake_event (monitor);
+#endif
+}
+
+static void
+handle_alarm_notify_event (GSIdleMonitor         *monitor,
+                           XSyncAlarmNotifyEvent *alarm_event)
+{
+        GSIdleMonitorWatch *watch;
+        gboolean            res;
+        gboolean            condition;
+
+        if (alarm_event->state == XSyncAlarmDestroyed) {
+                return;
+        }
+
+        watch = find_watch_for_alarm (monitor, alarm_event->alarm);
+
+        if (watch == NULL) {
+                g_debug ("Unable to find watch for alarm %d", (int)alarm_event->alarm);
+                return;
+        }
+
+        g_debug ("Watch %d fired, idle time = %" G_GINT64_FORMAT,
+                 watch->id,
+                 _xsyncvalue_to_int64 (alarm_event->counter_value));
+
+        if (alarm_event->alarm == watch->xalarm_positive) {
+                condition = TRUE;
+        } else {
+                condition = FALSE;
+        }
+
+        res = TRUE;
+        if (watch->callback != NULL) {
+                res = watch->callback (monitor,
+                                       watch->id,
+                                       condition,
+                                       watch->user_data);
+        }
+
+        if (! res) {
+                /* reset all timers */
+                g_debug ("GSIdleMonitor: callback returned FALSE; resetting idle time");
+                gs_idle_monitor_reset (monitor);
+        }
+}
+
+static GdkFilterReturn
+xevent_filter (GdkXEvent     *xevent,
+               GdkEvent      *event,
+               GSIdleMonitor *monitor)
+{
+        XEvent                *ev;
+        XSyncAlarmNotifyEvent *alarm_event;
+
+        ev = xevent;
+        if (ev->xany.type != monitor->sync_event_base + XSyncAlarmNotify) {
+                return GDK_FILTER_CONTINUE;
+        }
+
+        alarm_event = xevent;
+
+        handle_alarm_notify_event (monitor, alarm_event);
+
+        return GDK_FILTER_CONTINUE;
+}
+
+static gboolean
+init_xsync (GSIdleMonitor *monitor)
+{
+        int                 sync_error_base;
+        int                 res;
+        int                 major;
+        int                 minor;
+        int                 i;
+        int                 ncounters;
+        XSyncSystemCounter *counters;
+
+        res = XSyncQueryExtension (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+                                   &monitor->sync_event_base,
+                                   &sync_error_base);
+        if (! res) {
+                g_warning ("GSIdleMonitor: Sync extension not present");
+                return FALSE;
+        }
+
+        res = XSyncInitialize (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &major, &minor);
+        if (! res) {
+                g_warning ("GSIdleMonitor: Unable to initialize Sync extension");
+                return FALSE;
+        }
+
+        counters = XSyncListSystemCounters (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &ncounters);
+        for (i = 0; i < ncounters; i++) {
+                if (counters[i].name != NULL
+                    && strcmp (counters[i].name, "IDLETIME") == 0) {
+                        monitor->counter = counters[i].counter;
+                        break;
+                }
+        }
+        XSyncFreeSystemCounterList (counters);
+
+        if (monitor->counter == None) {
+                g_warning ("GSIdleMonitor: IDLETIME counter not found");
+                return FALSE;
+        }
+
+        gdk_window_add_filter (NULL, (GdkFilterFunc)xevent_filter, monitor);
+
+        return TRUE;
+}
+
+static void
+_init_xtest (GSIdleMonitor *monitor)
+{
+#ifdef HAVE_XTEST
+        int a, b, c, d;
+
+        XLockDisplay (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+        monitor->have_xtest = (XTestQueryExtension (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), &a, &b, &c, &d) == True);
+        if (monitor->have_xtest) {
+                monitor->keycode1 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XK_Alt_L);
+                if (monitor->keycode1 == 0) {
+                        g_warning ("keycode1 not existent");
+                }
+                monitor->keycode2 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XK_Alt_R);
+                if (monitor->keycode2 == 0) {
+                        monitor->keycode2 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), XK_Alt_L);
+                        if (monitor->keycode2 == 0) {
+                                g_warning ("keycode2 not existent");
+                        }
+                }
+                monitor->keycode = &monitor->keycode1;
+        }
+        XUnlockDisplay (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()));
+#endif /* HAVE_XTEST */
+}
+
+static GObject *
+gs_idle_monitor_constructor (GType                  type,
+                             guint                  n_construct_properties,
+                             GObjectConstructParam *construct_properties)
+{
+        GSIdleMonitor *monitor;
+
+        monitor = GS_IDLE_MONITOR (G_OBJECT_CLASS (gs_idle_monitor_parent_class)->constructor (type,
+                                                                                               n_construct_properties,
+                                                                                               construct_properties));
+
+        _init_xtest (monitor);
+
+        if (! init_xsync (monitor)) {
+                g_object_unref (monitor);
+                return NULL;
+        }
+
+        return G_OBJECT (monitor);
+}
+
+static void
+gs_idle_monitor_class_init (GSIdleMonitorClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = gs_idle_monitor_finalize;
+        object_class->dispose = gs_idle_monitor_dispose;
+        object_class->constructor = gs_idle_monitor_constructor;
+}
+
+static guint32
+get_next_watch_serial (void)
+{
+        guint32 serial;
+
+        serial = watch_serial++;
+
+        if ((gint32)watch_serial < 0) {
+                watch_serial = 1;
+        }
+
+        /* FIXME: make sure it isn't in the hash */
+
+        return serial;
+}
+
+static GSIdleMonitorWatch *
+idle_monitor_watch_new (guint interval)
+{
+        GSIdleMonitorWatch *watch;
+
+        watch = g_slice_new0 (GSIdleMonitorWatch);
+        watch->interval = _int64_to_xsyncvalue ((gint64)interval);
+        watch->id = get_next_watch_serial ();
+        watch->xalarm_positive = None;
+        watch->xalarm_negative = None;
+
+        return watch;
+}
+
+static void
+idle_monitor_watch_free (GSIdleMonitorWatch *watch)
+{
+        if (watch == NULL) {
+                return;
+        }
+        if (watch->xalarm_positive != None) {
+                XSyncDestroyAlarm (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), watch->xalarm_positive);
+        }
+        if (watch->xalarm_negative != None) {
+                XSyncDestroyAlarm (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), watch->xalarm_negative);
+        }
+        g_slice_free (GSIdleMonitorWatch, watch);
+}
+
+static void
+gs_idle_monitor_init (GSIdleMonitor *monitor)
+{
+        monitor->watches = g_hash_table_new_full (NULL,
+                                                  NULL,
+                                                  NULL,
+                                                  (GDestroyNotify)idle_monitor_watch_free);
+
+        monitor->counter = None;
+}
+
+static void
+gs_idle_monitor_finalize (GObject *object)
+{
+        GSIdleMonitor *idle_monitor;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GS_IS_IDLE_MONITOR (object));
+
+        idle_monitor = GS_IDLE_MONITOR (object);
+
+        g_return_if_fail (idle_monitor != NULL);
+
+        G_OBJECT_CLASS (gs_idle_monitor_parent_class)->finalize (object);
+}
+
+GSIdleMonitor *
+gs_idle_monitor_new (void)
+{
+        GObject *idle_monitor;
+
+        idle_monitor = g_object_new (GS_TYPE_IDLE_MONITOR,
+                                     NULL);
+
+        return GS_IDLE_MONITOR (idle_monitor);
+}
+
+static gboolean
+_xsync_alarm_set (GSIdleMonitor      *monitor,
+                  GSIdleMonitorWatch *watch)
+{
+        XSyncAlarmAttributes attr;
+        XSyncValue           delta;
+        guint                flags;
+
+        flags = XSyncCACounter
+                | XSyncCAValueType
+                | XSyncCATestType
+                | XSyncCAValue
+                | XSyncCADelta
+                | XSyncCAEvents;
+
+        XSyncIntToValue (&delta, 0);
+        attr.trigger.counter = monitor->counter;
+        attr.trigger.value_type = XSyncAbsolute;
+        attr.trigger.wait_value = watch->interval;
+        attr.delta = delta;
+        attr.events = TRUE;
+
+        attr.trigger.wait_value = _int64_to_xsyncvalue (_xsyncvalue_to_int64 (watch->interval) - 1);
+        attr.trigger.test_type = XSyncPositiveTransition;
+        if (watch->xalarm_positive != None) {
+                g_debug ("GSIdleMonitor: updating alarm for positive transition wait=%" G_GINT64_FORMAT,
+                         _xsyncvalue_to_int64 (attr.trigger.wait_value));
+                XSyncChangeAlarm (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), watch->xalarm_positive, flags, &attr);
+        } else {
+                g_debug ("GSIdleMonitor: creating new alarm for positive transition wait=%" G_GINT64_FORMAT,
+                         _xsyncvalue_to_int64 (attr.trigger.wait_value));
+                watch->xalarm_positive = XSyncCreateAlarm (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), flags, &attr);
+        }
+
+        attr.trigger.test_type = XSyncNegativeTransition;
+        if (watch->xalarm_negative != None) {
+                g_debug ("GSIdleMonitor: updating alarm for negative transition wait=%" G_GINT64_FORMAT,
+                         _xsyncvalue_to_int64 (attr.trigger.wait_value));
+                XSyncChangeAlarm (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), watch->xalarm_negative, flags, &attr);
+        } else {
+                g_debug ("GSIdleMonitor: creating new alarm for negative transition wait=%" G_GINT64_FORMAT,
+                         _xsyncvalue_to_int64 (attr.trigger.wait_value));
+                watch->xalarm_negative = XSyncCreateAlarm (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), flags, &attr);
+        }
+
+        return TRUE;
+}
+
+guint
+gs_idle_monitor_add_watch (GSIdleMonitor         *monitor,
+                           guint                  interval,
+                           GSIdleMonitorWatchFunc callback,
+                           gpointer               user_data)
+{
+        GSIdleMonitorWatch *watch;
+
+        g_return_val_if_fail (GS_IS_IDLE_MONITOR (monitor), 0);
+        g_return_val_if_fail (callback != NULL, 0);
+
+        watch = idle_monitor_watch_new (interval);
+        watch->callback = callback;
+        watch->user_data = user_data;
+
+        _xsync_alarm_set (monitor, watch);
+
+        g_hash_table_insert (monitor->watches,
+                             GUINT_TO_POINTER (watch->id),
+                             watch);
+        return watch->id;
+}
+
+void
+gs_idle_monitor_remove_watch (GSIdleMonitor *monitor,
+                              guint          id)
+{
+        g_return_if_fail (GS_IS_IDLE_MONITOR (monitor));
+
+        g_hash_table_remove (monitor->watches,
+                             GUINT_TO_POINTER (id));
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/14.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/14.html new file mode 100644 index 0000000..d72b781 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/14.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ * Authors: William Jon McCann <mccann@jhu.edu>
+ *
+ */
+
+#ifndef __GS_IDLE_MONITOR_H
+#define __GS_IDLE_MONITOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS<--- syntax error
+
+#define GS_TYPE_IDLE_MONITOR         (gs_idle_monitor_get_type ())
+G_DECLARE_FINAL_TYPE (GSIdleMonitor, gs_idle_monitor, GS, IDLE_MONITOR, GObject)
+
+typedef gboolean (*GSIdleMonitorWatchFunc) (GSIdleMonitor *monitor,
+                                            guint          id,
+                                            gboolean       condition,
+                                            gpointer       user_data);
+
+GSIdleMonitor * gs_idle_monitor_new            (void);
+
+guint           gs_idle_monitor_add_watch      (GSIdleMonitor         *monitor,
+                                                guint                  interval,
+                                                GSIdleMonitorWatchFunc callback,
+                                                gpointer               user_data);
+
+void            gs_idle_monitor_remove_watch   (GSIdleMonitor         *monitor,
+                                                guint                  id);
+void            gs_idle_monitor_reset          (GSIdleMonitor         *monitor);
+
+G_END_DECLS
+
+#endif /* __GS_IDLE_MONITOR_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/15.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/15.html new file mode 100644 index 0000000..5bdaef8 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/15.html @@ -0,0 +1,1315 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-app.h"
+#include "gsm-app-glue.h"
+
+typedef struct {
+        char            *id;
+        char            *app_id;
+        int              phase;
+        char            *startup_id;
+        DBusGConnection *connection;
+} GsmAppPrivate;
+
+enum {
+        EXITED,
+        DIED,
+        REGISTERED,
+        LAST_SIGNAL
+};
+
+static guint32 app_serial = 1;
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+enum {
+        PROP_0,
+        PROP_ID,
+        PROP_STARTUP_ID,
+        PROP_PHASE,
+        LAST_PROP
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmApp, gsm_app, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+GQuark
+gsm_app_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_app_error");
+        }
+
+        return ret;
+
+}
+
+static guint32
+get_next_app_serial (void)
+{
+        guint32 serial;
+
+        serial = app_serial++;
+
+        if ((gint32)app_serial < 0) {
+                app_serial = 1;
+        }
+
+        return serial;
+}
+
+static gboolean
+register_app (GsmApp *app)
+{
+        GError *error;
+        GsmAppPrivate *priv;
+
+        error = NULL;
+        priv = gsm_app_get_instance_private (app);
+
+        priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (priv->connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                return FALSE;
+        }
+
+        dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (app));
+
+        return TRUE;
+}
+
+static GObject *
+gsm_app_constructor (GType                  type,
+                     guint                  n_construct_properties,
+                     GObjectConstructParam *construct_properties)
+{
+        GsmApp    *app;
+        gboolean   res;
+        GsmAppPrivate *priv;
+
+        app = GSM_APP (G_OBJECT_CLASS (gsm_app_parent_class)->constructor (type,
+                                                                           n_construct_properties,
+                                                                           construct_properties));
+        priv = gsm_app_get_instance_private (app);
+
+        g_free (priv->id);
+        priv->id = g_strdup_printf ("/org/gnome/SessionManager/App%u", get_next_app_serial ());
+
+        res = register_app (app);
+        if (! res) {
+                g_warning ("Unable to register app with session bus");
+        }
+
+        return G_OBJECT (app);
+}
+
+static void
+gsm_app_init (GsmApp *app)
+{
+}
+
+static void
+gsm_app_set_phase (GsmApp *app,
+                   int     phase)
+{
+        GsmAppPrivate *priv;
+        g_return_if_fail (GSM_IS_APP (app));
+
+        priv = gsm_app_get_instance_private (app);
+
+        priv->phase = phase;
+}
+
+static void
+gsm_app_set_id (GsmApp     *app,
+                const char *id)
+{
+        GsmAppPrivate *priv;
+        g_return_if_fail (GSM_IS_APP (app));
+
+        priv = gsm_app_get_instance_private (app);
+
+        g_free (priv->id);
+
+        priv->id = g_strdup (id);
+        g_object_notify (G_OBJECT (app), "id");
+
+}
+static void
+gsm_app_set_startup_id (GsmApp     *app,
+                        const char *startup_id)
+{
+        GsmAppPrivate *priv;
+        g_return_if_fail (GSM_IS_APP (app));
+
+        priv = gsm_app_get_instance_private (app);
+
+        g_free (priv->startup_id);
+
+        priv->startup_id = g_strdup (startup_id);
+        g_object_notify (G_OBJECT (app), "startup-id");
+
+}
+
+static void
+gsm_app_set_property (GObject      *object,
+                      guint         prop_id,
+                      const GValue *value,
+                      GParamSpec   *pspec)
+{
+        GsmApp *app = GSM_APP (object);
+
+        switch (prop_id) {
+        case PROP_STARTUP_ID:
+                gsm_app_set_startup_id (app, g_value_get_string (value));
+                break;
+        case PROP_ID:
+                gsm_app_set_id (app, g_value_get_string (value));
+                break;
+        case PROP_PHASE:
+                gsm_app_set_phase (app, g_value_get_int (value));
+                break;
+        default:
+                break;
+        }
+}
+
+static void
+gsm_app_get_property (GObject    *object,
+                      guint       prop_id,
+                      GValue     *value,
+                      GParamSpec *pspec)
+{
+        GsmAppPrivate *priv;
+        GsmApp *app = GSM_APP (object);
+
+        priv = gsm_app_get_instance_private (app);
+
+        switch (prop_id) {
+        case PROP_STARTUP_ID:
+                g_value_set_string (value, priv->startup_id);
+                break;
+        case PROP_ID:
+                g_value_set_string (value, priv->id);
+                break;
+        case PROP_PHASE:
+                g_value_set_int (value, priv->phase);
+                break;
+        default:
+                break;
+        }
+}
+
+static void
+gsm_app_dispose (GObject *object)
+{
+        GsmAppPrivate *priv;
+        GsmApp *app = GSM_APP (object);
+
+        priv = gsm_app_get_instance_private (app);
+
+        g_free (priv->startup_id);
+        priv->startup_id = NULL;
+
+        g_free (priv->id);
+        priv->id = NULL;
+
+        G_OBJECT_CLASS (gsm_app_parent_class)->dispose (object);
+}
+
+static void
+gsm_app_class_init (GsmAppClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->set_property = gsm_app_set_property;
+        object_class->get_property = gsm_app_get_property;
+        object_class->dispose = gsm_app_dispose;
+        object_class->constructor = gsm_app_constructor;
+
+        klass->impl_start = NULL;
+        klass->impl_get_app_id = NULL;
+        klass->impl_get_autorestart = NULL;
+        klass->impl_provides = NULL;
+        klass->impl_is_running = NULL;
+        klass->impl_peek_autostart_delay = NULL;
+
+        g_object_class_install_property (object_class,
+                                         PROP_PHASE,
+                                         g_param_spec_int ("phase",
+                                                           "Phase",
+                                                           "Phase",
+                                                           -1,
+                                                           G_MAXINT,
+                                                           -1,
+                                                           G_PARAM_READWRITE));
+        g_object_class_install_property (object_class,
+                                         PROP_ID,
+                                         g_param_spec_string ("id",
+                                                              "ID",
+                                                              "ID",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_STARTUP_ID,
+                                         g_param_spec_string ("startup-id",
+                                                              "startup ID",
+                                                              "Session management startup ID",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+        signals[EXITED] =
+                g_signal_new ("exited",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmAppClass, exited),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+        signals[DIED] =
+                g_signal_new ("died",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmAppClass, died),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+
+        signals[REGISTERED] =
+                g_signal_new ("registered",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmAppClass, registered),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+
+        dbus_g_object_type_install_info (GSM_TYPE_APP, &dbus_glib_gsm_app_object_info);
+}
+
+const char *
+gsm_app_peek_id (GsmApp *app)
+{
+        GsmAppPrivate *priv;
+        priv = gsm_app_get_instance_private (app);
+
+        return priv->id;
+}
+
+const char *
+gsm_app_peek_app_id (GsmApp *app)
+{
+        return GSM_APP_GET_CLASS (app)->impl_get_app_id (app);
+}
+
+const char *
+gsm_app_peek_startup_id (GsmApp *app)
+{
+        GsmAppPrivate *priv;
+
+        priv = gsm_app_get_instance_private (app);
+        return priv->startup_id;
+}
+
+/**
+ * gsm_app_peek_phase:
+ * @app: a %GsmApp
+ *
+ * Returns @app's startup phase.
+ *
+ * Return value: @app's startup phase
+ **/
+GsmManagerPhase
+gsm_app_peek_phase (GsmApp *app)
+{
+        GsmAppPrivate *priv;
+        g_return_val_if_fail (GSM_IS_APP (app), GSM_MANAGER_PHASE_APPLICATION);
+
+        priv = gsm_app_get_instance_private (app);
+
+        return priv->phase;
+}
+
+gboolean
+gsm_app_peek_is_disabled (GsmApp *app)
+{
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        if (GSM_APP_GET_CLASS (app)->impl_is_disabled) {
+                return GSM_APP_GET_CLASS (app)->impl_is_disabled (app);
+        } else {
+                return FALSE;
+        }
+}
+
+gboolean
+gsm_app_peek_is_conditionally_disabled (GsmApp *app)
+{
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        if (GSM_APP_GET_CLASS (app)->impl_is_conditionally_disabled) {
+                return GSM_APP_GET_CLASS (app)->impl_is_conditionally_disabled (app);
+        } else {
+                return FALSE;
+        }
+}
+
+gboolean
+gsm_app_is_running (GsmApp *app)
+{
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        if (GSM_APP_GET_CLASS (app)->impl_is_running) {
+                return GSM_APP_GET_CLASS (app)->impl_is_running (app);
+        } else {
+                return FALSE;
+        }
+}
+
+gboolean
+gsm_app_peek_autorestart (GsmApp *app)
+{
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        if (GSM_APP_GET_CLASS (app)->impl_get_autorestart) {
+                return GSM_APP_GET_CLASS (app)->impl_get_autorestart (app);
+        } else {
+                return FALSE;
+        }
+}
+
+gboolean
+gsm_app_provides (GsmApp *app, const char *service)
+{
+
+        if (GSM_APP_GET_CLASS (app)->impl_provides) {
+                return GSM_APP_GET_CLASS (app)->impl_provides (app, service);
+        } else {
+                return FALSE;
+        }
+}
+
+gboolean
+gsm_app_has_autostart_condition (GsmApp     *app,
+                                 const char *condition)
+{
+
+        if (GSM_APP_GET_CLASS (app)->impl_has_autostart_condition) {
+                return GSM_APP_GET_CLASS (app)->impl_has_autostart_condition (app, condition);
+        } else {
+                return FALSE;
+        }
+}
+
+gboolean
+gsm_app_start (GsmApp  *app,
+               GError **error)
+{
+        GsmAppPrivate *priv;
+
+        priv = gsm_app_get_instance_private (app);
+        g_debug ("Starting app: %s", priv->id);
+
+        return GSM_APP_GET_CLASS (app)->impl_start (app, error);
+}
+
+gboolean
+gsm_app_restart (GsmApp  *app,
+                 GError **error)
+{
+        GsmAppPrivate *priv;
+
+        priv = gsm_app_get_instance_private (app);
+
+        g_debug ("Re-starting app: %s", priv->id);
+
+        return GSM_APP_GET_CLASS (app)->impl_restart (app, error);
+}
+
+gboolean
+gsm_app_stop (GsmApp  *app,
+              GError **error)
+{
+        return GSM_APP_GET_CLASS (app)->impl_stop (app, error);
+}
+
+void
+gsm_app_registered (GsmApp *app)
+{
+        g_return_if_fail (GSM_IS_APP (app));
+
+        g_signal_emit (app, signals[REGISTERED], 0);
+}
+
+int
+gsm_app_peek_autostart_delay (GsmApp *app)
+{
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        if (GSM_APP_GET_CLASS (app)->impl_peek_autostart_delay) {
+                return GSM_APP_GET_CLASS (app)->impl_peek_autostart_delay (app);
+        } else {
+                return 0;
+        }
+}
+
+void
+gsm_app_exited (GsmApp *app)
+{
+        g_return_if_fail (GSM_IS_APP (app));
+
+        g_signal_emit (app, signals[EXITED], 0);
+}
+
+void
+gsm_app_died (GsmApp *app)
+{
+        g_return_if_fail (GSM_IS_APP (app));
+
+        g_signal_emit (app, signals[DIED], 0);
+}
+
+gboolean
+gsm_app_get_app_id (GsmApp     *app,
+                    char      **id,
+                    GError    **error)
+{
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+        *id = g_strdup (GSM_APP_GET_CLASS (app)->impl_get_app_id (app));
+        return TRUE;
+}
+
+gboolean
+gsm_app_get_startup_id (GsmApp     *app,
+                        char      **id,
+                        GError    **error)
+{
+        GsmAppPrivate *priv;
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        priv = gsm_app_get_instance_private (app);
+        *id = g_strdup (priv->startup_id);
+        return TRUE;
+}
+
+gboolean
+gsm_app_get_phase (GsmApp     *app,
+                   guint      *phase,
+                   GError    **error)
+{
+        GsmAppPrivate *priv;
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        priv = gsm_app_get_instance_private (app);
+        *phase = priv->phase;
+        return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/16.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/16.html new file mode 100644 index 0000000..cb85bff --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/16.html @@ -0,0 +1,477 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_APP_H__
+#define __GSM_APP_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "eggdesktopfile.h"<--- Include file: "eggdesktopfile.h" not found.
+
+#include "gsm-manager.h"
+#include "gsm-client.h"
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_APP            (gsm_app_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsmApp, gsm_app, GSM, APP, GObject)
+
+struct _GsmAppClass
+{
+        GObjectClass parent_class;
+
+        /* signals */
+        void        (*exited)       (GsmApp *app);
+        void        (*died)         (GsmApp *app);
+        void        (*registered)   (GsmApp *app);
+
+        /* virtual methods */
+        gboolean    (*impl_start)                     (GsmApp     *app,
+                                                       GError    **error);
+        gboolean    (*impl_restart)                   (GsmApp     *app,
+                                                       GError    **error);
+        gboolean    (*impl_stop)                      (GsmApp     *app,
+                                                       GError    **error);
+        int         (*impl_peek_autostart_delay)      (GsmApp     *app);
+        gboolean    (*impl_provides)                  (GsmApp     *app,
+                                                       const char *service);
+        gboolean    (*impl_has_autostart_condition)   (GsmApp     *app,
+                                                       const char *service);
+        gboolean    (*impl_is_running)                (GsmApp     *app);
+
+        gboolean    (*impl_get_autorestart)           (GsmApp     *app);
+        const char *(*impl_get_app_id)                (GsmApp     *app);
+        gboolean    (*impl_is_disabled)               (GsmApp     *app);
+        gboolean    (*impl_is_conditionally_disabled) (GsmApp     *app);
+};
+
+typedef enum
+{
+        GSM_APP_ERROR_GENERAL = 0,
+        GSM_APP_ERROR_START,
+        GSM_APP_ERROR_STOP,
+        GSM_APP_NUM_ERRORS
+} GsmAppError;
+
+#define GSM_APP_ERROR gsm_app_error_quark ()
+
+GQuark           gsm_app_error_quark                    (void);
+
+gboolean         gsm_app_peek_autorestart               (GsmApp     *app);
+
+const char      *gsm_app_peek_id                        (GsmApp     *app);
+const char      *gsm_app_peek_app_id                    (GsmApp     *app);
+const char      *gsm_app_peek_startup_id                (GsmApp     *app);
+GsmManagerPhase  gsm_app_peek_phase                     (GsmApp     *app);
+gboolean         gsm_app_peek_is_disabled               (GsmApp     *app);
+gboolean         gsm_app_peek_is_conditionally_disabled (GsmApp     *app);
+
+gboolean         gsm_app_start                          (GsmApp     *app,
+                                                         GError    **error);
+gboolean         gsm_app_restart                        (GsmApp     *app,
+                                                         GError    **error);
+gboolean         gsm_app_stop                           (GsmApp     *app,
+                                                         GError    **error);
+gboolean         gsm_app_is_running                     (GsmApp     *app);
+
+void             gsm_app_exited                         (GsmApp     *app);
+void             gsm_app_died                           (GsmApp     *app);
+
+gboolean         gsm_app_provides                       (GsmApp     *app,
+                                                         const char *service);
+gboolean         gsm_app_has_autostart_condition        (GsmApp     *app,
+                                                         const char *condition);
+void             gsm_app_registered                     (GsmApp     *app);
+int              gsm_app_peek_autostart_delay           (GsmApp     *app);
+
+/* exported to bus */
+gboolean         gsm_app_get_app_id                     (GsmApp     *app,
+                                                         char      **id,
+                                                         GError    **error);
+gboolean         gsm_app_get_startup_id                 (GsmApp     *app,
+                                                         char      **id,
+                                                         GError    **error);
+gboolean         gsm_app_get_phase                      (GsmApp     *app,
+                                                         guint      *phase,
+                                                         GError    **error);
+
+G_END_DECLS
+
+#endif /* __GSM_APP_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/17.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/17.html new file mode 100644 index 0000000..ab6e7b2 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/17.html @@ -0,0 +1,609 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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_MANAGER_H
+#define __GSM_MANAGER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-store.h"
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_MANAGER         (gsm_manager_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsmManager, gsm_manager, GSM, MANAGER, GObject)
+
+struct _GsmManagerClass
+{
+        GObjectClass   parent_class;
+
+        void          (* session_running)     (GsmManager      *manager);
+        void          (* session_over)        (GsmManager      *manager);
+        void          (* session_over_notice) (GsmManager      *manager);
+
+        void          (* phase_changed)       (GsmManager      *manager,
+                                               const char      *phase);
+
+        void          (* client_added)        (GsmManager      *manager,
+                                               const char      *id);
+        void          (* client_removed)      (GsmManager      *manager,
+                                               const char      *id);
+        void          (* inhibitor_added)     (GsmManager      *manager,
+                                               const char      *id);
+        void          (* inhibitor_removed)   (GsmManager      *manager,
+                                               const char      *id);
+}; //GsmManagerClass;
+
+typedef enum {
+        /* gsm's own startup/initialization phase */
+        GSM_MANAGER_PHASE_STARTUP = 0,
+        /* xrandr setup, mate-settings-daemon, etc */
+        GSM_MANAGER_PHASE_INITIALIZATION,
+        /* window/compositing managers */
+        GSM_MANAGER_PHASE_WINDOW_MANAGER,
+        /* apps that will create _NET_WM_WINDOW_TYPE_PANEL windows */
+        GSM_MANAGER_PHASE_PANEL,
+        /* apps that will create _NET_WM_WINDOW_TYPE_DESKTOP windows */
+        GSM_MANAGER_PHASE_DESKTOP,
+        /* everything else */
+        GSM_MANAGER_PHASE_APPLICATION,
+        /* done launching */
+        GSM_MANAGER_PHASE_RUNNING,
+        /* shutting down */
+        GSM_MANAGER_PHASE_QUERY_END_SESSION,
+        GSM_MANAGER_PHASE_END_SESSION,
+        GSM_MANAGER_PHASE_EXIT
+} GsmManagerPhase;
+
+typedef enum
+{
+        GSM_MANAGER_ERROR_GENERAL = 0,
+        GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION,
+        GSM_MANAGER_ERROR_NOT_IN_RUNNING,
+        GSM_MANAGER_ERROR_ALREADY_REGISTERED,
+        GSM_MANAGER_ERROR_NOT_REGISTERED,
+        GSM_MANAGER_ERROR_INVALID_OPTION,
+        GSM_MANAGER_ERROR_LOCKED_DOWN,
+        GSM_MANAGER_NUM_ERRORS
+} GsmManagerError;
+
+#define GSM_MANAGER_ERROR gsm_manager_error_quark ()
+
+typedef enum {
+        GSM_MANAGER_LOGOUT_MODE_NORMAL = 0,
+        GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION,
+        GSM_MANAGER_LOGOUT_MODE_FORCE
+} GsmManagerLogoutMode;
+
+GType               gsm_manager_error_get_type                 (void);
+#define GSM_MANAGER_TYPE_ERROR (gsm_manager_error_get_type ())
+
+GQuark              gsm_manager_error_quark                    (void);
+
+GsmManager *        gsm_manager_new                            (GsmStore       *client_store,
+                                                                gboolean        failsafe);
+
+gboolean            gsm_manager_add_autostart_app              (GsmManager     *manager,
+                                                                const char     *path,
+                                                                const char     *provides);
+gboolean            gsm_manager_add_autostart_apps_from_dir    (GsmManager     *manager,
+                                                                const char     *path);
+gboolean            gsm_manager_add_legacy_session_apps        (GsmManager     *manager,
+                                                                const char     *path);
+
+void                gsm_manager_start                          (GsmManager     *manager);
+
+/* exported methods */
+
+gboolean            gsm_manager_register_client                (GsmManager            *manager,
+                                                                const char            *app_id,
+                                                                const char            *client_startup_id,
+                                                                DBusGMethodInvocation *context);
+gboolean            gsm_manager_unregister_client              (GsmManager            *manager,
+                                                                const char            *session_client_id,
+                                                                DBusGMethodInvocation *context);
+
+gboolean            gsm_manager_inhibit                        (GsmManager            *manager,
+                                                                const char            *app_id,
+                                                                guint                  toplevel_xid,
+                                                                const char            *reason,
+                                                                guint                  flags,
+                                                                DBusGMethodInvocation *context);
+gboolean            gsm_manager_uninhibit                      (GsmManager            *manager,
+                                                                guint                  inhibit_cookie,
+                                                                DBusGMethodInvocation *context);
+gboolean            gsm_manager_is_inhibited                   (GsmManager            *manager,
+                                                                guint                  flags,
+                                                                gboolean              *is_inhibited,
+                                                                GError                *error);
+
+gboolean            gsm_manager_request_shutdown               (GsmManager     *manager,
+                                                                GError        **error);
+
+gboolean            gsm_manager_request_reboot                 (GsmManager     *manager,
+                                                                GError        **error);
+
+gboolean            gsm_manager_shutdown                       (GsmManager     *manager,
+                                                                GError        **error);
+
+gboolean            gsm_manager_can_shutdown                   (GsmManager     *manager,
+                                                                gboolean       *shutdown_available,
+                                                                GError        **error);
+gboolean            gsm_manager_logout                         (GsmManager     *manager,
+                                                                guint           logout_mode,
+                                                                GError        **error);
+
+gboolean            gsm_manager_setenv                         (GsmManager     *manager,
+                                                                const char     *variable,
+                                                                const char     *value,
+                                                                GError        **error);
+gboolean            gsm_manager_initialization_error           (GsmManager     *manager,
+                                                                const char     *message,
+                                                                gboolean        fatal,
+                                                                GError        **error);
+
+gboolean            gsm_manager_get_clients                    (GsmManager     *manager,
+                                                                GPtrArray     **clients,
+                                                                GError        **error);
+gboolean            gsm_manager_get_inhibitors                 (GsmManager     *manager,
+                                                                GPtrArray     **inhibitors,
+                                                                GError        **error);
+gboolean            gsm_manager_is_autostart_condition_handled (GsmManager     *manager,
+                                                                const char     *condition,
+                                                                gboolean       *handled,
+                                                                GError        **error);
+gboolean            gsm_manager_set_phase                      (GsmManager     *manager,
+                                                                GsmManagerPhase phase);
+
+gboolean            gsm_manager_is_session_running             (GsmManager *manager,
+                                                                gboolean *running,
+                                                                GError **error);
+
+void                _gsm_manager_set_renderer                  (GsmManager     *manager,
+                                                                const char     *renderer);
+
+G_END_DECLS<--- syntax error
+
+#endif /* __GSM_MANAGER_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/18.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/18.html new file mode 100644 index 0000000..0b2d9d3 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/18.html @@ -0,0 +1,403 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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_STORE_H
+#define __GSM_STORE_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_STORE         (gsm_store_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsmStore, gsm_store, GSM, STORE, GObject)
+
+struct _GsmStoreClass
+{
+        GObjectClass   parent_class;
+
+        void          (* added)    (GsmStore   *store,
+                                    const char *id);
+        void          (* removed)  (GsmStore   *store,
+                                    const char *id);
+};
+
+typedef enum
+{
+         GSM_STORE_ERROR_GENERAL
+} GsmStoreError;
+
+#define GSM_STORE_ERROR gsm_store_error_quark ()
+
+typedef gboolean (*GsmStoreFunc) (const char *id,
+                                  GObject    *object,
+                                  gpointer    user_data);
+
+GQuark              gsm_store_error_quark              (void);
+
+GsmStore *          gsm_store_new                      (void);
+
+gboolean            gsm_store_get_locked               (GsmStore    *store);
+void                gsm_store_set_locked               (GsmStore    *store,
+                                                        gboolean     locked);
+
+guint               gsm_store_size                     (GsmStore    *store);
+gboolean            gsm_store_add                      (GsmStore    *store,
+                                                        const char  *id,
+                                                        GObject     *object);
+void                gsm_store_clear                    (GsmStore    *store);
+gboolean            gsm_store_remove                   (GsmStore    *store,
+                                                        const char  *id);
+
+void                gsm_store_foreach                  (GsmStore    *store,
+                                                        GsmStoreFunc func,
+                                                        gpointer     user_data);
+guint               gsm_store_foreach_remove           (GsmStore    *store,
+                                                        GsmStoreFunc func,
+                                                        gpointer     user_data);
+GObject *           gsm_store_find                     (GsmStore    *store,
+                                                        GsmStoreFunc predicate,
+                                                        gpointer     user_data);
+GObject *           gsm_store_lookup                   (GsmStore    *store,
+                                                        const char  *id);
+
+G_END_DECLS
+
+#endif /* __GSM_STORE_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/19.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/19.html new file mode 100644 index 0000000..48aa0bc --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/19.html @@ -0,0 +1,543 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+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);
+
+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__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/2.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/2.html new file mode 100644 index 0000000..9ac540c --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/2.html @@ -0,0 +1,2079 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ * Copyright (C) 2007 Vincent Untz.
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-properties-dialog.h"
+#include "gsm-app-dialog.h"
+#include "msm-desktop-app-dialog.h"
+#include "gsm-util.h"<--- Include file: "gsm-util.h" not found.
+#include "gsp-app.h"
+#include "gsp-app-manager.h"
+
+#define GTKBUILDER_FILE "session-properties.ui"
+
+#define CAPPLET_TREEVIEW_WIDGET_NAME      "session_properties_treeview"
+#define CAPPLET_ADD_WIDGET_NAME           "session_properties_add_button"
+#define CAPPLET_DESKTOP_ADD_WIDGET_NAME   "session_properties_desktop_add_button"
+#define CAPPLET_DELETE_WIDGET_NAME        "session_properties_delete_button"
+#define CAPPLET_EDIT_WIDGET_NAME          "session_properties_edit_button"
+#define CAPPLET_SAVE_WIDGET_NAME          "session_properties_save_button"
+#define CAPPLET_REMEMBER_WIDGET_NAME      "session_properties_remember_toggle"
+#define CAPPLET_SHOW_HIDDEN_WIDGET_NAME   "session_properties_show_hidden_toggle"
+
+#define STARTUP_APP_ICON     "system-run"
+
+#define SPC_CONFIG_SCHEMA   "org.mate.session"
+#define SPC_AUTOSAVE_KEY    "auto-save-session"
+#define SPC_SHOW_HIDDEN_KEY "show-hidden-apps"
+
+struct _GsmPropertiesDialog
+{
+        GtkDialog          parent;
+        GtkBuilder        *xml;
+        GtkListStore      *list_store;
+        GtkTreeModel      *tree_filter;
+
+        GtkTreeView       *treeview;
+        GtkWidget         *add_button;
+        GtkWidget         *desktop_add_button;
+        GtkWidget         *delete_button;
+        GtkWidget         *edit_button;
+
+        GspAppManager     *manager;
+
+        GSettings         *settings;
+};
+
+enum {
+        STORE_COL_ENABLED = 0,
+        STORE_COL_GICON,
+        STORE_COL_DESCRIPTION,
+        STORE_COL_APP,
+        STORE_COL_SEARCH,
+        NUMBER_OF_COLUMNS
+};
+
+static void     gsm_properties_dialog_finalize    (GObject                  *object);
+
+G_DEFINE_TYPE (GsmPropertiesDialog, gsm_properties_dialog, GTK_TYPE_DIALOG)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static gboolean
+find_by_app (GtkTreeModel *model,
+             GtkTreeIter  *iter,
+             GspApp       *app)
+{
+        GspApp *iter_app = NULL;
+
+        if (!gtk_tree_model_get_iter_first (model, iter)) {
+                return FALSE;
+        }
+
+        do {
+                gtk_tree_model_get (model, iter,
+                                    STORE_COL_APP, &iter_app,
+                                    -1);
+
+                if (iter_app == app) {
+                        g_object_unref (iter_app);
+                        return TRUE;
+                }
+
+                g_object_unref (iter_app);
+        } while (gtk_tree_model_iter_next (model, iter));
+
+        return FALSE;
+}
+
+static void
+_fill_iter_from_app (GtkListStore *list_store,
+                     GtkTreeIter  *iter,
+                     GspApp       *app)
+{
+        gboolean    enabled;
+        GIcon      *icon;
+        const char *description;
+        const char *app_name;
+
+        enabled     = !gsp_app_get_hidden (app);
+        icon        = gsp_app_get_icon (app);
+        description = gsp_app_get_description (app);
+        app_name    = gsp_app_get_name (app);
+
+        if (G_IS_THEMED_ICON (icon)) {
+                GtkIconTheme       *theme;
+                const char * const *icon_names;
+
+                theme = gtk_icon_theme_get_default ();
+                icon_names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+                if (icon_names[0] == NULL ||
+                    !gtk_icon_theme_has_icon (theme, icon_names[0])) {
+                        g_object_unref (icon);
+                        icon = NULL;
+                }
+        } else if (G_IS_FILE_ICON (icon)) {
+                GFile *iconfile;
+
+                iconfile = g_file_icon_get_file (G_FILE_ICON (icon));
+                if (!g_file_query_exists (iconfile, NULL)) {
+                        g_object_unref (icon);
+                        icon = NULL;
+                }
+        }
+
+        if (icon == NULL) {
+                icon = g_themed_icon_new (STARTUP_APP_ICON);
+        }
+
+        gtk_list_store_set (list_store, iter,
+                            STORE_COL_ENABLED, enabled,
+                            STORE_COL_GICON, icon,
+                            STORE_COL_DESCRIPTION, description,
+                            STORE_COL_APP, app,
+                            STORE_COL_SEARCH, app_name,
+                            -1);
+        g_object_unref (icon);
+}
+
+static void
+_app_changed (GsmPropertiesDialog *dialog,
+              GspApp              *app)
+{
+        GtkTreeIter iter;
+
+        if (!find_by_app (GTK_TREE_MODEL (dialog->list_store),
+                          &iter, app)) {
+                return;
+        }
+
+        _fill_iter_from_app (dialog->list_store, &iter, app);
+}
+
+static void
+append_app (GsmPropertiesDialog *dialog,
+            GspApp              *app)
+{
+        GtkTreeIter   iter;
+        if (find_by_app (GTK_TREE_MODEL (dialog->list_store),
+                         &iter, app)) {
+                return;
+        }
+
+        gtk_list_store_append (dialog->list_store, &iter);
+        _fill_iter_from_app (dialog->list_store, &iter, app);
+
+        g_signal_connect_swapped (app, "changed",
+                                  G_CALLBACK (_app_changed), dialog);
+}
+
+static void
+_app_added (GsmPropertiesDialog *dialog,
+            GspApp              *app,
+            GspAppManager       *manager)
+{
+        (void) manager;
+        append_app (dialog, app);
+}
+
+static void
+remove_app (GsmPropertiesDialog *dialog,
+            GspApp              *app)
+{
+        GtkTreeIter iter;
+
+        if (!find_by_app (GTK_TREE_MODEL (dialog->list_store),
+                          &iter, app)) {
+                return;
+        }
+
+        g_signal_handlers_disconnect_by_func (app,
+                                              _app_changed,
+                                              dialog);
+        gtk_list_store_remove (dialog->list_store, &iter);
+}
+
+static void
+_app_removed (GsmPropertiesDialog *dialog,
+              GspApp              *app,
+              GspAppManager       *manager)
+{
+        (void) manager;
+        remove_app (dialog, app);
+}
+
+static void
+populate_model (GsmPropertiesDialog *dialog)
+{
+        GSList *apps;
+        GSList *l;
+
+        apps = gsp_app_manager_get_apps (dialog->manager);
+        for (l = apps; l != NULL; l = l->next) {
+                append_app (dialog, GSP_APP (l->data));
+        }
+        g_slist_free (apps);
+}
+
+static void
+on_selection_changed (GtkTreeSelection    *selection,
+                      GsmPropertiesDialog *dialog)
+{
+        gboolean sel;
+
+        sel = gtk_tree_selection_get_selected (selection, NULL, NULL);
+
+        gtk_widget_set_sensitive (dialog->edit_button, sel);
+        gtk_widget_set_sensitive (dialog->delete_button, sel);
+}
+
+static void
+on_startup_enabled_toggled (GtkCellRendererToggle *cell_renderer,
+                            char                  *path,
+                            GsmPropertiesDialog   *dialog)
+{
+        GtkTreeIter iter;
+        GspApp     *app;
+        gboolean    active;
+
+        if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (dialog->tree_filter),
+                                                  &iter, path)) {
+                return;
+        }
+
+        app = NULL;
+        gtk_tree_model_get (GTK_TREE_MODEL (dialog->tree_filter),
+                            &iter,
+                            STORE_COL_APP, &app,
+                            -1);
+
+        active = gtk_cell_renderer_toggle_get_active (cell_renderer);
+
+        if (app) {
+                gsp_app_set_hidden (app, active);
+                g_object_unref (app);
+        }
+}
+
+static void
+on_drag_data_received (GtkWidget           *widget,
+                       GdkDragContext      *drag_context,
+                       gint                 x,
+                       gint                 y,
+                       GtkSelectionData    *data,
+                       guint                info,
+                       guint                time,
+                       GsmPropertiesDialog *dialog)
+{
+        gboolean dnd_success;
+
+        dnd_success = FALSE;
+
+        if (data != NULL) {
+                char **filenames;
+                int    i;
+
+                filenames = gtk_selection_data_get_uris (data);
+
+                for (i = 0; filenames[i] && filenames[i][0]; i++) {
+                        /* Return success if at least one file succeeded */
+                        gboolean file_success;
+                        file_success = gsp_app_copy_desktop_file (filenames[i]);
+                        dnd_success = dnd_success || file_success;
+                }
+
+                g_strfreev (filenames);
+        }
+
+        gtk_drag_finish (drag_context, dnd_success, FALSE, time);
+        g_signal_stop_emission_by_name (widget, "drag_data_received");
+}
+
+static void
+on_drag_begin (GtkWidget           *widget,
+               GdkDragContext      *context,
+               GsmPropertiesDialog *dialog)
+{
+        GtkTreePath *path;
+        GtkTreeIter  iter;
+        GspApp      *app;
+
+        gtk_tree_view_get_cursor (GTK_TREE_VIEW (widget), &path, NULL);
+        gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->tree_filter),
+                                 &iter, path);
+        gtk_tree_path_free (path);
+
+        gtk_tree_model_get (GTK_TREE_MODEL (dialog->tree_filter),
+                            &iter,
+                            STORE_COL_APP, &app,
+                            -1);
+
+        if (app) {
+                g_object_set_data_full (G_OBJECT (context), "gsp-app",
+                                        g_object_ref (app), g_object_unref);
+                g_object_unref (app);
+        }
+
+}
+
+static void
+on_drag_data_get (GtkWidget           *widget,
+                  GdkDragContext      *context,
+                  GtkSelectionData    *selection_data,
+                  guint                info,
+                  guint                time,
+                  GsmPropertiesDialog *dialog)
+{
+        GspApp *app;
+
+        app = g_object_get_data (G_OBJECT (context), "gsp-app");
+        if (app) {
+                const char *uris[2];
+                char       *uri;
+
+                uri = g_filename_to_uri (gsp_app_get_path (app), NULL, NULL);
+
+                uris[0] = uri;
+                uris[1] = NULL;
+                gtk_selection_data_set_uris (selection_data, (char **) uris);
+
+                g_free (uri);
+        }
+}
+
+static void
+on_add_app_clicked (GtkWidget           *widget,
+                    GsmPropertiesDialog *dialog)
+{
+        GtkWidget  *add_dialog;
+        char       *name;
+        char       *exec;
+        char       *comment;
+        guint       delay;
+
+        add_dialog = gsm_app_dialog_new (NULL, NULL, NULL, 0);
+        gtk_window_set_transient_for (GTK_WINDOW (add_dialog),
+                                      GTK_WINDOW (dialog));
+
+        if (gsm_app_dialog_run (GSM_APP_DIALOG (add_dialog),
+                                &name, &exec, &comment, &delay)) {
+                gsp_app_create (name, comment, exec, delay);
+                g_free (name);
+                g_free (exec);
+                g_free (comment);
+        }
+}
+
+static void
+on_desktop_add_app_clicked (GtkWidget           *widget,
+                            GsmPropertiesDialog *dialog)
+{
+    GtkWidget  *desktop_add_dialog;
+    gint        response;
+    const char *filename;
+
+    desktop_add_dialog = msm_desktop_app_dialog_new (dialog->manager);
+    gtk_window_set_transient_for (GTK_WINDOW (desktop_add_dialog),
+                                  GTK_WINDOW (dialog));
+
+    gtk_widget_show_all (desktop_add_dialog);
+    response = gtk_dialog_run (GTK_DIALOG (desktop_add_dialog));
+
+    if (response == GTK_RESPONSE_OK)
+    {
+        filename = msm_dektop_app_dialog_get_selected (MSM_DESKTOP_APP_DIALOG (desktop_add_dialog));
+        if (filename != NULL)
+        {
+            gsp_app_copy_desktop_file (g_filename_to_uri (filename, NULL, NULL));
+        }
+    }
+
+    gtk_widget_destroy (desktop_add_dialog);
+}
+
+static void
+on_delete_app_clicked (GtkWidget           *widget,
+                       GsmPropertiesDialog *dialog)
+{
+        GtkTreeSelection *selection;
+        GtkTreeIter       iter;
+        GspApp           *app;
+
+        selection = gtk_tree_view_get_selection (dialog->treeview);
+
+        if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+                return;
+        }
+
+        app = NULL;
+        gtk_tree_model_get (GTK_TREE_MODEL (dialog->tree_filter),
+                            &iter,
+                            STORE_COL_APP, &app,
+                            -1);
+
+        if (app) {
+                gsp_app_delete (app);
+                g_object_unref (app);
+        }
+}
+
+static void
+on_edit_app_clicked (GtkWidget           *widget,
+                     GsmPropertiesDialog *dialog)
+{
+        GtkTreeSelection *selection;
+        GtkTreeIter       iter;
+        GspApp           *app;
+
+        selection = gtk_tree_view_get_selection (dialog->treeview);
+
+        if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
+                return;
+        }
+
+        app = NULL;
+        gtk_tree_model_get (GTK_TREE_MODEL (dialog->tree_filter),
+                            &iter,
+                            STORE_COL_APP, &app,
+                            -1);
+
+        if (app) {
+                GtkWidget  *edit_dialog;
+                char       *name;
+                char       *exec;
+                char       *comment;
+                guint       delay;
+
+                edit_dialog = gsm_app_dialog_new (gsp_app_get_name (app),
+                                                  gsp_app_get_exec (app),
+                                                  gsp_app_get_comment (app),
+                                                  gsp_app_get_delay (app));
+                gtk_window_set_transient_for (GTK_WINDOW (edit_dialog),
+                                              GTK_WINDOW (dialog));
+
+                if (gsm_app_dialog_run (GSM_APP_DIALOG (edit_dialog),
+                                        &name, &exec, &comment, &delay)) {
+                        gsp_app_update (app, name, comment, exec, delay);
+                        g_free (name);
+                        g_free (exec);
+                        g_free (comment);
+                }
+
+                g_object_unref (app);
+        }
+}
+
+static void
+on_row_activated (GtkTreeView         *tree_view,
+                  GtkTreePath         *path,
+                  GtkTreeViewColumn   *column,
+                  GsmPropertiesDialog *dialog)
+{
+        on_edit_app_clicked (NULL, dialog);
+}
+
+static void
+on_show_hidden_toggled (GtkToggleButton     *togglebutton,
+                        GsmPropertiesDialog *dialog)
+{
+        (void) togglebutton;
+        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->tree_filter));
+}
+
+static void
+on_save_session_clicked (GtkWidget           *widget,
+                         GsmPropertiesDialog *dialog)
+{
+        g_debug ("Session saving is not implemented yet!");
+}
+
+static gboolean
+on_main_notebook_scroll_event (GtkWidget        *widget,
+                               GdkEventScroll   *event)
+{
+        GtkNotebook *notebook = GTK_NOTEBOOK (widget);
+        GtkWidget *child, *event_widget, *action_widget;
+
+        child = gtk_notebook_get_nth_page (notebook, gtk_notebook_get_current_page (notebook));
+        if (child == NULL)
+                return FALSE;
+
+        event_widget = gtk_get_event_widget ((GdkEvent*) event);
+
+        /* Ignore scroll events from the content of the page */
+        if (event_widget == NULL || event_widget == child || gtk_widget_is_ancestor (event_widget, child))
+                return FALSE;
+
+        /* And also from the action widgets */
+        action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_START);
+        if (event_widget == action_widget || (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
+                return FALSE;
+
+        action_widget = gtk_notebook_get_action_widget (notebook, GTK_PACK_END);
+        if (event_widget == action_widget || (action_widget != NULL && gtk_widget_is_ancestor (event_widget, action_widget)))
+                return FALSE;
+
+        switch (event->direction) {
+                case GDK_SCROLL_RIGHT:
+                case GDK_SCROLL_DOWN:
+                        gtk_notebook_next_page (notebook);
+                        break;
+                case GDK_SCROLL_LEFT:
+                case GDK_SCROLL_UP:
+                        gtk_notebook_prev_page (notebook);
+                        break;
+                case GDK_SCROLL_SMOOTH:
+                        switch (gtk_notebook_get_tab_pos (notebook)) {
+                                case GTK_POS_LEFT:
+                                case GTK_POS_RIGHT:
+                                        if (event->delta_y > 0)
+                                                gtk_notebook_next_page (notebook);
+                                        else if (event->delta_y < 0)
+                                                gtk_notebook_prev_page (notebook);
+                                        break;
+                                case GTK_POS_TOP:
+                                case GTK_POS_BOTTOM:
+                                        if (event->delta_x > 0)
+                                                gtk_notebook_next_page (notebook);
+                                        else if (event->delta_x < 0)
+                                                gtk_notebook_prev_page (notebook);
+                                        break;
+                        }
+                        break;
+        }
+
+        return TRUE;
+}
+
+static gboolean
+visible_func (GtkTreeModel *model,
+              GtkTreeIter  *iter,
+              gpointer      data)
+{
+        gboolean           visible = FALSE;
+        GtkToggleButton   *toggle_button = data;;
+        GspApp            *app;
+        gboolean           show_hidden;
+
+        show_hidden = gtk_toggle_button_get_active (toggle_button);
+
+        gtk_tree_model_get (model, iter,
+                            STORE_COL_APP, &app,
+                            -1);
+
+        if (app) {
+                gboolean nodisplay;
+
+                nodisplay = gsp_app_get_nodisplay (app);
+                visible = show_hidden || !nodisplay;
+                g_object_unref (app);
+        } else {
+                visible = show_hidden;
+        }
+
+        return visible;
+}
+
+static void
+setup_dialog (GsmPropertiesDialog *dialog)
+{
+        GtkTreeView       *treeview;
+        GtkWidget         *button;
+        GtkToggleButton   *toggle_button;
+        GtkTreeModel      *tree_filter;
+        GtkTreeViewColumn *column;
+        GtkCellRenderer   *renderer;
+        GtkTreeSelection  *selection;
+        GtkTargetList     *targetlist;
+
+        gsm_util_dialog_add_button (GTK_DIALOG (dialog),
+                                    _("_Help"), "help-browser",
+                                    GTK_RESPONSE_HELP);
+
+        gsm_util_dialog_add_button (GTK_DIALOG (dialog),
+                                    _("_Close"), "window-close",
+                                    GTK_RESPONSE_CLOSE);
+
+        dialog->settings = g_settings_new (SPC_CONFIG_SCHEMA);
+
+        toggle_button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (dialog->xml,
+                                                                   CAPPLET_SHOW_HIDDEN_WIDGET_NAME));
+
+        g_settings_bind (dialog->settings, SPC_SHOW_HIDDEN_KEY,
+                         toggle_button, "active", G_SETTINGS_BIND_DEFAULT);
+
+        g_signal_connect (toggle_button, "toggled",
+                          G_CALLBACK (on_show_hidden_toggled),
+                          dialog);
+
+        dialog->list_store = gtk_list_store_new (NUMBER_OF_COLUMNS,
+                                                 G_TYPE_BOOLEAN,
+                                                 G_TYPE_ICON,
+                                                 G_TYPE_STRING,
+                                                 G_TYPE_OBJECT,
+                                                 G_TYPE_STRING);
+        tree_filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (dialog->list_store),
+                                                 NULL);
+        g_object_unref (dialog->list_store);
+        dialog->tree_filter = tree_filter;
+
+        gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (tree_filter), visible_func, toggle_button, NULL);
+
+        treeview = GTK_TREE_VIEW (gtk_builder_get_object (dialog->xml,
+                                                          CAPPLET_TREEVIEW_WIDGET_NAME));
+        dialog->treeview = treeview;
+
+        gtk_tree_view_set_model (treeview, tree_filter);
+        g_object_unref (tree_filter);
+
+        gtk_tree_view_set_headers_visible (treeview, FALSE);
+        g_signal_connect (treeview,
+                          "row-activated",
+                          G_CALLBACK (on_row_activated),
+                          dialog);
+
+        selection = gtk_tree_view_get_selection (treeview);
+        gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+        g_signal_connect (selection,
+                          "changed",
+                          G_CALLBACK (on_selection_changed),
+                          dialog);
+
+        /* CHECKBOX COLUMN */
+        renderer = gtk_cell_renderer_toggle_new ();
+        column = gtk_tree_view_column_new_with_attributes (_("Enabled"),
+                                                           renderer,
+                                                           "active", STORE_COL_ENABLED,
+                                                           NULL);
+        gtk_tree_view_append_column (treeview, column);
+        g_signal_connect (renderer,
+                          "toggled",
+                          G_CALLBACK (on_startup_enabled_toggled),
+                          dialog);
+
+        /* ICON COLUMN */
+        renderer = gtk_cell_renderer_pixbuf_new ();
+        column = gtk_tree_view_column_new_with_attributes (_("Icon"),
+                                                           renderer,
+                                                           "gicon", STORE_COL_GICON,
+                                                           "sensitive", STORE_COL_ENABLED,
+                                                           NULL);
+        g_object_set (renderer,
+                      "stock-size", GSM_PROPERTIES_ICON_SIZE,
+                      NULL);
+        gtk_tree_view_append_column (treeview, column);
+
+        /* NAME COLUMN */
+        renderer = gtk_cell_renderer_text_new ();
+        column = gtk_tree_view_column_new_with_attributes (_("Program"),
+                                                           renderer,
+                                                           "markup", STORE_COL_DESCRIPTION,
+                                                           "sensitive", STORE_COL_ENABLED,
+                                                           NULL);
+        g_object_set (renderer,
+                      "ellipsize", PANGO_ELLIPSIZE_END,
+                      NULL);
+        gtk_tree_view_append_column (treeview, column);
+
+        gtk_tree_view_column_set_sort_column_id (column, STORE_COL_DESCRIPTION);
+        gtk_tree_view_set_search_column (treeview, STORE_COL_SEARCH);
+
+        gtk_tree_view_enable_model_drag_source (treeview,
+                                                GDK_BUTTON1_MASK|GDK_BUTTON2_MASK,
+                                                NULL, 0,
+                                                GDK_ACTION_COPY);
+        gtk_drag_source_add_uri_targets (GTK_WIDGET (treeview));
+
+        gtk_drag_dest_set (GTK_WIDGET (treeview),
+                           GTK_DEST_DEFAULT_ALL,
+                           NULL, 0,
+                           GDK_ACTION_COPY);
+        gtk_drag_dest_add_uri_targets (GTK_WIDGET (treeview));
+
+        /* we don't want to accept drags coming from this widget */
+        targetlist = gtk_drag_dest_get_target_list (GTK_WIDGET (treeview));
+        if (targetlist != NULL) {
+                GtkTargetEntry *targets;
+                gint n_targets;
+                gint i;
+                targets = gtk_target_table_new_from_list (targetlist, &n_targets);
+                for (i = 0; i < n_targets; i++)
+                        targets[i].flags = GTK_TARGET_OTHER_WIDGET;
+                targetlist = gtk_target_list_new (targets, n_targets);
+                gtk_drag_dest_set_target_list (GTK_WIDGET (treeview), targetlist);
+                gtk_target_list_unref (targetlist);
+                gtk_target_table_free (targets, n_targets);
+        }
+
+        g_signal_connect (treeview, "drag_begin",
+                          G_CALLBACK (on_drag_begin),
+                          dialog);
+        g_signal_connect (treeview, "drag_data_get",
+                          G_CALLBACK (on_drag_data_get),
+                          dialog);
+        g_signal_connect (treeview, "drag_data_received",
+                          G_CALLBACK (on_drag_data_received),
+                          dialog);
+
+        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->list_store),
+                                              STORE_COL_DESCRIPTION,
+                                              GTK_SORT_ASCENDING);
+
+        button = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     CAPPLET_ADD_WIDGET_NAME));
+        dialog->add_button = button;
+        g_signal_connect (button,
+                          "clicked",
+                          G_CALLBACK (on_add_app_clicked),
+                          dialog);
+
+        button = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     CAPPLET_DESKTOP_ADD_WIDGET_NAME));
+        dialog->desktop_add_button = button;
+        g_signal_connect (button,
+                          "clicked",
+                          G_CALLBACK (on_desktop_add_app_clicked),
+                          dialog);
+
+        button = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     CAPPLET_DELETE_WIDGET_NAME));
+        dialog->delete_button = button;
+        g_signal_connect (button,
+                          "clicked",
+                          G_CALLBACK (on_delete_app_clicked),
+                          dialog);
+
+        button = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     CAPPLET_EDIT_WIDGET_NAME));
+        dialog->edit_button = button;
+        g_signal_connect (button,
+                          "clicked",
+                          G_CALLBACK (on_edit_app_clicked),
+                          dialog);
+
+        button = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     CAPPLET_REMEMBER_WIDGET_NAME));
+
+        g_settings_bind (dialog->settings, SPC_AUTOSAVE_KEY,
+                         button, "active", G_SETTINGS_BIND_DEFAULT);
+
+        button = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     CAPPLET_SAVE_WIDGET_NAME));
+        g_signal_connect (button,
+                          "clicked",
+                          G_CALLBACK (on_save_session_clicked),
+                          dialog);
+
+        dialog->manager = gsp_app_manager_get ();
+        gsp_app_manager_fill (dialog->manager);
+        g_signal_connect_swapped (dialog->manager, "added",
+                                  G_CALLBACK (_app_added), dialog);
+        g_signal_connect_swapped (dialog->manager, "removed",
+                                  G_CALLBACK (_app_removed), dialog);
+
+        populate_model (dialog);
+        gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (dialog->tree_filter));
+}
+
+static GObject *
+gsm_properties_dialog_constructor (GType                  type,
+                                guint                  n_construct_properties,
+                                GObjectConstructParam *construct_properties)
+{
+        GsmPropertiesDialog *dialog;
+
+        dialog = GSM_PROPERTIES_DIALOG (G_OBJECT_CLASS (gsm_properties_dialog_parent_class)->constructor (type,
+                                                                                                          n_construct_properties,
+                                                                                                          construct_properties));
+
+        setup_dialog (dialog);
+
+        return G_OBJECT (dialog);
+}
+
+static void
+gsm_properties_dialog_dispose (GObject *object)
+{
+        GsmPropertiesDialog *dialog;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_PROPERTIES_DIALOG (object));
+
+        dialog = GSM_PROPERTIES_DIALOG (object);
+
+        if (dialog->xml != NULL) {
+                g_object_unref (dialog->xml);
+                dialog->xml = NULL;
+        }
+
+        if (dialog->settings != NULL) {
+                g_object_unref (dialog->settings);
+                dialog->settings = NULL;
+        }
+
+        G_OBJECT_CLASS (gsm_properties_dialog_parent_class)->dispose (object);
+
+        /* it's important to do this after chaining to the parent dispose
+         * method because we want to make sure the treeview has been disposed
+         * and removed all its references to GspApp objects */
+        if (dialog->manager != NULL) {
+                g_object_unref (dialog->manager);
+                dialog->manager = NULL;
+        }
+}
+
+static void
+gsm_properties_dialog_class_init (GsmPropertiesDialogClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->constructor = gsm_properties_dialog_constructor;
+        object_class->dispose = gsm_properties_dialog_dispose;
+        object_class->finalize = gsm_properties_dialog_finalize;
+}
+
+static void
+gsm_properties_dialog_init (GsmPropertiesDialog *dialog)
+{
+        GtkWidget   *content_area;
+        GtkWidget   *widget;
+        GError      *error;
+
+        dialog->xml = gtk_builder_new ();
+        gtk_builder_set_translation_domain (dialog->xml, GETTEXT_PACKAGE);
+
+        error = NULL;
+        if (!gtk_builder_add_from_file (dialog->xml,
+                                        GTKBUILDER_DIR "/" GTKBUILDER_FILE,
+                                        &error)) {
+                if (error) {
+                        g_warning ("Could not load capplet UI file: %s",
+                                   error->message);
+                        g_error_free (error);
+                } else {
+                        g_warning ("Could not load capplet UI file.");
+                }
+        }
+
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+        widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     "main-notebook"));
+
+        gtk_widget_add_events (widget, GDK_SCROLL_MASK);
+        g_signal_connect (widget,
+                          "scroll-event",
+                          G_CALLBACK (on_main_notebook_scroll_event),
+                          NULL);
+
+        gtk_box_pack_start (GTK_BOX (content_area), widget, TRUE, TRUE, 0);
+
+        gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+        gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+        gtk_box_set_spacing (GTK_BOX (content_area), 2);
+        gtk_window_set_icon_name (GTK_WINDOW (dialog), "mate-session-properties");
+        gtk_window_set_title (GTK_WINDOW (dialog), _("Startup Applications Preferences"));
+}
+
+static void
+gsm_properties_dialog_finalize (GObject *object)
+{
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_PROPERTIES_DIALOG (object));
+
+        G_OBJECT_CLASS (gsm_properties_dialog_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_properties_dialog_new (void)
+{
+        GObject *object;
+
+        object = g_object_new (GSM_TYPE_PROPERTIES_DIALOG,
+                               NULL);
+
+        return GTK_WIDGET (object);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/20.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/20.html new file mode 100644 index 0000000..3f61cf7 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/20.html @@ -0,0 +1,469 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_app_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                         GValue       *return_value,
+                                                         guint         n_param_values,
+                                                         const GValue *param_values,
+                                                         gpointer      invocation_hint,
+                                                         gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_app_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                    GValue       *return_value,
+                                                    guint         n_param_values,
+                                                    const GValue *param_values,
+                                                    gpointer      invocation_hint G_GNUC_UNUSED,
+                                                    gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+                                                             gpointer arg1,
+                                                             gpointer arg2,
+                                                             gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gsm_app_methods[] = {
+  { (GCallback) gsm_app_get_app_id, dbus_glib_marshal_gsm_app_BOOLEAN__POINTER_POINTER, 0 },
+  { (GCallback) gsm_app_get_startup_id, dbus_glib_marshal_gsm_app_BOOLEAN__POINTER_POINTER, 56 },
+  { (GCallback) gsm_app_get_phase, dbus_glib_marshal_gsm_app_BOOLEAN__POINTER_POINTER, 120 },
+};
+
+const DBusGObjectInfo dbus_glib_gsm_app_object_info = {  1,
+  dbus_glib_gsm_app_methods,
+  3,
+"org.gnome.SessionManager.App\0GetAppId\0S\0app_id\0O\0F\0N\0s\0\0org.gnome.SessionManager.App\0GetStartupId\0S\0startup_id\0O\0F\0N\0s\0\0org.gnome.SessionManager.App\0GetPhase\0S\0phase\0O\0F\0N\0u\0\0\0",
+"\0",
+"\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/21.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/21.html new file mode 100644 index 0000000..fcc218a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/21.html @@ -0,0 +1,2717 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+/* Needed for FreeBSD */
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-autostart-app.h"
+#include "gsm-util.h"
+
+#ifdef __GNUC__
+#define UNUSED_VARIABLE __attribute__ ((unused))
+#else
+#define UNUSED_VARIABLE
+#endif
+
+enum {
+        AUTOSTART_LAUNCH_SPAWN = 0,
+        AUTOSTART_LAUNCH_ACTIVATE
+};
+
+enum {
+        GSM_CONDITION_NONE          = 0,
+        GSM_CONDITION_IF_EXISTS     = 1,
+        GSM_CONDITION_UNLESS_EXISTS = 2,
+        GSM_CONDITION_MATE          = 3,
+        GSM_CONDITION_GSETTINGS     = 4,
+        GSM_CONDITION_UNKNOWN       = 5
+};
+
+#define GSM_SESSION_CLIENT_DBUS_INTERFACE "org.mate.SessionClient"
+
+typedef struct {
+        char                 *desktop_filename;
+        char                 *desktop_id;
+        char                 *startup_id;
+
+        EggDesktopFile       *desktop_file;
+
+        /* desktop file state */
+        char                 *condition_string;
+        gboolean              condition;
+        gboolean              autorestart;
+        int                   autostart_delay;
+
+        GFileMonitor         *condition_monitor;
+        GSettings            *condition_settings;
+
+        int                   launch_type;
+        GPid                  pid;
+        guint                 child_watch_id;
+
+        GDBusConnection      *connection;
+        GDBusProxy           *proxy;
+} GsmAutostartAppPrivate;
+
+enum {
+        CONDITION_CHANGED,
+        LAST_SIGNAL
+};
+
+enum {
+        PROP_0,
+        PROP_DESKTOP_FILENAME
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmAutostartApp, gsm_autostart_app, GSM_TYPE_APP)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void
+gsm_autostart_app_init (GsmAutostartApp *app)
+{
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        priv->pid = -1;
+        priv->condition_monitor = NULL;
+        priv->condition = FALSE;
+        priv->autostart_delay = -1;
+}
+
+static gboolean
+is_disabled (GsmApp *app)
+{
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        /* Hidden key, used by autostart spec */
+        if (egg_desktop_file_get_boolean (priv->desktop_file,
+                                          EGG_DESKTOP_FILE_KEY_HIDDEN, NULL)) {
+                g_debug ("app %s is disabled by Hidden",
+                         gsm_app_peek_id (app));
+                return TRUE;
+        }
+
+        /* Check OnlyShowIn/NotShowIn/TryExec */
+        if (!egg_desktop_file_can_launch (priv->desktop_file, "MATE")) {
+                g_debug ("app %s not installed or not for MATE",
+                         gsm_app_peek_id (app));
+                return TRUE;
+        }
+
+        /* Do not check AutostartCondition - this method is only to determine
+         if the app is unconditionally disabled */
+
+        return FALSE;
+}
+
+static gboolean
+parse_condition_string (const char *condition_string,
+                        guint      *condition_kindp,
+                        char      **keyp)
+{
+        const char *space;
+        const char *key;
+        int         len;
+        guint       kind;
+
+        space = condition_string + strcspn (condition_string, " ");
+        len = space - condition_string;
+        key = space;
+        while (isspace ((unsigned char)*key)) {
+                key++;
+        }
+
+        if (!g_ascii_strncasecmp (condition_string, "if-exists", len) && key) {
+                kind = GSM_CONDITION_IF_EXISTS;
+        } else if (!g_ascii_strncasecmp (condition_string, "unless-exists", len) && key) {
+                kind = GSM_CONDITION_UNLESS_EXISTS;
+        } else if (!g_ascii_strncasecmp (condition_string, "MATE", len)) {
+                kind = GSM_CONDITION_MATE;
+        } else if (!g_ascii_strncasecmp (condition_string, "GSettings", len)) {
+                kind = GSM_CONDITION_GSETTINGS;
+        } else {
+                key = NULL;
+                kind = GSM_CONDITION_UNKNOWN;
+        }
+
+        if (keyp != NULL) {
+                *keyp = g_strdup (key);
+        }
+
+        if (condition_kindp != NULL) {
+                *condition_kindp = kind;
+        }
+
+        return (kind != GSM_CONDITION_UNKNOWN);
+}
+
+static void
+if_exists_condition_cb (GFileMonitor     *monitor,
+                        GFile            *file,
+                        GFile            *other_file,
+                        GFileMonitorEvent event,
+                        GsmApp           *app)
+{
+        GsmAutostartAppPrivate *priv;
+        gboolean                condition = FALSE;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        switch (event) {
+        case G_FILE_MONITOR_EVENT_CREATED:
+                condition = TRUE;
+                break;
+        case G_FILE_MONITOR_EVENT_DELETED:
+                condition = FALSE;
+                break;
+        default:
+                /* Ignore any other monitor event */
+                return;
+        }
+
+        /* Emit only if the condition actually changed */
+        if (condition != priv->condition) {
+                priv->condition = condition;
+                g_signal_emit (app, signals[CONDITION_CHANGED], 0, condition);
+        }
+}
+
+static void
+unless_exists_condition_cb (GFileMonitor     *monitor,
+                            GFile            *file,
+                            GFile            *other_file,
+                            GFileMonitorEvent event,
+                            GsmApp           *app)
+{
+        GsmAutostartAppPrivate *priv;
+        gboolean                condition = FALSE;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        switch (event) {
+        case G_FILE_MONITOR_EVENT_CREATED:
+                condition = FALSE;
+                break;
+        case G_FILE_MONITOR_EVENT_DELETED:
+                condition = TRUE;
+                break;
+        default:
+                /* Ignore any other monitor event */
+                return;
+        }
+
+        /* Emit only if the condition actually changed */
+        if (condition != priv->condition) {
+                priv->condition = condition;
+                g_signal_emit (app, signals[CONDITION_CHANGED], 0, condition);
+        }
+}
+
+static void
+gsettings_condition_cb (GSettings  *settings,
+                        const char *key,
+                        gpointer    user_data)
+{
+        GsmApp                 *app;
+        GsmAutostartAppPrivate *priv;
+        gboolean                condition;
+
+        g_return_if_fail (GSM_IS_APP (user_data));
+
+        app = GSM_APP (user_data);
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        condition = g_settings_get_boolean (settings, key);
+
+        g_debug ("GsmAutostartApp: app:%s condition changed condition:%d",
+                 gsm_app_peek_id (app),
+                 condition);
+
+        /* Emit only if the condition actually changed */
+        if (condition != priv->condition) {
+                priv->condition = condition;
+                g_signal_emit (app, signals[CONDITION_CHANGED], 0, condition);
+        }
+}
+
+static gboolean
+setup_gsettings_condition_monitor (GsmAutostartApp *app,
+                                   const char      *key)
+{
+        GSettingsSchemaSource *source;
+        GSettingsSchema *schema;
+        GSettings *settings;
+        char **elems;
+        gboolean retval = FALSE;
+        char *signal;
+        GsmAutostartAppPrivate *priv;
+
+        elems = g_strsplit (key, " ", 2);
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        if (elems == NULL)
+                goto out;
+
+        if (elems[0] == NULL || elems[1] == NULL)
+	        goto out;
+
+        source = g_settings_schema_source_get_default ();
+
+        schema = g_settings_schema_source_lookup (source, elems[0], TRUE);
+
+        if (schema == NULL)
+                goto out;
+
+        settings = g_settings_new_full (schema, NULL, NULL);
+        g_settings_schema_unref (schema);
+
+        signal = g_strdup_printf ("changed::%s", elems[1]);
+        g_signal_connect (G_OBJECT (settings), signal,
+                          G_CALLBACK (gsettings_condition_cb), app);
+        g_free (signal);
+
+        retval = g_settings_get_boolean (settings, elems[1]);
+
+        priv->condition_settings = settings;
+
+out:
+        g_strfreev (elems);
+
+        return retval;
+}
+
+static void
+setup_condition_monitor (GsmAutostartApp *app)
+{
+        guint    kind;
+        char    *key;
+        gboolean res;
+        gboolean UNUSED_VARIABLE disabled;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        if (priv->condition_monitor != NULL) {
+                g_file_monitor_cancel (priv->condition_monitor);
+        }
+
+        if (priv->condition_settings != NULL) {
+                g_object_unref (priv->condition_settings);
+                priv->condition_settings = NULL;
+        }
+
+        if (priv->condition_string == NULL) {
+                return;
+        }
+
+        /* if it is disabled outright there is no point in monitoring */
+        if (is_disabled (GSM_APP (app))) {
+                return;
+        }
+
+        key = NULL;
+        res = parse_condition_string (priv->condition_string, &kind, &key);
+        if (! res) {
+                g_free (key);
+                return;
+        }
+
+        if (key == NULL) {
+                return;
+        }
+
+        if (kind == GSM_CONDITION_IF_EXISTS) {
+                char  *file_path;
+                GFile *file;
+
+                file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
+
+                disabled = !g_file_test (file_path, G_FILE_TEST_EXISTS);
+
+                file = g_file_new_for_path (file_path);
+                priv->condition_monitor = g_file_monitor_file (file, 0, NULL, NULL);
+
+                g_signal_connect (priv->condition_monitor, "changed",
+                                  G_CALLBACK (if_exists_condition_cb),
+                                  app);
+
+                g_object_unref (file);
+                g_free (file_path);
+        } else if (kind == GSM_CONDITION_UNLESS_EXISTS) {
+                char  *file_path;
+                GFile *file;
+
+                file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
+
+                disabled = g_file_test (file_path, G_FILE_TEST_EXISTS);
+
+                file = g_file_new_for_path (file_path);
+                priv->condition_monitor = g_file_monitor_file (file, 0, NULL, NULL);
+
+                g_signal_connect (priv->condition_monitor, "changed",
+                                  G_CALLBACK (unless_exists_condition_cb),
+                                  app);
+
+                g_object_unref (file);
+                g_free (file_path);
+        } else if (kind == GSM_CONDITION_MATE) {
+                disabled = !setup_gsettings_condition_monitor (app, key);
+        } else if (kind == GSM_CONDITION_GSETTINGS) {
+                disabled = !setup_gsettings_condition_monitor (app, key);
+        } else {
+                disabled = TRUE;
+        }
+
+        g_free (key);
+
+        /* FIXME: cache the disabled value? */
+}
+
+static gboolean
+load_desktop_file (GsmAutostartApp *app)
+{
+        char    *dbus_name;
+        char    *startup_id;
+        char    *phase_str;
+        int      phase;
+        gboolean res;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        if (priv->desktop_file == NULL) {
+                return FALSE;
+        }
+
+        phase_str = egg_desktop_file_get_string (priv->desktop_file,
+                                                 GSM_AUTOSTART_APP_PHASE_KEY,
+                                                 NULL);
+        if (phase_str != NULL) {
+                if (strcmp (phase_str, "Initialization") == 0) {
+                        phase = GSM_MANAGER_PHASE_INITIALIZATION;
+                } else if (strcmp (phase_str, "WindowManager") == 0) {
+                        phase = GSM_MANAGER_PHASE_WINDOW_MANAGER;
+                } else if (strcmp (phase_str, "Panel") == 0) {
+                        phase = GSM_MANAGER_PHASE_PANEL;
+                } else if (strcmp (phase_str, "Desktop") == 0) {
+                        phase = GSM_MANAGER_PHASE_DESKTOP;
+                } else {
+                        phase = GSM_MANAGER_PHASE_APPLICATION;
+                }
+
+                g_free (phase_str);
+        } else {
+                phase = GSM_MANAGER_PHASE_APPLICATION;
+        }
+
+        dbus_name = egg_desktop_file_get_string (priv->desktop_file,
+                                                 GSM_AUTOSTART_APP_DBUS_NAME_KEY,
+                                                 NULL);
+        if (dbus_name != NULL) {
+                priv->launch_type = AUTOSTART_LAUNCH_ACTIVATE;
+        } else {
+                priv->launch_type = AUTOSTART_LAUNCH_SPAWN;
+        }
+
+        /* this must only be done on first load */
+        switch (priv->launch_type) {
+        case AUTOSTART_LAUNCH_SPAWN:
+                startup_id =
+                        egg_desktop_file_get_string (priv->desktop_file,
+                                                     GSM_AUTOSTART_APP_STARTUP_ID_KEY,
+                                                     NULL);
+
+                if (startup_id == NULL) {
+                        startup_id = gsm_util_generate_startup_id ();
+                }
+                break;
+        case AUTOSTART_LAUNCH_ACTIVATE:
+                startup_id = g_strdup (dbus_name);
+                break;
+        default:
+                g_assert_not_reached ();
+        }
+
+        res = egg_desktop_file_has_key (priv->desktop_file,
+                                        GSM_AUTOSTART_APP_AUTORESTART_KEY,
+                                        NULL);
+        if (res) {
+                priv->autorestart = egg_desktop_file_get_boolean (priv->desktop_file,
+                                                                  GSM_AUTOSTART_APP_AUTORESTART_KEY,
+                                                                  NULL);
+        } else {
+                priv->autorestart = FALSE;
+        }
+
+        g_free (priv->condition_string);
+        priv->condition_string = egg_desktop_file_get_string (priv->desktop_file,
+                                                              "AutostartCondition",
+                                                              NULL);
+        setup_condition_monitor (app);
+
+        if (phase == GSM_MANAGER_PHASE_APPLICATION) {
+                /* Only accept an autostart delay for the application phase */
+                priv->autostart_delay = egg_desktop_file_get_integer (priv->desktop_file,
+                                                                      GSM_AUTOSTART_APP_DELAY_KEY,
+                                                                      NULL);
+                if (priv->autostart_delay < 0) {
+                        g_warning ("Invalid autostart delay of %d for %s", priv->autostart_delay,
+                                   gsm_app_peek_id (GSM_APP (app)));
+                        priv->autostart_delay = -1;
+                }
+        }
+
+        g_object_set (app,
+                      "phase", phase,
+                      "startup-id", startup_id,
+                      NULL);
+
+        g_free (startup_id);
+        g_free (dbus_name);
+
+        return TRUE;
+}
+
+static void
+gsm_autostart_app_set_desktop_filename (GsmAutostartApp *app,
+                                        const char      *desktop_filename)
+{
+        GError *error;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        if (priv->desktop_file != NULL) {
+                egg_desktop_file_free (priv->desktop_file);
+                priv->desktop_file = NULL;
+                g_free (priv->desktop_id);
+        }
+
+        if (desktop_filename == NULL) {
+                return;
+        }
+
+        priv->desktop_id = g_path_get_basename (desktop_filename);
+
+        error = NULL;
+        priv->desktop_file = egg_desktop_file_new (desktop_filename, &error);
+        if (priv->desktop_file == NULL) {
+                g_warning ("Could not parse desktop file %s: %s",
+                           desktop_filename,
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+}
+
+static void
+gsm_autostart_app_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+        GsmAutostartApp *self;
+
+        self = GSM_AUTOSTART_APP (object);
+
+        switch (prop_id) {
+        case PROP_DESKTOP_FILENAME:
+                gsm_autostart_app_set_desktop_filename (self, g_value_get_string (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_autostart_app_get_property (GObject    *object,
+                                guint       prop_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
+{
+        GsmAutostartApp *self;
+        GsmAutostartAppPrivate *priv;
+
+        self = GSM_AUTOSTART_APP (object);
+        priv = gsm_autostart_app_get_instance_private (self);
+
+        switch (prop_id) {
+        case PROP_DESKTOP_FILENAME:
+                if (priv->desktop_file != NULL) {
+                        g_value_set_string (value, egg_desktop_file_get_source (priv->desktop_file));
+                } else {
+                        g_value_set_string (value, NULL);
+                }
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_autostart_app_dispose (GObject *object)
+{
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(object));
+
+        if (priv->startup_id) {
+                g_free (priv->startup_id);
+                priv->startup_id = NULL;
+        }
+
+        if (priv->condition_string) {
+                g_free (priv->condition_string);
+                priv->condition_string = NULL;
+        }
+
+        if (priv->condition_settings) {
+                g_object_unref (priv->condition_settings);
+                priv->condition_settings = NULL;
+        }
+
+        if (priv->desktop_file) {
+                egg_desktop_file_free (priv->desktop_file);
+                priv->desktop_file = NULL;
+        }
+
+        if (priv->desktop_id) {
+                g_free (priv->desktop_id);
+                priv->desktop_id = NULL;
+        }
+
+        if (priv->child_watch_id > 0) {
+                g_source_remove (priv->child_watch_id);
+                priv->child_watch_id = 0;
+        }
+
+        if (priv->proxy != NULL) {
+                g_object_unref (priv->proxy);
+                priv->proxy = NULL;
+        }
+
+        if (priv->connection != NULL) {
+                g_object_unref (priv->connection);
+                priv->connection = NULL;
+        }
+
+        if (priv->condition_monitor) {
+                g_file_monitor_cancel (priv->condition_monitor);
+        }
+
+        G_OBJECT_CLASS (gsm_autostart_app_parent_class)->dispose (object);
+}
+
+static gboolean
+is_running (GsmApp *app)
+{
+        GsmAutostartAppPrivate *priv;
+        gboolean                is;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        /* is running if pid is still valid or
+         * or a client is connected
+         */
+        /* FIXME: check client */
+        is = (priv->pid != -1);
+
+        return is;
+}
+
+static gboolean
+is_conditionally_disabled (GsmApp *app)
+{
+        gboolean                res;
+        gboolean                disabled;
+        char                   *key;
+        guint                   kind;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        /* Check AutostartCondition */
+        if (priv->condition_string == NULL) {
+                return FALSE;
+        }
+
+        key = NULL;
+        res = parse_condition_string (priv->condition_string, &kind, &key);
+        if (! res) {
+                g_free (key);
+                return TRUE;
+        }
+
+        if (key == NULL) {
+                return TRUE;
+        }
+
+        if (kind == GSM_CONDITION_IF_EXISTS) {
+                char *file_path;
+
+                file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
+                disabled = !g_file_test (file_path, G_FILE_TEST_EXISTS);
+                g_free (file_path);
+        } else if (kind == GSM_CONDITION_UNLESS_EXISTS) {
+                char *file_path;
+
+                file_path = g_build_filename (g_get_user_config_dir (), key, NULL);
+                disabled = g_file_test (file_path, G_FILE_TEST_EXISTS);
+                g_free (file_path);
+        } else if (kind == GSM_CONDITION_MATE && priv->condition_settings != NULL) {
+                char **elems;
+                elems = g_strsplit (key, " ", 2);
+                disabled = !g_settings_get_boolean (priv->condition_settings, elems[1]);
+                g_strfreev (elems);
+        } else if (kind == GSM_CONDITION_GSETTINGS && priv->condition_settings != NULL) {
+                char **elems;
+                elems = g_strsplit (key, " ", 2);
+                disabled = !g_settings_get_boolean (priv->condition_settings, elems[1]);
+                g_strfreev (elems);
+        } else {
+                disabled = TRUE;
+        }
+
+        /* Set initial condition */
+        priv->condition = !disabled;
+
+        g_free (key);
+
+        return disabled;
+}
+
+static void
+app_exited (GPid             pid,
+            int              status,
+            GsmAutostartApp *app)
+{
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+        g_debug ("GsmAutostartApp: (pid:%d) done (%s:%d)",
+                 (int) pid,
+                 WIFEXITED (status) ? "status"
+                 : WIFSIGNALED (status) ? "signal"
+                 : "unknown",
+                 WIFEXITED (status) ? WEXITSTATUS (status)
+                 : WIFSIGNALED (status) ? WTERMSIG (status)
+                 : -1);
+
+        g_spawn_close_pid (priv->pid);
+        priv->pid = -1;
+        priv->child_watch_id = 0;
+
+        if (WIFEXITED (status)) {
+                gsm_app_exited (GSM_APP (app));
+        } else if (WIFSIGNALED (status)) {
+                gsm_app_died (GSM_APP (app));
+        }
+}
+
+static int
+_signal_pid (int pid,
+             int signal)
+{
+        int status = -1;
+
+        /* perhaps block sigchld */
+        g_debug ("GsmAutostartApp: sending signal %d to process %d", signal, pid);
+        errno = 0;
+        status = kill (pid, signal);
+
+        if (status < 0) {
+                if (errno == ESRCH) {
+                        g_warning ("Child process %d was already dead.",
+                                   (int)pid);
+                } else {
+                        g_warning ("Couldn't kill child process %d: %s",
+                                   pid,
+                                   g_strerror (errno));
+                }
+        }
+
+        /* perhaps unblock sigchld */
+
+        return status;
+}
+
+static gboolean
+autostart_app_stop_spawn (GsmAutostartApp *app,
+                          GError         **error)
+{
+        int res;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        if (priv->pid < 1) {
+                g_set_error (error,
+                             GSM_APP_ERROR,
+                             GSM_APP_ERROR_STOP,
+                             "Not running");
+                return FALSE;
+        }
+
+        res = _signal_pid (priv->pid, SIGTERM);
+        if (res != 0) {
+                g_set_error (error,
+                             GSM_APP_ERROR,
+                             GSM_APP_ERROR_STOP,
+                             "Unable to stop: %s",
+                             g_strerror (errno));
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+static gboolean
+autostart_app_stop_activate (GsmAutostartApp *app,
+                             GError         **error)
+{
+        return TRUE;
+}
+
+static gboolean
+gsm_autostart_app_stop (GsmApp  *app,
+                        GError **error)
+{
+        GsmAutostartApp *aapp;
+        gboolean         ret;
+        GsmAutostartAppPrivate *priv;
+
+        aapp = GSM_AUTOSTART_APP (app);
+
+        priv = gsm_autostart_app_get_instance_private (aapp);
+        g_return_val_if_fail (priv->desktop_file != NULL, FALSE);
+
+        switch (priv->launch_type) {
+        case AUTOSTART_LAUNCH_SPAWN:
+                ret = autostart_app_stop_spawn (aapp, error);
+                break;
+        case AUTOSTART_LAUNCH_ACTIVATE:
+                ret = autostart_app_stop_activate (aapp, error);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        return ret;
+}
+
+static gboolean
+autostart_app_start_spawn (GsmAutostartApp *app,
+                           GError         **error)
+{
+        char            *env[2] = { NULL, NULL };
+        gboolean         success;
+        GError          *local_error;
+        const char      *startup_id;
+        char            *command;
+        GsmAutostartAppPrivate *priv;
+
+        startup_id = gsm_app_peek_startup_id (GSM_APP (app));
+        g_assert (startup_id != NULL);
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        env[0] = g_strdup_printf ("DESKTOP_AUTOSTART_ID=%s", startup_id);
+
+        local_error = NULL;
+        command = egg_desktop_file_parse_exec (priv->desktop_file,
+                                               NULL,
+                                               &local_error);
+        if (command == NULL) {
+                g_warning ("Unable to parse command from  '%s': %s",
+                           egg_desktop_file_get_source (priv->desktop_file),
+                           local_error->message);
+                g_error_free (local_error);
+        }
+
+        g_debug ("GsmAutostartApp: starting %s: command=%s startup-id=%s", priv->desktop_id, command, startup_id);
+        g_free (command);
+
+        g_free (priv->startup_id);
+        local_error = NULL;
+        success = egg_desktop_file_launch (priv->desktop_file,
+                                           NULL,
+                                           &local_error,
+                                           EGG_DESKTOP_FILE_LAUNCH_PUTENV, env,
+                                           EGG_DESKTOP_FILE_LAUNCH_FLAGS, G_SPAWN_DO_NOT_REAP_CHILD,
+                                           EGG_DESKTOP_FILE_LAUNCH_RETURN_PID, &priv->pid,
+                                           EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID, &priv->startup_id,
+                                           NULL);
+        g_free (env[0]);
+
+        if (success) {
+                g_debug ("GsmAutostartApp: started pid:%d", priv->pid);
+                priv->child_watch_id = g_child_watch_add (priv->pid,
+                                                          (GChildWatchFunc)app_exited,
+                                                          app);
+        } else {
+                g_set_error (error,
+                             GSM_APP_ERROR,
+                             GSM_APP_ERROR_START,
+                             "Unable to start application: %s", local_error->message);
+                g_error_free (local_error);
+        }
+
+        return success;
+}
+
+static void
+start_notify (GObject *source_object,
+              GAsyncResult *res,
+              gpointer data)
+{
+        GsmAutostartApp *app;
+        GsmAutostartAppPrivate *priv;
+        GError  *error;
+        GVariant *variant;
+
+        app = data;
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        error = NULL;
+        if (priv->proxy == NULL)
+                return;
+
+        variant = g_dbus_proxy_call_finish (priv->proxy, res, &error);
+        if (variant == NULL) {
+                g_warning ("GsmAutostartApp: Error starting application: %s", error->message);
+                g_error_free (error);
+                return;
+        } else {
+                g_debug ("GsmAutostartApp: Started application %s", priv->desktop_id);
+                g_variant_unref (variant);
+        }
+
+        g_object_unref (priv->proxy);
+        priv->proxy = NULL;
+
+        g_object_unref (priv->connection);
+        priv->connection = NULL;
+}
+
+static gboolean
+autostart_app_start_activate (GsmAutostartApp  *app,
+                              GError          **error)
+{
+        const char      *name;
+        char            *path;
+        char            *arguments;
+        GError          *local_error;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (app);
+
+        local_error = NULL;
+        priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &local_error);
+        if (priv->connection == NULL) {
+                if (local_error != NULL) {
+                        g_warning ("error getting session bus: %s", local_error->message);
+                }
+                g_propagate_error (error, local_error);
+                return FALSE;
+        }
+
+        name = gsm_app_peek_startup_id (GSM_APP (app));
+        g_assert (name != NULL);
+
+        path = egg_desktop_file_get_string (priv->desktop_file,
+                                            GSM_AUTOSTART_APP_DBUS_PATH_KEY,
+                                            NULL);
+        if (path == NULL) {
+                /* just pick one? */
+                path = g_strdup ("/");
+        }
+
+        arguments = egg_desktop_file_get_string (priv->desktop_file,
+                                                 GSM_AUTOSTART_APP_DBUS_ARGS_KEY,
+                                                 NULL);
+
+        local_error = NULL;
+        priv->proxy = g_dbus_proxy_new_sync (priv->connection,
+                                             G_DBUS_PROXY_FLAGS_NONE,
+                                             NULL,
+                                             name,
+                                             path,
+                                             GSM_SESSION_CLIENT_DBUS_INTERFACE,
+                                             NULL,
+                                             &local_error);
+        if (priv->proxy == NULL) {
+                g_propagate_error (error, local_error);
+                return FALSE;
+        }
+
+        g_dbus_proxy_call (priv->proxy,
+                           "Start",
+                           g_variant_new ("(s)", arguments),
+                           G_DBUS_CALL_FLAGS_NONE,
+                           -1,
+                           NULL,
+                           (GAsyncReadyCallback) start_notify,
+                           app);
+
+        return TRUE;
+}
+
+static gboolean
+gsm_autostart_app_start (GsmApp  *app,
+                         GError **error)
+{
+        GsmAutostartApp *aapp;
+        gboolean         ret;
+        GsmAutostartAppPrivate *priv;
+
+        aapp = GSM_AUTOSTART_APP (app);
+        priv = gsm_autostart_app_get_instance_private (aapp);
+
+        g_return_val_if_fail (priv->desktop_file != NULL, FALSE);
+
+        switch (priv->launch_type) {
+        case AUTOSTART_LAUNCH_SPAWN:
+                ret = autostart_app_start_spawn (aapp, error);
+                break;
+        case AUTOSTART_LAUNCH_ACTIVATE:
+                ret = autostart_app_start_activate (aapp, error);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        return ret;
+}
+
+static gboolean
+gsm_autostart_app_restart (GsmApp  *app,
+                           GError **error)
+{
+        GError  *local_error;
+        gboolean res;
+
+        /* ignore stop errors - it is fine if it is already stopped */
+        local_error = NULL;
+        res = gsm_app_stop (app, &local_error);
+        if (! res) {
+                g_debug ("GsmAutostartApp: Couldn't stop app: %s", local_error->message);
+                g_error_free (local_error);
+        }
+
+        res = gsm_app_start (app, &local_error);
+        if (! res) {
+                g_propagate_error (error, local_error);
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+static gboolean
+gsm_autostart_app_provides (GsmApp     *app,
+                            const char *service)
+{
+        char           **provides;
+        gsize            len;
+        gsize            i;
+        GsmAutostartApp *aapp;
+        GsmAutostartAppPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+
+        aapp = GSM_AUTOSTART_APP (app);
+        priv = gsm_autostart_app_get_instance_private (aapp);
+
+        if (priv->desktop_file == NULL) {
+                return FALSE;
+        }
+
+        provides = egg_desktop_file_get_string_list (priv->desktop_file,
+                                                     GSM_AUTOSTART_APP_PROVIDES_KEY,
+                                                     &len, NULL);
+        if (!provides) {
+                return FALSE;
+        }
+
+        for (i = 0; i < len; i++) {
+                if (!strcmp (provides[i], service)) {
+                        g_strfreev (provides);
+                        return TRUE;
+                }
+        }
+
+        g_strfreev (provides);
+        return FALSE;
+}
+
+static gboolean
+gsm_autostart_app_has_autostart_condition (GsmApp     *app,
+                                           const char *condition)
+{
+        GsmAutostartApp *aapp;
+        GsmAutostartAppPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_APP (app), FALSE);
+        g_return_val_if_fail (condition != NULL, FALSE);
+
+        aapp = GSM_AUTOSTART_APP (app);
+        priv = gsm_autostart_app_get_instance_private (aapp);
+
+        if (priv->condition_string == NULL) {
+                return FALSE;
+        }
+
+        if (strcmp (priv->condition_string, condition) == 0) {
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+static gboolean
+gsm_autostart_app_get_autorestart (GsmApp *app)
+{
+        gboolean res;
+        gboolean autorestart;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        if (priv->desktop_file == NULL) {
+                return FALSE;
+        }
+
+        autorestart = FALSE;
+
+        res = egg_desktop_file_has_key (priv->desktop_file,
+                                        GSM_AUTOSTART_APP_AUTORESTART_KEY,
+                                        NULL);
+        if (res) {
+                autorestart = egg_desktop_file_get_boolean (priv->desktop_file,
+                                                            GSM_AUTOSTART_APP_AUTORESTART_KEY,
+                                                            NULL);
+        }
+
+        return autorestart;
+}
+
+static const char *
+gsm_autostart_app_get_app_id (GsmApp *app)
+{
+        const char *location;
+        const char *slash;
+        GsmAutostartAppPrivate *priv;
+
+        priv = gsm_autostart_app_get_instance_private (GSM_AUTOSTART_APP(app));
+
+        if (priv->desktop_file == NULL) {
+                return NULL;
+        }
+
+        location = egg_desktop_file_get_source (priv->desktop_file);
+
+        slash = strrchr (location, '/');
+        if (slash != NULL) {
+                return slash + 1;
+        } else {
+                return location;
+        }
+}
+
+static int
+gsm_autostart_app_peek_autostart_delay (GsmApp *app)
+{
+        GsmAutostartAppPrivate *priv;
+        GsmAutostartApp *aapp = GSM_AUTOSTART_APP (app);
+
+        priv = gsm_autostart_app_get_instance_private (aapp);
+
+        return priv->autostart_delay;
+}
+
+static GObject *
+gsm_autostart_app_constructor (GType                  type,
+                               guint                  n_construct_properties,
+                               GObjectConstructParam *construct_properties)
+{
+        GsmAutostartApp *app;
+
+        app = GSM_AUTOSTART_APP (G_OBJECT_CLASS (gsm_autostart_app_parent_class)->constructor (type,
+                                                                                               n_construct_properties,
+                                                                                               construct_properties));
+
+        if (! load_desktop_file (app)) {
+                g_object_unref (app);
+                app = NULL;
+        }
+
+        return G_OBJECT (app);
+}
+
+static void
+gsm_autostart_app_class_init (GsmAutostartAppClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        GsmAppClass  *app_class = GSM_APP_CLASS (klass);
+
+        object_class->set_property = gsm_autostart_app_set_property;
+        object_class->get_property = gsm_autostart_app_get_property;
+        object_class->dispose = gsm_autostart_app_dispose;
+        object_class->constructor = gsm_autostart_app_constructor;
+
+        app_class->impl_is_disabled = is_disabled;
+        app_class->impl_is_conditionally_disabled = is_conditionally_disabled;
+        app_class->impl_is_running = is_running;
+        app_class->impl_start = gsm_autostart_app_start;
+        app_class->impl_restart = gsm_autostart_app_restart;
+        app_class->impl_stop = gsm_autostart_app_stop;
+        app_class->impl_provides = gsm_autostart_app_provides;
+        app_class->impl_has_autostart_condition = gsm_autostart_app_has_autostart_condition;
+        app_class->impl_get_app_id = gsm_autostart_app_get_app_id;
+        app_class->impl_get_autorestart = gsm_autostart_app_get_autorestart;
+        app_class->impl_peek_autostart_delay = gsm_autostart_app_peek_autostart_delay;
+
+        g_object_class_install_property (object_class,
+                                         PROP_DESKTOP_FILENAME,
+                                         g_param_spec_string ("desktop-filename",
+                                                              "Desktop filename",
+                                                              "Freedesktop .desktop file",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        signals[CONDITION_CHANGED] =
+                g_signal_new ("condition-changed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmAutostartAppClass, condition_changed),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__BOOLEAN,
+                              G_TYPE_NONE,
+                              1,
+                              G_TYPE_BOOLEAN);
+}
+
+GsmApp *
+gsm_autostart_app_new (const char *desktop_file)
+{
+        GsmAutostartApp *app;
+
+        app = g_object_new (GSM_TYPE_AUTOSTART_APP,
+                            "desktop-filename", desktop_file,
+                            NULL);
+
+        return GSM_APP (app);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/22.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/22.html new file mode 100644 index 0000000..a7d1e66 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/22.html @@ -0,0 +1,353 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_AUTOSTART_APP_H__
+#define __GSM_AUTOSTART_APP_H__
+
+#include "gsm-app.h"
+
+#include <X11/SM/SMlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_AUTOSTART_APP            (gsm_autostart_app_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsmAutostartApp, gsm_autostart_app, GSM, AUTOSTART_APP, GsmApp)
+
+struct _GsmAutostartAppClass
+{
+        GsmAppClass parent_class;
+
+        /* signals */
+        void     (*condition_changed)  (GsmApp  *app,
+                                        gboolean condition);
+};
+
+GsmApp *gsm_autostart_app_new                (const char *desktop_file);
+
+#define GSM_AUTOSTART_APP_PHASE_KEY       "X-MATE-Autostart-Phase"
+#define GSM_AUTOSTART_APP_PROVIDES_KEY    "X-MATE-Provides"
+#define GSM_AUTOSTART_APP_STARTUP_ID_KEY  "X-MATE-Autostart-startup-id"
+#define GSM_AUTOSTART_APP_AUTORESTART_KEY "X-MATE-AutoRestart"
+#define GSM_AUTOSTART_APP_DBUS_NAME_KEY   "X-MATE-DBus-Name"
+#define GSM_AUTOSTART_APP_DBUS_PATH_KEY   "X-MATE-DBus-Path"
+#define GSM_AUTOSTART_APP_DBUS_ARGS_KEY   "X-MATE-DBus-Start-Arguments"
+#define GSM_AUTOSTART_APP_DISCARD_KEY     "X-MATE-Autostart-discard-exec"
+#define GSM_AUTOSTART_APP_DELAY_KEY       "X-MATE-Autostart-Delay"
+
+G_END_DECLS
+
+#endif /* __GSM_AUTOSTART_APP_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/23.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/23.html new file mode 100644 index 0000000..bcc467b --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/23.html @@ -0,0 +1,383 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* gsm-util.h
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_UTIL_H__
+#define __GSM_UTIL_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define IS_STRING_EMPTY(x) ((x)==NULL||(x)[0]=='\0')
+
+gchar**     gsm_get_screen_locker_command           (void);
+
+char *      gsm_util_find_desktop_file_for_app_name (const char  *app_name,
+                                                     char       **dirs);
+
+gchar      *gsm_util_get_empty_tmp_session_dir      (void);
+
+const char *gsm_util_get_saved_session_dir          (void);
+
+gchar**     gsm_util_get_app_dirs                   (void);
+
+gchar**     gsm_util_get_autostart_dirs             (void);
+
+gchar **    gsm_util_get_desktop_dirs               (void);
+
+gboolean    gsm_util_text_is_blank                  (const char *str);
+
+void        gsm_util_init_error                     (gboolean    fatal,
+                                                     const char *format, ...);
+
+char *      gsm_util_generate_startup_id            (void);
+
+gboolean    gsm_util_export_activation_environment  (GError     **error);
+
+#ifdef HAVE_SYSTEMD
+gboolean    gsm_util_export_user_environment        (GError     **error);
+#endif
+
+void        gsm_util_setenv                         (const char *variable,
+                                                     const char *value);
+
+GtkWidget*  gsm_util_dialog_add_button              (GtkDialog   *dialog,
+                                                     const gchar *button_text,
+                                                     const gchar *icon_name,
+                                                     gint         response_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GSM_UTIL_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/24.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/24.html new file mode 100644 index 0000000..ae3f3ed --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/24.html @@ -0,0 +1,1401 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "eggdesktopfile.h"<--- Include file: "eggdesktopfile.h" not found.
+
+#include "gsm-marshal.h"
+#include "gsm-client.h"
+#include "gsm-client-glue.h"
+
+static guint32 client_serial = 1;
+
+typedef struct {
+        GObject          parent;
+        char            *id;
+        char            *startup_id;
+        char            *app_id;
+        guint            status;
+        DBusGConnection *connection;
+} GsmClientPrivate;
+
+enum {
+        PROP_0,
+        PROP_ID,
+        PROP_STARTUP_ID,
+        PROP_APP_ID,
+        PROP_STATUS
+};
+
+enum {
+        DISCONNECTED,
+        END_SESSION_RESPONSE,
+        LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsmClient, gsm_client, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+GQuark
+gsm_client_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_client_error");
+        }
+
+        return ret;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+gsm_client_error_get_type (void)
+{
+        static GType etype = 0;
+
+        if (etype == 0) {
+                static const GEnumValue values[] = {
+                        ENUM_ENTRY (GSM_CLIENT_ERROR_GENERAL, "GeneralError"),
+                        ENUM_ENTRY (GSM_CLIENT_ERROR_NOT_REGISTERED, "NotRegistered"),
+                        { 0, 0, 0 }
+                };
+
+                g_assert (GSM_CLIENT_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+
+                etype = g_enum_register_static ("GsmClientError", values);
+        }
+
+        return etype;
+}
+
+static guint32
+get_next_client_serial (void)
+{
+        guint32 serial;
+
+        serial = client_serial++;
+
+        if ((gint32)client_serial < 0) {
+                client_serial = 1;
+        }
+
+        return serial;
+}
+
+static gboolean
+register_client (GsmClient *client)
+{
+        GError *error;
+        GsmClientPrivate *priv;
+
+        error = NULL;
+        priv = gsm_client_get_instance_private (client);
+        priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (priv->connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                return FALSE;
+        }
+
+        dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (client));
+
+        return TRUE;
+}
+
+static GObject *
+gsm_client_constructor (GType                  type,
+                        guint                  n_construct_properties,
+                        GObjectConstructParam *construct_properties)
+{
+        GsmClient *client;
+        gboolean   res;
+        GsmClientPrivate *priv;
+
+        client = GSM_CLIENT (G_OBJECT_CLASS (gsm_client_parent_class)->constructor (type,
+                                                                                    n_construct_properties,
+                                                                                    construct_properties));
+        priv = gsm_client_get_instance_private (client);
+        g_free (priv->id);
+        priv->id = g_strdup_printf ("/org/gnome/SessionManager/Client%u", get_next_client_serial ());
+
+        res = register_client (client);
+        if (! res) {
+                g_warning ("Unable to register client with session bus");
+        }
+
+        return G_OBJECT (client);
+}
+
+static void
+gsm_client_init (GsmClient *client)
+{
+}
+
+static void
+gsm_client_finalize (GObject *object)
+{
+        GsmClient *client;
+        GsmClientPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_CLIENT (object));
+
+        client = GSM_CLIENT (object);
+        priv = gsm_client_get_instance_private (client);
+
+        g_return_if_fail (priv != NULL);
+
+        g_free (priv->id);
+        g_free (priv->startup_id);
+        g_free (priv->app_id);
+
+        G_OBJECT_CLASS (gsm_client_parent_class)->finalize (object);
+}
+
+void
+gsm_client_set_status (GsmClient *client,
+                       guint      status)
+{
+        GsmClientPrivate *priv;
+        g_return_if_fail (GSM_IS_CLIENT (client));
+
+        priv = gsm_client_get_instance_private (client);
+        if (priv->status != status) {
+                priv->status = status;
+                g_object_notify (G_OBJECT (client), "status");
+        }
+}
+
+static void
+gsm_client_set_startup_id (GsmClient  *client,
+                           const char *startup_id)
+{
+        GsmClientPrivate *priv;
+        g_return_if_fail (GSM_IS_CLIENT (client));
+
+        priv = gsm_client_get_instance_private (client);
+
+        g_free (priv->startup_id);
+
+        if (startup_id != NULL) {
+                priv->startup_id = g_strdup (startup_id);
+        } else {
+                priv->startup_id = g_strdup ("");
+        }
+        g_object_notify (G_OBJECT (client), "startup-id");
+}
+
+void
+gsm_client_set_app_id (GsmClient  *client,
+                       const char *app_id)
+{
+        GsmClientPrivate *priv;
+        g_return_if_fail (GSM_IS_CLIENT (client));
+
+        priv = gsm_client_get_instance_private (client);
+
+        g_free (priv->app_id);
+
+        if (app_id != NULL) {
+                priv->app_id = g_strdup (app_id);
+        } else {
+                priv->app_id = g_strdup ("");
+        }
+        g_object_notify (G_OBJECT (client), "app-id");
+}
+
+static void
+gsm_client_set_property (GObject       *object,
+                         guint          prop_id,
+                         const GValue  *value,
+                         GParamSpec    *pspec)
+{
+        GsmClient *self;
+
+        self = GSM_CLIENT (object);
+
+        switch (prop_id) {
+        case PROP_STARTUP_ID:
+                gsm_client_set_startup_id (self, g_value_get_string (value));
+                break;
+        case PROP_APP_ID:
+                gsm_client_set_app_id (self, g_value_get_string (value));
+                break;
+        case PROP_STATUS:
+                gsm_client_set_status (self, g_value_get_uint (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_client_get_property (GObject    *object,
+                         guint       prop_id,
+                         GValue     *value,
+                         GParamSpec *pspec)
+{
+        GsmClient *self;
+        GsmClientPrivate *priv;
+
+        self = GSM_CLIENT (object);
+        priv = gsm_client_get_instance_private (self);
+
+        switch (prop_id) {
+        case PROP_STARTUP_ID:
+                g_value_set_string (value, priv->startup_id);
+                break;
+        case PROP_APP_ID:
+                g_value_set_string (value, priv->app_id);
+                break;
+        case PROP_STATUS:
+                g_value_set_uint (value, priv->status);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static gboolean
+default_stop (GsmClient *client,
+              GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        g_warning ("Stop not implemented");
+
+        return TRUE;
+}
+
+static void
+gsm_client_dispose (GObject *object)
+{
+        GsmClient *client;
+        GsmClientPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_CLIENT (object));
+
+        client = GSM_CLIENT (object);
+        priv = gsm_client_get_instance_private (client);
+
+        g_debug ("GsmClient: disposing %s", priv->id);
+
+        G_OBJECT_CLASS (gsm_client_parent_class)->dispose (object);
+}
+
+static void
+gsm_client_class_init (GsmClientClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsm_client_get_property;
+        object_class->set_property = gsm_client_set_property;
+        object_class->constructor = gsm_client_constructor;
+        object_class->finalize = gsm_client_finalize;
+        object_class->dispose = gsm_client_dispose;
+
+        klass->impl_stop = default_stop;
+
+        signals[DISCONNECTED] =
+                g_signal_new ("disconnected",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmClientClass, disconnected),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+        signals[END_SESSION_RESPONSE] =
+                g_signal_new ("end-session-response",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmClientClass, end_session_response),
+                              NULL, NULL,
+                              gsm_marshal_VOID__BOOLEAN_BOOLEAN_BOOLEAN_STRING,
+                              G_TYPE_NONE,
+                              4, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING);
+
+        g_object_class_install_property (object_class,
+                                         PROP_STARTUP_ID,
+                                         g_param_spec_string ("startup-id",
+                                                              "startup-id",
+                                                              "startup-id",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_APP_ID,
+                                         g_param_spec_string ("app-id",
+                                                              "app-id",
+                                                              "app-id",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_STATUS,
+                                         g_param_spec_uint ("status",
+                                                            "status",
+                                                            "status",
+                                                            0,
+                                                            G_MAXINT,
+                                                            GSM_CLIENT_UNREGISTERED,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+        dbus_g_object_type_install_info (GSM_TYPE_CLIENT, &dbus_glib_gsm_client_object_info);
+}
+
+const char *
+gsm_client_peek_id (GsmClient *client)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
+
+        priv = gsm_client_get_instance_private (client);
+
+        return priv->id;
+}
+
+/**
+ * gsm_client_peek_app_id:
+ * @client: a #GsmClient.
+ *
+ * Note that the application ID might not be known; this happens when for XSMP
+ * clients that we did not start ourselves, for instance.
+ *
+ * Returns: the application ID of the client, or %NULL if no such ID is
+ * known. The string is owned by @client.
+ **/
+const char *
+gsm_client_peek_app_id (GsmClient *client)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
+
+        priv = gsm_client_get_instance_private (client);
+
+        return priv->app_id;
+}
+
+const char *
+gsm_client_peek_startup_id (GsmClient *client)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
+
+        priv = gsm_client_get_instance_private (client);
+
+        return priv->startup_id;
+}
+
+guint
+gsm_client_peek_status (GsmClient *client)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), GSM_CLIENT_UNREGISTERED);
+
+        priv = gsm_client_get_instance_private (client);
+
+        return priv->status;
+}
+
+guint
+gsm_client_peek_restart_style_hint (GsmClient *client)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), GSM_CLIENT_RESTART_NEVER);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_get_restart_style_hint (client);
+}
+
+gboolean
+gsm_client_get_startup_id (GsmClient *client,
+                           char     **id,
+                           GError   **error)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        priv = gsm_client_get_instance_private (client);
+
+        *id = g_strdup (priv->startup_id);
+
+        return TRUE;
+}
+
+gboolean
+gsm_client_get_app_id (GsmClient *client,
+                       char     **id,
+                       GError   **error)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        priv = gsm_client_get_instance_private (client);
+
+        *id = g_strdup (priv->app_id);
+
+        return TRUE;
+}
+
+gboolean
+gsm_client_get_restart_style_hint (GsmClient *client,
+                                   guint     *hint,
+                                   GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        *hint = GSM_CLIENT_GET_CLASS (client)->impl_get_restart_style_hint (client);
+
+        return TRUE;
+}
+
+gboolean
+gsm_client_get_status (GsmClient *client,
+                       guint     *status,
+                       GError   **error)
+{
+        GsmClientPrivate *priv;
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        priv = gsm_client_get_instance_private (client);
+
+        *status = priv->status;
+
+        return TRUE;
+}
+
+gboolean
+gsm_client_get_unix_process_id (GsmClient  *client,
+                                guint      *pid,
+                                GError    **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        *pid = GSM_CLIENT_GET_CLASS (client)->impl_get_unix_process_id (client);
+
+        return TRUE;
+}
+
+/**
+ * gsm_client_get_app_name:
+ * @client: a #GsmClient.
+ *
+ * Returns: a copy of the application name of the client, or %NULL if no such
+ * name is known.
+ **/
+char *
+gsm_client_get_app_name (GsmClient *client)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), NULL);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_get_app_name (client);
+}
+
+gboolean
+gsm_client_cancel_end_session (GsmClient *client,
+                               GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_cancel_end_session (client, error);
+}
+
+gboolean
+gsm_client_query_end_session (GsmClient *client,
+                              guint      flags,
+                              GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_query_end_session (client, flags, error);
+}
+
+gboolean
+gsm_client_end_session (GsmClient *client,
+                        guint      flags,
+                        GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_end_session (client, flags, error);
+}
+
+gboolean
+gsm_client_stop (GsmClient *client,
+                 GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_stop (client, error);
+}
+
+void
+gsm_client_disconnected (GsmClient *client)
+{
+        g_signal_emit (client, signals[DISCONNECTED], 0);
+}
+
+GKeyFile *
+gsm_client_save (GsmClient *client,
+                 GError   **error)
+{
+        g_return_val_if_fail (GSM_IS_CLIENT (client), FALSE);
+
+        return GSM_CLIENT_GET_CLASS (client)->impl_save (client, error);
+}
+
+void
+gsm_client_end_session_response (GsmClient  *client,
+                                 gboolean    is_ok,
+                                 gboolean    do_last,
+                                 gboolean    cancel,
+                                 const char *reason)
+{
+        g_signal_emit (client, signals[END_SESSION_RESPONSE], 0,
+                       is_ok, do_last, cancel, reason);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/25.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/25.html new file mode 100644 index 0000000..5c79a95 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/25.html @@ -0,0 +1,315 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#ifndef __GSM_MARSHAL_MARSHAL_H__
+#define __GSM_MARSHAL_MARSHAL_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+/* BOOLEAN:POINTER (gsm-marshal.list:1) */
+extern
+void gsm_marshal_BOOLEAN__POINTER (GClosure     *closure,
+                                   GValue       *return_value,
+                                   guint         n_param_values,
+                                   const GValue *param_values,
+                                   gpointer      invocation_hint,
+                                   gpointer      marshal_data);
+
+/* VOID:BOOLEAN,BOOLEAN,BOOLEAN,STRING (gsm-marshal.list:2) */
+extern
+void gsm_marshal_VOID__BOOLEAN_BOOLEAN_BOOLEAN_STRING (GClosure     *closure,
+                                                       GValue       *return_value,
+                                                       guint         n_param_values,
+                                                       const GValue *param_values,
+                                                       gpointer      invocation_hint,
+                                                       gpointer      marshal_data);
+
+/* VOID:BOOLEAN,BOOLEAN,POINTER (gsm-marshal.list:3) */
+extern
+void gsm_marshal_VOID__BOOLEAN_BOOLEAN_POINTER (GClosure     *closure,
+                                                GValue       *return_value,
+                                                guint         n_param_values,
+                                                const GValue *param_values,
+                                                gpointer      invocation_hint,
+                                                gpointer      marshal_data);
+
+
+G_END_DECLS<--- syntax error
+
+#endif /* __GSM_MARSHAL_MARSHAL_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/26.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/26.html new file mode 100644 index 0000000..aeb5809 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/26.html @@ -0,0 +1,571 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                            GValue       *return_value,
+                                                            guint         n_param_values,
+                                                            const GValue *param_values,
+                                                            gpointer      invocation_hint,
+                                                            gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                       GValue       *return_value,
+                                                       guint         n_param_values,
+                                                       const GValue *param_values,
+                                                       gpointer      invocation_hint G_GNUC_UNUSED,
+                                                       gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+                                                             gpointer arg1,
+                                                             gpointer arg2,
+                                                             gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_client_BOOLEAN__POINTER (GClosure     *closure,
+                                                    GValue       *return_value,
+                                                    guint         n_param_values,
+                                                    const GValue *param_values,
+                                                    gpointer      invocation_hint,
+                                                    gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_client_BOOLEAN__POINTER (GClosure     *closure,
+                                               GValue       *return_value,
+                                               guint         n_param_values,
+                                               const GValue *param_values,
+                                               gpointer      invocation_hint G_GNUC_UNUSED,
+                                               gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+                                                     gpointer arg1,
+                                                     gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 2);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gsm_client_methods[] = {
+  { (GCallback) gsm_client_get_app_id, dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER, 0 },
+  { (GCallback) gsm_client_get_startup_id, dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER, 59 },
+  { (GCallback) gsm_client_get_restart_style_hint, dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER, 126 },
+  { (GCallback) gsm_client_get_unix_process_id, dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER, 194 },
+  { (GCallback) gsm_client_get_status, dbus_glib_marshal_gsm_client_BOOLEAN__POINTER_POINTER, 258 },
+  { (GCallback) gsm_client_stop, dbus_glib_marshal_gsm_client_BOOLEAN__POINTER, 318 },
+};
+
+const DBusGObjectInfo dbus_glib_gsm_client_object_info = {  1,
+  dbus_glib_gsm_client_methods,
+  6,
+"org.gnome.SessionManager.Client\0GetAppId\0S\0app_id\0O\0F\0N\0s\0\0org.gnome.SessionManager.Client\0GetStartupId\0S\0startup_id\0O\0F\0N\0s\0\0org.gnome.SessionManager.Client\0GetRestartStyleHint\0S\0hint\0O\0F\0N\0u\0\0org.gnome.SessionManager.Client\0GetUnixProcessId\0S\0pid\0O\0F\0N\0u\0\0org.gnome.SessionManager.Client\0GetStatus\0S\0status\0O\0F\0N\0u\0\0org.gnome.SessionManager.Client\0Stop\0S\0\0\0",
+"\0",
+"\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/27.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/27.html new file mode 100644 index 0000000..91351fc --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/27.html @@ -0,0 +1,2389 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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, 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 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-marshal.h"
+#include "gsm-consolekit.h"
+
+#define CK_NAME      "org.freedesktop.ConsoleKit"
+#define CK_PATH      "/org/freedesktop/ConsoleKit"
+#define CK_INTERFACE "org.freedesktop.ConsoleKit"
+
+#define CK_MANAGER_PATH      "/org/freedesktop/ConsoleKit/Manager"
+#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager"
+#define CK_SEAT_INTERFACE    "org.freedesktop.ConsoleKit.Seat"
+#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session"
+
+typedef struct
+{
+        DBusGConnection *dbus_connection;
+        DBusGProxy      *bus_proxy;
+        DBusGProxy      *ck_proxy;
+        guint32          is_connected : 1;
+} GsmConsolekitPrivate;
+
+enum {
+        PROP_0,
+        PROP_IS_CONNECTED
+};
+
+enum {
+        REQUEST_COMPLETED = 0,
+        PRIVILEGES_COMPLETED,
+        LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void     gsm_consolekit_finalize     (GObject            *object);
+
+static void     gsm_consolekit_free_dbus    (GsmConsolekit      *manager);
+
+static DBusHandlerResult gsm_consolekit_dbus_filter (DBusConnection *connection,
+                                                     DBusMessage    *message,
+                                                     void           *user_data);
+
+static void     gsm_consolekit_on_name_owner_changed (DBusGProxy        *bus_proxy,
+                                                      const char        *name,
+                                                      const char        *prev_owner,
+                                                      const char        *new_owner,
+                                                      GsmConsolekit   *manager);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmConsolekit, gsm_consolekit, G_TYPE_OBJECT);
+
+static void
+gsm_consolekit_get_property (GObject    *object,
+                             guint       prop_id,
+                             GValue     *value,
+                             GParamSpec *pspec)
+{
+        GsmConsolekit *manager = GSM_CONSOLEKIT (object);
+        GsmConsolekitPrivate *priv;
+
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        switch (prop_id) {
+        case PROP_IS_CONNECTED:
+                g_value_set_boolean (value,
+                                     priv->is_connected);
+                break;
+
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                                   prop_id,
+                                                   pspec);
+        }
+}
+
+static void
+gsm_consolekit_class_init (GsmConsolekitClass *manager_class)
+{
+        GObjectClass *object_class;
+        GParamSpec   *param_spec;
+
+        object_class = G_OBJECT_CLASS (manager_class);
+
+        object_class->finalize = gsm_consolekit_finalize;
+        object_class->get_property = gsm_consolekit_get_property;
+
+        param_spec = g_param_spec_boolean ("is-connected",
+                                           "Is connected",
+                                           "Whether the session is connected to ConsoleKit",
+                                           FALSE,
+                                           G_PARAM_READABLE);
+
+        g_object_class_install_property (object_class, PROP_IS_CONNECTED,
+                                         param_spec);
+
+        signals [REQUEST_COMPLETED] =
+                g_signal_new ("request-completed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmConsolekitClass, request_completed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__POINTER,
+                              G_TYPE_NONE,
+                              1, G_TYPE_POINTER);
+
+        signals [PRIVILEGES_COMPLETED] =
+                g_signal_new ("privileges-completed",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmConsolekitClass, privileges_completed),
+                              NULL,
+                              NULL,
+                              gsm_marshal_VOID__BOOLEAN_BOOLEAN_POINTER,
+                              G_TYPE_NONE,
+                              3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER);
+
+}
+
+static DBusHandlerResult
+gsm_consolekit_dbus_filter (DBusConnection *connection,
+                            DBusMessage    *message,
+                            void           *user_data)
+{
+        GsmConsolekit *manager;
+
+        manager = GSM_CONSOLEKIT (user_data);
+
+        if (dbus_message_is_signal (message,
+                                    DBUS_INTERFACE_LOCAL, "Disconnected") &&
+            strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0) {
+                gsm_consolekit_free_dbus (manager);
+                /* let other filters get this disconnected signal, so that they
+                 * can handle it too */
+        }
+
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static gboolean
+gsm_consolekit_ensure_ck_connection (GsmConsolekit  *manager,
+                                     GError        **error)
+{
+        GError  *connection_error;
+        gboolean is_connected;
+        GsmConsolekitPrivate *priv;
+
+        connection_error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (priv->dbus_connection == NULL) {
+                DBusConnection *connection;
+
+                priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM,
+                                                        &connection_error);
+
+                if (priv->dbus_connection == NULL) {
+                        g_propagate_error (error, connection_error);
+                        is_connected = FALSE;
+                        goto out;
+                }
+
+                connection = dbus_g_connection_get_connection (priv->dbus_connection);
+                dbus_connection_set_exit_on_disconnect (connection, FALSE);
+                dbus_connection_add_filter (connection,
+                                            gsm_consolekit_dbus_filter,
+                                            manager, NULL);
+        }
+
+        if (priv->bus_proxy == NULL) {
+                priv->bus_proxy =
+                        dbus_g_proxy_new_for_name_owner (priv->dbus_connection,
+                                                         DBUS_SERVICE_DBUS,
+                                                         DBUS_PATH_DBUS,
+                                                         DBUS_INTERFACE_DBUS,
+                                                         &connection_error);
+
+                if (priv->bus_proxy == NULL) {
+                        g_propagate_error (error, connection_error);
+                        is_connected = FALSE;
+                        goto out;
+                }
+
+                dbus_g_proxy_add_signal (priv->bus_proxy,
+                                         "NameOwnerChanged",
+                                         G_TYPE_STRING,
+                                         G_TYPE_STRING,
+                                         G_TYPE_STRING,
+                                         G_TYPE_INVALID);
+
+                dbus_g_proxy_connect_signal (priv->bus_proxy,
+                                             "NameOwnerChanged",
+                                             G_CALLBACK (gsm_consolekit_on_name_owner_changed),
+                                             manager, NULL);
+        }
+
+        if (priv->ck_proxy == NULL) {
+                priv->ck_proxy =
+                        dbus_g_proxy_new_for_name_owner (priv->dbus_connection,
+                                                         "org.freedesktop.ConsoleKit",
+                                                         "/org/freedesktop/ConsoleKit/Manager",
+                                                         "org.freedesktop.ConsoleKit.Manager",
+                                                         &connection_error);
+
+                if (priv->ck_proxy == NULL) {
+                        g_propagate_error (error, connection_error);
+                        is_connected = FALSE;
+                        goto out;
+                }
+        }
+
+        is_connected = TRUE;
+
+out:
+        if (priv->is_connected != is_connected) {
+                priv->is_connected = (is_connected != FALSE);
+                g_object_notify (G_OBJECT (manager), "is-connected");
+        }
+
+        if (!is_connected) {
+                if (priv->dbus_connection == NULL) {
+                        if (priv->bus_proxy != NULL) {
+                                g_object_unref (priv->bus_proxy);
+                                priv->bus_proxy = NULL;
+                        }
+
+                        if (priv->ck_proxy != NULL) {
+                                g_object_unref (priv->ck_proxy);
+                                priv->ck_proxy = NULL;
+                        }
+                } else if (priv->bus_proxy == NULL) {
+                        if (priv->ck_proxy != NULL) {
+                                g_object_unref (priv->ck_proxy);
+                                priv->ck_proxy = NULL;
+                        }
+                }
+        }
+
+        return is_connected;
+}
+
+static void
+gsm_consolekit_on_name_owner_changed (DBusGProxy    *bus_proxy,
+                                      const char    *name,
+                                      const char    *prev_owner,
+                                      const char    *new_owner,
+                                      GsmConsolekit *manager)
+{
+        GsmConsolekitPrivate *priv;
+
+        if (name != NULL && strcmp (name, "org.freedesktop.ConsoleKit") != 0) {
+                return;
+        }
+
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (priv->ck_proxy != NULL) {
+                g_object_unref (priv->ck_proxy);
+                priv->ck_proxy = NULL;
+        }
+
+        gsm_consolekit_ensure_ck_connection (manager, NULL);
+}
+
+static void
+gsm_consolekit_init (GsmConsolekit *manager)
+{
+        GError *error;
+
+        error = NULL;
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+        }
+}
+
+static void
+gsm_consolekit_free_dbus (GsmConsolekit *manager)
+{
+        GsmConsolekitPrivate *priv;
+
+        priv = gsm_consolekit_get_instance_private (manager);
+        if (priv->bus_proxy != NULL) {
+                g_object_unref (priv->bus_proxy);
+                priv->bus_proxy = NULL;
+        }
+
+        if (priv->ck_proxy != NULL) {
+                g_object_unref (priv->ck_proxy);
+                priv->ck_proxy = NULL;
+        }
+
+        if (priv->dbus_connection != NULL) {
+                DBusConnection *connection;
+                connection = dbus_g_connection_get_connection (priv->dbus_connection);
+                dbus_connection_remove_filter (connection,
+                                               gsm_consolekit_dbus_filter,
+                                               manager);
+
+                dbus_g_connection_unref (priv->dbus_connection);
+                priv->dbus_connection = NULL;
+        }
+}
+
+static void
+gsm_consolekit_finalize (GObject *object)
+{
+        GsmConsolekit *manager;
+        GObjectClass  *parent_class;
+
+        manager = GSM_CONSOLEKIT (object);
+
+        parent_class = G_OBJECT_CLASS (gsm_consolekit_parent_class);
+
+        gsm_consolekit_free_dbus (manager);
+
+        if (parent_class->finalize != NULL) {
+                parent_class->finalize (object);
+        }
+}
+
+GQuark
+gsm_consolekit_error_quark (void)
+{
+        static GQuark error_quark = 0;
+
+        if (error_quark == 0) {
+                error_quark = g_quark_from_static_string ("gsm-consolekit-error");
+        }
+
+        return error_quark;
+}
+
+GsmConsolekit *
+gsm_consolekit_new (void)
+{
+        GsmConsolekit *manager;
+
+        manager = g_object_new (GSM_TYPE_CONSOLEKIT, NULL);
+
+        return manager;
+}
+
+static void
+emit_restart_complete (GsmConsolekit *manager,
+                       GError        *error)
+{
+        GError *call_error;
+
+        call_error = NULL;
+
+        if (error != NULL) {
+                call_error = g_error_new_literal (GSM_CONSOLEKIT_ERROR,
+                                                  GSM_CONSOLEKIT_ERROR_RESTARTING,
+                                                  error->message);
+        }
+
+        g_signal_emit (G_OBJECT (manager),
+                       signals [REQUEST_COMPLETED],
+                       0, call_error);
+
+        if (call_error != NULL) {
+                g_error_free (call_error);
+        }
+}
+
+static void
+emit_stop_complete (GsmConsolekit *manager,
+                    GError        *error)
+{
+        GError *call_error;
+
+        call_error = NULL;
+
+        if (error != NULL) {
+                call_error = g_error_new_literal (GSM_CONSOLEKIT_ERROR,
+                                                  GSM_CONSOLEKIT_ERROR_STOPPING,
+                                                  error->message);
+        }
+
+        g_signal_emit (G_OBJECT (manager),
+                       signals [REQUEST_COMPLETED],
+                       0, call_error);
+
+        if (call_error != NULL) {
+                g_error_free (call_error);
+        }
+}
+
+void
+gsm_consolekit_attempt_restart (GsmConsolekit *manager)
+{
+        gboolean res;
+        GError  *error;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                emit_restart_complete (manager, error);
+                g_error_free (error);
+                return;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "Restart",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_INVALID);
+
+        if (!res) {
+                g_warning ("Unable to restart system: %s", error->message);
+                emit_restart_complete (manager, error);
+                g_error_free (error);
+        } else {
+                emit_restart_complete (manager, NULL);
+        }
+}
+
+void
+gsm_consolekit_attempt_stop (GsmConsolekit *manager)
+{
+        gboolean res;
+        GError  *error;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                emit_stop_complete (manager, error);
+                g_error_free (error);
+                return;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "Stop",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_INVALID);
+
+        if (!res) {
+                g_warning ("Unable to stop system: %s", error->message);
+                emit_stop_complete (manager, error);
+                g_error_free (error);
+        } else {
+                emit_stop_complete (manager, NULL);
+        }
+}
+
+void
+gsm_consolekit_attempt_suspend (GsmConsolekit *manager)
+{
+        gboolean res;
+        GError  *error;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "Suspend",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_BOOLEAN, TRUE, /* interactive */
+                                              G_TYPE_INVALID,
+                                              G_TYPE_INVALID);
+
+        if (!res) {
+                g_warning ("Unable to suspend system: %s", error->message);
+                g_error_free (error);
+        }
+}
+
+void
+gsm_consolekit_attempt_hibernate (GsmConsolekit *manager)
+{
+        gboolean res;
+        GError  *error;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "Hibernate",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_BOOLEAN, TRUE, /* interactive */
+                                              G_TYPE_INVALID,
+                                              G_TYPE_INVALID);
+
+        if (!res) {
+                g_warning ("Unable to hibernate system: %s", error->message);
+                g_error_free (error);
+        }
+}
+
+static gboolean
+get_current_session_id (DBusConnection *connection,
+                        char          **session_id)
+{
+        DBusError       local_error;
+        DBusMessage    *message;
+        DBusMessage    *reply;
+        gboolean        ret;
+        DBusMessageIter iter;
+        const char     *value;
+
+        ret = FALSE;
+        reply = NULL;
+
+        dbus_error_init (&local_error);
+        message = dbus_message_new_method_call (CK_NAME,
+                                                CK_MANAGER_PATH,
+                                                CK_MANAGER_INTERFACE,
+                                                "GetCurrentSession");
+        if (message == NULL) {
+                goto out;
+        }
+
+        dbus_error_init (&local_error);
+        reply = dbus_connection_send_with_reply_and_block (connection,
+                                                           message,
+                                                           -1,
+                                                           &local_error);
+        if (reply == NULL) {
+                if (dbus_error_is_set (&local_error)) {
+                        g_warning ("Unable to determine session: %s", local_error.message);
+                        dbus_error_free (&local_error);
+                        goto out;
+                }
+        }
+
+        dbus_message_iter_init (reply, &iter);
+        dbus_message_iter_get_basic (&iter, &value);
+        if (session_id != NULL) {
+                *session_id = g_strdup (value);
+        }
+
+        ret = TRUE;
+out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+        if (reply != NULL) {
+                dbus_message_unref (reply);
+        }
+
+        return ret;
+}
+
+static gboolean
+get_seat_id_for_session (DBusConnection *connection,
+                         const char     *session_id,
+                         char          **seat_id)
+{
+        DBusError       local_error;
+        DBusMessage    *message;
+        DBusMessage    *reply;
+        gboolean        ret;
+        DBusMessageIter iter;
+        const char     *value;
+
+        ret = FALSE;
+        reply = NULL;
+
+        dbus_error_init (&local_error);
+        message = dbus_message_new_method_call (CK_NAME,
+                                                session_id,
+                                                CK_SESSION_INTERFACE,
+                                                "GetSeatId");
+        if (message == NULL) {
+                goto out;
+        }
+
+        dbus_error_init (&local_error);
+        reply = dbus_connection_send_with_reply_and_block (connection,
+                                                           message,
+                                                           -1,
+                                                           &local_error);
+        if (reply == NULL) {
+                if (dbus_error_is_set (&local_error)) {
+                        g_warning ("Unable to determine seat: %s", local_error.message);
+                        dbus_error_free (&local_error);
+                        goto out;
+                }
+        }
+
+        dbus_message_iter_init (reply, &iter);
+        dbus_message_iter_get_basic (&iter, &value);
+        if (seat_id != NULL) {
+                *seat_id = g_strdup (value);
+        }
+
+        ret = TRUE;
+out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+        if (reply != NULL) {
+                dbus_message_unref (reply);
+        }
+
+        return ret;
+}
+
+static char *
+get_current_seat_id (DBusConnection *connection)
+{
+        gboolean res;
+        char    *session_id;
+        char    *seat_id;
+
+        session_id = NULL;
+        seat_id = NULL;
+
+        res = get_current_session_id (connection, &session_id);
+        if (res) {
+                res = get_seat_id_for_session (connection, session_id, &seat_id);
+        }
+        g_free (session_id);
+
+        return seat_id;
+}
+
+void
+gsm_consolekit_set_session_idle (GsmConsolekit *manager,
+                                 gboolean       is_idle)
+{
+        gboolean        res;
+        GError         *error;
+        char           *session_id;
+        DBusMessage    *message;
+        DBusMessage    *reply;
+        DBusError       dbus_error;
+        DBusMessageIter iter;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return;
+        }
+
+        session_id = NULL;
+        res = get_current_session_id (dbus_g_connection_get_connection (priv->dbus_connection),
+                                      &session_id);
+        if (!res) {
+                goto out;
+        }
+
+        g_debug ("Updating ConsoleKit idle status: %d", is_idle);
+        message = dbus_message_new_method_call (CK_NAME,
+                                                session_id,
+                                                CK_SESSION_INTERFACE,
+                                                "SetIdleHint");
+        if (message == NULL) {
+                g_debug ("Couldn't allocate the D-Bus message");
+                return;
+        }
+
+        dbus_message_iter_init_append (message, &iter);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &is_idle);
+
+        /* FIXME: use async? */
+        dbus_error_init (&dbus_error);
+        reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (priv->dbus_connection),
+                                                           message,
+                                                           -1,
+                                                           &dbus_error);
+        dbus_message_unref (message);
+
+        if (reply != NULL) {
+                dbus_message_unref (reply);
+        }
+
+        if (dbus_error_is_set (&dbus_error)) {
+                g_debug ("%s raised:\n %s\n\n", dbus_error.name, dbus_error.message);
+                dbus_error_free (&dbus_error);
+        }
+
+out:
+        g_free (session_id);
+}
+
+static gboolean
+seat_can_activate_sessions (DBusConnection *connection,
+                            const char     *seat_id)
+{
+        DBusError       local_error;
+        DBusMessage    *message;
+        DBusMessage    *reply;
+        DBusMessageIter iter;
+        gboolean        can_activate;
+
+        can_activate = FALSE;
+        reply = NULL;
+
+        dbus_error_init (&local_error);
+        message = dbus_message_new_method_call (CK_NAME,
+                                                seat_id,
+                                                CK_SEAT_INTERFACE,
+                                                "CanActivateSessions");
+        if (message == NULL) {
+                goto out;
+        }
+
+        dbus_error_init (&local_error);
+        reply = dbus_connection_send_with_reply_and_block (connection,
+                                                           message,
+                                                           -1,
+                                                           &local_error);
+        if (reply == NULL) {
+                if (dbus_error_is_set (&local_error)) {
+                        g_warning ("Unable to activate session: %s", local_error.message);
+                        dbus_error_free (&local_error);
+                        goto out;
+                }
+        }
+
+        dbus_message_iter_init (reply, &iter);
+        dbus_message_iter_get_basic (&iter, &can_activate);
+
+out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+        if (reply != NULL) {
+                dbus_message_unref (reply);
+        }
+
+        return can_activate;
+}
+
+gboolean
+gsm_consolekit_can_switch_user (GsmConsolekit *manager)
+{
+        GError  *error;
+        char    *seat_id;
+        gboolean ret;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        seat_id = get_current_seat_id (dbus_g_connection_get_connection (priv->dbus_connection));
+        if (seat_id == NULL || seat_id[0] == '\0') {
+                g_debug ("seat id is not set; can't switch sessions");
+                return FALSE;
+        }
+
+        ret = seat_can_activate_sessions (dbus_g_connection_get_connection (priv->dbus_connection),
+                                          seat_id);
+        g_free (seat_id);
+
+        return ret;
+}
+
+gboolean
+gsm_consolekit_get_restart_privileges (GsmConsolekit *manager)
+{
+        g_signal_emit (G_OBJECT (manager),
+                       signals [PRIVILEGES_COMPLETED],
+                       0, TRUE, TRUE, NULL);
+
+        return TRUE;
+}
+
+gboolean
+gsm_consolekit_get_stop_privileges (GsmConsolekit *manager)
+{
+        g_signal_emit (G_OBJECT (manager),
+                       signals [PRIVILEGES_COMPLETED],
+                       0, TRUE, TRUE, NULL);
+
+        return TRUE;
+}
+
+gboolean
+gsm_consolekit_can_restart (GsmConsolekit *manager)
+{
+        gboolean res;
+        gboolean can_restart;
+        GError  *error;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "CanRestart",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_BOOLEAN, &can_restart,
+                                              G_TYPE_INVALID);
+        if (res == FALSE) {
+                g_warning ("Could not make DBUS call: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        return can_restart;
+}
+
+gboolean
+gsm_consolekit_can_stop (GsmConsolekit *manager)
+{
+        gboolean res;
+        gboolean can_stop;
+        GError  *error;
+        GsmConsolekitPrivate *priv;
+
+        error = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "CanStop",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_BOOLEAN, &can_stop,
+                                              G_TYPE_INVALID);
+
+        if (res == FALSE) {
+                g_warning ("Could not make DBUS call: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        return can_stop;
+}
+
+gboolean
+gsm_consolekit_can_suspend (GsmConsolekit *manager)
+{
+        gboolean res;
+        gboolean can_suspend;
+        gchar *retval;
+        GError *error = NULL;
+        GsmConsolekitPrivate *priv;
+
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "CanSuspend",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_STRING, &retval,
+                                              G_TYPE_INVALID);
+
+        if (res == FALSE) {
+                g_warning ("Could not make DBUS call: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        can_suspend = g_strcmp0 (retval, "yes") == 0 ||
+                      g_strcmp0 (retval, "challenge") == 0;
+
+        g_free (retval);
+        return can_suspend;
+}
+
+gboolean
+gsm_consolekit_can_hibernate (GsmConsolekit *manager)
+{
+        gboolean res;
+        gboolean can_hibernate;
+        gchar *retval;
+        GError *error = NULL;
+        GsmConsolekitPrivate *priv;
+
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &error)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = dbus_g_proxy_call_with_timeout (priv->ck_proxy,
+                                              "CanHibernate",
+                                              INT_MAX,
+                                              &error,
+                                              G_TYPE_INVALID,
+                                              G_TYPE_STRING, &retval,
+                                              G_TYPE_INVALID);
+
+        if (res == FALSE) {
+                g_warning ("Could not make DBUS call: %s",
+                           error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        can_hibernate = g_strcmp0 (retval, "yes") == 0 ||
+                        g_strcmp0 (retval, "challenge") == 0;
+
+        g_free (retval);
+        return can_hibernate;
+}
+
+gchar *
+gsm_consolekit_get_current_session_type (GsmConsolekit *manager)
+{
+        GError *gerror;
+        DBusConnection *connection;
+        DBusError error;
+        DBusMessage *message = NULL;
+        DBusMessage *reply = NULL;
+        gchar *session_id;
+        gchar *ret;
+        DBusMessageIter iter;
+        const char *value;
+        GsmConsolekitPrivate *priv;
+
+        session_id = NULL;
+        ret = NULL;
+        gerror = NULL;
+        priv = gsm_consolekit_get_instance_private (manager);
+
+        if (!gsm_consolekit_ensure_ck_connection (manager, &gerror)) {
+                g_warning ("Could not connect to ConsoleKit: %s",
+                           gerror->message);
+                g_error_free (gerror);
+                goto out;
+        }
+
+        connection = dbus_g_connection_get_connection (priv->dbus_connection);
+        if (!get_current_session_id (connection, &session_id)) {
+                goto out;
+        }
+
+        dbus_error_init (&error);
+        message = dbus_message_new_method_call (CK_NAME,
+                                                session_id,
+                                                CK_SESSION_INTERFACE,
+                                                "GetSessionType");
+        if (message == NULL) {
+                goto out;
+        }
+
+        reply = dbus_connection_send_with_reply_and_block (connection,
+                                                           message,
+                                                           -1,
+                                                           &error);
+
+        if (reply == NULL) {
+                if (dbus_error_is_set (&error)) {
+                        g_warning ("Unable to determine session type: %s", error.message);
+                        dbus_error_free (&error);
+                }
+                goto out;
+        }
+
+        dbus_message_iter_init (reply, &iter);
+        dbus_message_iter_get_basic (&iter, &value);
+        ret = g_strdup (value);
+
+out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+        if (reply != NULL) {
+                dbus_message_unref (reply);
+        }
+        g_free (session_id);
+
+        return ret;
+}
+
+GsmConsolekit *
+gsm_get_consolekit (void)
+{
+        static GsmConsolekit *manager = NULL;
+
+        if (manager == NULL) {
+                manager = gsm_consolekit_new ();
+        }
+
+        return g_object_ref (manager);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/28.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/28.html new file mode 100644 index 0000000..0fd22ad --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/28.html @@ -0,0 +1,427 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *	Jon McCann <jmccann@redhat.com>
+ */
+
+#ifndef __GSM_CONSOLEKIT_H__
+#define __GSM_CONSOLEKIT_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_CONSOLEKIT             (gsm_consolekit_get_type ())
+#define GSM_CONSOLEKIT_ERROR            (gsm_consolekit_error_quark ())
+
+G_DECLARE_DERIVABLE_TYPE (GsmConsolekit, gsm_consolekit, GSM, CONSOLEKIT, GObject)
+
+typedef enum   _GsmConsolekitError   GsmConsolekitError;
+
+struct _GsmConsolekitClass
+{
+        GObjectClass parent_class;
+
+        void (* request_completed) (GsmConsolekit *manager,
+                                    GError        *error);
+
+        void (* privileges_completed) (GsmConsolekit *manager,
+                                       gboolean       success,
+                                       gboolean       ask_later,
+                                       GError        *error);
+};
+
+enum _GsmConsolekitError {
+        GSM_CONSOLEKIT_ERROR_RESTARTING = 0,
+        GSM_CONSOLEKIT_ERROR_STOPPING
+};
+
+#define GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW "LoginWindow"
+
+GQuark           gsm_consolekit_error_quark     (void);
+
+GsmConsolekit   *gsm_consolekit_new             (void) G_GNUC_MALLOC;
+
+gboolean         gsm_consolekit_can_switch_user (GsmConsolekit *manager);
+
+gboolean         gsm_consolekit_get_restart_privileges (GsmConsolekit *manager);
+
+gboolean         gsm_consolekit_get_stop_privileges    (GsmConsolekit *manager);
+
+gboolean         gsm_consolekit_can_stop        (GsmConsolekit *manager);
+
+gboolean         gsm_consolekit_can_restart     (GsmConsolekit *manager);
+
+gboolean         gsm_consolekit_can_suspend     (GsmConsolekit *manager);
+
+gboolean         gsm_consolekit_can_hibernate   (GsmConsolekit *manager);
+
+void             gsm_consolekit_attempt_stop    (GsmConsolekit *manager);
+
+void             gsm_consolekit_attempt_restart (GsmConsolekit *manager);
+
+void             gsm_consolekit_attempt_suspend (GsmConsolekit *manager);
+
+void             gsm_consolekit_attempt_hibernate (GsmConsolekit *manager);
+
+void             gsm_consolekit_set_session_idle (GsmConsolekit *manager,
+                                                  gboolean       is_idle);
+
+gchar           *gsm_consolekit_get_current_session_type (GsmConsolekit *manager);
+
+GsmConsolekit   *gsm_get_consolekit             (void);
+
+G_END_DECLS
+
+#endif /* __GSM_CONSOLEKIT_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/29.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/29.html new file mode 100644 index 0000000..51865fc --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/29.html @@ -0,0 +1,1625 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-dbus-client.h"
+#include "gsm-marshal.h"
+
+#include "gsm-manager.h"
+#include "gsm-util.h"
+
+#define SM_DBUS_NAME                     "org.gnome.SessionManager"
+#define SM_DBUS_CLIENT_PRIVATE_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+struct _GsmDBusClient
+{
+        GsmClient             parent;
+        char                 *bus_name;
+        GPid                  caller_pid;
+        GsmClientRestartStyle restart_style_hint;
+        DBusConnection       *connection;
+};
+
+enum {
+        PROP_0,
+        PROP_BUS_NAME
+};
+
+G_DEFINE_TYPE (GsmDBusClient, gsm_dbus_client, GSM_TYPE_CLIENT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+GQuark
+gsm_dbus_client_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_dbus_client_error");
+        }
+
+        return ret;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+gsm_dbus_client_error_get_type (void)
+{
+        static GType etype = 0;
+
+        if (etype == 0) {
+                static const GEnumValue values[] = {
+                        ENUM_ENTRY (GSM_DBUS_CLIENT_ERROR_GENERAL, "GeneralError"),
+                        ENUM_ENTRY (GSM_DBUS_CLIENT_ERROR_NOT_CLIENT, "NotClient"),
+                        { 0, 0, 0 }
+                };
+
+                g_assert (GSM_DBUS_CLIENT_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+
+                etype = g_enum_register_static ("GsmDbusClientError", values);
+        }
+
+        return etype;
+}
+
+static gboolean
+setup_connection (GsmDBusClient *client)
+{
+        DBusError error;
+
+        dbus_error_init (&error);
+
+        if (client->connection == NULL) {
+                client->connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
+                if (client->connection == NULL) {
+                        if (dbus_error_is_set (&error)) {
+                                g_debug ("GsmDbusClient: Couldn't connect to session bus: %s",
+                                         error.message);
+                                dbus_error_free (&error);
+                        }
+                        return FALSE;
+                }
+
+                dbus_connection_setup_with_g_main (client->connection, NULL);
+                dbus_connection_set_exit_on_disconnect (client->connection, FALSE);
+        }
+
+        return TRUE;
+}
+
+static void
+raise_error (DBusConnection *connection,
+             DBusMessage    *in_reply_to,
+             const char     *error_name,
+             char           *format, ...)
+{
+        char         buf[512];
+        DBusMessage *reply;
+
+        va_list args;
+        va_start (args, format);
+        vsnprintf (buf, sizeof (buf), format, args);
+        va_end (args);
+
+        reply = dbus_message_new_error (in_reply_to, error_name, buf);
+        if (reply == NULL) {
+                g_error ("No memory");
+        }
+        if (! dbus_connection_send (connection, reply, NULL)) {
+                g_error ("No memory");
+        }
+
+        dbus_message_unref (reply);
+}
+
+static void
+handle_end_session_response (GsmDBusClient *client,
+                             DBusMessage   *message)
+{
+        const char     *sender;
+        DBusMessage    *reply;
+        DBusError       error;
+        dbus_bool_t     is_ok;
+        const char     *reason;
+
+        dbus_error_init (&error);
+        if (! dbus_message_get_args (message, &error,
+                                     DBUS_TYPE_BOOLEAN, &is_ok,
+                                     DBUS_TYPE_STRING, &reason,
+                                     DBUS_TYPE_INVALID)) {
+                if (dbus_error_is_set (&error)) {
+                        g_warning ("Invalid method call: %s", error.message);
+                        dbus_error_free (&error);
+                }
+                raise_error (client->connection,
+                             message,
+                             DBUS_ERROR_FAILED,
+                             "There is a syntax error in the invocation of the method EndSessionResponse");
+                return;
+        }
+
+        g_debug ("GsmDBusClient: got EndSessionResponse is-ok:%d reason=%s", is_ok, reason);
+
+        /* make sure it is from our client */
+        sender = dbus_message_get_sender (message);
+        if (sender == NULL
+            || IS_STRING_EMPTY (client->bus_name)
+            || strcmp (sender, client->bus_name) != 0) {
+
+                raise_error (client->connection,
+                             message,
+                             DBUS_ERROR_FAILED,
+                             "Caller not recognized as the client");
+                return;
+        }
+
+        reply = dbus_message_new_method_return (message);
+        if (reply == NULL) {
+                g_error ("No memory");
+        }
+
+        gsm_client_end_session_response (GSM_CLIENT (client),
+                                         is_ok, FALSE, FALSE, reason);
+
+        if (! dbus_connection_send (client->connection, reply, NULL)) {
+                g_error ("No memory");
+        }
+
+        dbus_message_unref (reply);
+}
+
+static DBusHandlerResult
+client_dbus_filter_function (DBusConnection *connection,
+                             DBusMessage    *message,
+                             void           *user_data)
+{
+        GsmDBusClient *client = GSM_DBUS_CLIENT (user_data);
+        const char    *path;
+
+        g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+        g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
+
+        path = dbus_message_get_path (message);
+
+        g_debug ("GsmDBusClient: obj_path=%s interface=%s method=%s",
+                 dbus_message_get_path (message),
+                 dbus_message_get_interface (message),
+                 dbus_message_get_member (message));
+
+        if (dbus_message_is_method_call (message, SM_DBUS_CLIENT_PRIVATE_INTERFACE, "EndSessionResponse")) {
+                g_assert (gsm_client_peek_id (GSM_CLIENT (client)) != NULL);
+
+                if (path != NULL && strcmp (path, gsm_client_peek_id (GSM_CLIENT (client))) != 0) {
+                        /* Different object path */
+                        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                }
+                handle_end_session_response (client, message);
+                return DBUS_HANDLER_RESULT_HANDLED;
+        }
+
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static GObject *
+gsm_dbus_client_constructor (GType                  type,
+                             guint                  n_construct_properties,
+                             GObjectConstructParam *construct_properties)
+{
+        GsmDBusClient *client;
+
+        client = GSM_DBUS_CLIENT (G_OBJECT_CLASS (gsm_dbus_client_parent_class)->constructor (type,
+                                                                                              n_construct_properties,
+                                                                                              construct_properties));
+
+        if (! setup_connection (client)) {
+                g_object_unref (client);
+                return NULL;
+        }
+
+        /* Object path is already registered by base class */
+        dbus_connection_add_filter (client->connection, client_dbus_filter_function, client, NULL);
+
+        return G_OBJECT (client);
+}
+
+static void
+gsm_dbus_client_init (GsmDBusClient *client)
+{
+}
+
+/* adapted from PolicyKit */
+static gboolean
+get_caller_info (GsmDBusClient *client,
+                 const char    *sender,
+                 uid_t         *calling_uid,
+                 pid_t         *calling_pid)
+{
+        gboolean         res;
+        GError          *error;
+        DBusGConnection *connection;
+        DBusGProxy      *bus_proxy;
+
+        res = FALSE;
+        bus_proxy = NULL;
+
+        if (sender == NULL) {
+                goto out;
+        }
+
+        error = NULL;
+        connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (connection == NULL) {
+                if (error != NULL) {
+                        g_warning ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                goto out;
+        }
+
+        bus_proxy = dbus_g_proxy_new_for_name (connection,
+                                               DBUS_SERVICE_DBUS,
+                                               DBUS_PATH_DBUS,
+                                               DBUS_INTERFACE_DBUS);
+
+        error = NULL;
+        if (! dbus_g_proxy_call (bus_proxy, "GetConnectionUnixUser", &error,
+                                 G_TYPE_STRING, sender,
+                                 G_TYPE_INVALID,
+                                 G_TYPE_UINT, calling_uid,
+                                 G_TYPE_INVALID)) {
+                g_debug ("GetConnectionUnixUser() failed: %s", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        error = NULL;
+        if (! dbus_g_proxy_call (bus_proxy, "GetConnectionUnixProcessID", &error,
+                                 G_TYPE_STRING, sender,
+                                 G_TYPE_INVALID,
+                                 G_TYPE_UINT, calling_pid,
+                                 G_TYPE_INVALID)) {
+                g_debug ("GetConnectionUnixProcessID() failed: %s", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        res = TRUE;
+
+        g_debug ("uid = %d", *calling_uid);
+        g_debug ("pid = %d", *calling_pid);
+
+out:
+        if (bus_proxy != NULL) {
+                g_object_unref (bus_proxy);
+        }
+        return res;
+}
+
+static void
+gsm_dbus_client_set_bus_name (GsmDBusClient  *client,
+                              const char     *bus_name)
+{
+        uid_t    uid;
+        pid_t    pid;
+
+        g_return_if_fail (GSM_IS_DBUS_CLIENT (client));
+
+        g_free (client->bus_name);
+
+        client->bus_name = g_strdup (bus_name);
+        g_object_notify (G_OBJECT (client), "bus-name");
+
+        if (client->bus_name != NULL) {
+                gboolean res;
+
+                res = get_caller_info (client, bus_name, &uid, &pid);
+                if (! res) {
+                        pid = 0;
+                }
+        } else {
+                pid = 0;
+        }
+        client->caller_pid = pid;
+}
+
+const char *
+gsm_dbus_client_get_bus_name (GsmDBusClient  *client)
+{
+        g_return_val_if_fail (GSM_IS_DBUS_CLIENT (client), NULL);
+
+        return client->bus_name;
+}
+
+static void
+gsm_dbus_client_set_property (GObject       *object,
+                              guint          prop_id,
+                              const GValue  *value,
+                              GParamSpec    *pspec)
+{
+        GsmDBusClient *self;
+
+        self = GSM_DBUS_CLIENT (object);
+
+        switch (prop_id) {
+        case PROP_BUS_NAME:
+                gsm_dbus_client_set_bus_name (self, g_value_get_string (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_dbus_client_get_property (GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+        GsmDBusClient *self;
+
+        self = GSM_DBUS_CLIENT (object);
+
+        switch (prop_id) {
+        case PROP_BUS_NAME:
+                g_value_set_string (value, self->bus_name);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_dbus_client_finalize (GObject *object)
+{
+        GsmDBusClient *client = (GsmDBusClient *) object;
+
+        g_free (client->bus_name);
+
+        G_OBJECT_CLASS (gsm_dbus_client_parent_class)->finalize (object);
+}
+
+static GKeyFile *
+dbus_client_save (GsmClient *client,
+                  GError   **error)
+{
+        g_debug ("GsmDBusClient: saving client with id %s",
+                 gsm_client_peek_id (client));
+
+        /* FIXME: We still don't support client saving for D-Bus
+         * session clients */
+
+        return NULL;
+}
+
+static gboolean
+dbus_client_stop (GsmClient *client,
+                  GError   **error)
+{
+        GsmDBusClient  *dbus_client = (GsmDBusClient *) client;
+        DBusMessage    *message;
+        gboolean        ret;
+
+        ret = FALSE;
+
+        /* unicast the signal to only the registered bus name */
+        message = dbus_message_new_signal (gsm_client_peek_id (client),
+                                           SM_DBUS_CLIENT_PRIVATE_INTERFACE,
+                                           "Stop");
+        if (message == NULL) {
+                goto out;
+        }
+        if (!dbus_message_set_destination (message, dbus_client->bus_name)) {
+                goto out;
+        }
+
+        if (!dbus_connection_send (dbus_client->connection, message, NULL)) {
+                goto out;
+        }
+
+        ret = TRUE;
+
+ out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+
+        return ret;
+}
+
+static char *
+dbus_client_get_app_name (GsmClient *client)
+{
+        /* Always use app-id instead */
+        return NULL;
+}
+
+static GsmClientRestartStyle
+dbus_client_get_restart_style_hint (GsmClient *client)
+{
+        return (GSM_DBUS_CLIENT (client)->restart_style_hint);
+}
+
+static guint
+dbus_client_get_unix_process_id (GsmClient *client)
+{
+        return (GSM_DBUS_CLIENT (client)->caller_pid);
+}
+
+static gboolean
+dbus_client_query_end_session (GsmClient *client,
+                               guint      flags,
+                               GError   **error)
+{
+        GsmDBusClient  *dbus_client = (GsmDBusClient *) client;
+        DBusMessage    *message;
+        DBusMessageIter iter;
+        gboolean        ret;
+
+        ret = FALSE;
+
+        if (dbus_client->bus_name == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Client is not registered");
+                return FALSE;
+        }
+
+        g_debug ("GsmDBusClient: sending QueryEndSession signal to %s", dbus_client->bus_name);
+
+        /* unicast the signal to only the registered bus name */
+        message = dbus_message_new_signal (gsm_client_peek_id (client),
+                                           SM_DBUS_CLIENT_PRIVATE_INTERFACE,
+                                           "QueryEndSession");
+        if (message == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send QueryEndSession message");
+                goto out;
+        }
+        if (!dbus_message_set_destination (message, dbus_client->bus_name)) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send QueryEndSession message");
+                goto out;
+        }
+
+        dbus_message_iter_init_append (message, &iter);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
+
+        if (!dbus_connection_send (dbus_client->connection, message, NULL)) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send QueryEndSession message");
+                goto out;
+        }
+
+        ret = TRUE;
+
+ out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+
+        return ret;
+}
+
+static gboolean
+dbus_client_end_session (GsmClient *client,
+                         guint      flags,
+                         GError   **error)
+{
+        GsmDBusClient  *dbus_client = (GsmDBusClient *) client;
+        DBusMessage    *message;
+        DBusMessageIter iter;
+        gboolean        ret;
+
+        ret = FALSE;
+
+        /* unicast the signal to only the registered bus name */
+        message = dbus_message_new_signal (gsm_client_peek_id (client),
+                                           SM_DBUS_CLIENT_PRIVATE_INTERFACE,
+                                           "EndSession");
+        if (message == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send EndSession message");
+                goto out;
+        }
+        if (!dbus_message_set_destination (message, dbus_client->bus_name)) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send EndSession message");
+                goto out;
+        }
+
+        dbus_message_iter_init_append (message, &iter);
+        dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &flags);
+
+        if (!dbus_connection_send (dbus_client->connection, message, NULL)) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send EndSession message");
+                goto out;
+        }
+
+        ret = TRUE;
+
+ out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+        return ret;
+}
+
+static gboolean
+dbus_client_cancel_end_session (GsmClient *client,
+                                GError   **error)
+{
+        GsmDBusClient  *dbus_client = (GsmDBusClient *) client;
+        DBusMessage    *message;
+        gboolean        ret = FALSE;
+
+        /* unicast the signal to only the registered bus name */
+        message = dbus_message_new_signal (gsm_client_peek_id (client),
+                                           SM_DBUS_CLIENT_PRIVATE_INTERFACE,
+                                           "CancelEndSession");
+        if (message == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send CancelEndSession message");
+                goto out;
+        }
+        if (!dbus_message_set_destination (message, dbus_client->bus_name)) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send CancelEndSession message");
+                goto out;
+        }
+
+        if (!dbus_connection_send (dbus_client->connection, message, NULL)) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Unable to send CancelEndSession message");
+                goto out;
+        }
+
+        ret = TRUE;
+
+ out:
+        if (message != NULL) {
+                dbus_message_unref (message);
+        }
+
+        return ret;
+}
+
+static void
+gsm_dbus_client_dispose (GObject *object)
+{
+        GsmDBusClient *client;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_DBUS_CLIENT (object));
+
+        client = GSM_DBUS_CLIENT (object);
+
+        dbus_connection_remove_filter (client->connection, client_dbus_filter_function, client);
+
+        G_OBJECT_CLASS (gsm_dbus_client_parent_class)->dispose (object);
+}
+
+static void
+gsm_dbus_client_class_init (GsmDBusClientClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+        GsmClientClass *client_class = GSM_CLIENT_CLASS (klass);
+
+        object_class->finalize             = gsm_dbus_client_finalize;
+        object_class->constructor          = gsm_dbus_client_constructor;
+        object_class->get_property         = gsm_dbus_client_get_property;
+        object_class->set_property         = gsm_dbus_client_set_property;
+        object_class->dispose              = gsm_dbus_client_dispose;
+
+        client_class->impl_save                   = dbus_client_save;
+        client_class->impl_stop                   = dbus_client_stop;
+        client_class->impl_query_end_session      = dbus_client_query_end_session;
+        client_class->impl_end_session            = dbus_client_end_session;
+        client_class->impl_cancel_end_session     = dbus_client_cancel_end_session;
+        client_class->impl_get_app_name           = dbus_client_get_app_name;
+        client_class->impl_get_restart_style_hint = dbus_client_get_restart_style_hint;
+        client_class->impl_get_unix_process_id    = dbus_client_get_unix_process_id;
+
+        g_object_class_install_property (object_class,
+                                         PROP_BUS_NAME,
+                                         g_param_spec_string ("bus-name",
+                                                              "bus-name",
+                                                              "bus-name",
+                                                              NULL,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+GsmClient *
+gsm_dbus_client_new (const char *startup_id,
+                     const char *bus_name)
+{
+        GsmDBusClient *client;
+
+        client = g_object_new (GSM_TYPE_DBUS_CLIENT,
+                               "startup-id", startup_id,
+                               "bus-name", bus_name,
+                               NULL);
+
+        return GSM_CLIENT (client);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/3.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/3.html new file mode 100644 index 0000000..4773606 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/3.html @@ -0,0 +1,315 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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_PROPERTIES_DIALOG_H
+#define __GSM_PROPERTIES_DIALOG_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_PROPERTIES_DIALOG         (gsm_properties_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (GsmPropertiesDialog, gsm_properties_dialog, GSM, PROPERTIES_DIALOG, GtkDialog)
+
+GtkWidget            * gsm_properties_dialog_new                (void);
+
+#define GSM_PROPERTIES_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR
+
+G_END_DECLS
+
+#endif /* __GSM_PROPERTIES_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/30.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/30.html new file mode 100644 index 0000000..b554b88 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/30.html @@ -0,0 +1,2499 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <cairo-xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-inhibit-dialog.h"
+#include "gsm-store.h"
+#include "gsm-client.h"
+#include "gsm-inhibitor.h"
+#include "eggdesktopfile.h"<--- Include file: "eggdesktopfile.h" not found.
+#include "gsm-util.h"
+
+#ifdef HAVE_XRENDER
+#include <X11/extensions/Xrender.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#define GTKBUILDER_FILE "gsm-inhibit-dialog.ui"
+
+#ifndef DEFAULT_ICON_SIZE
+#define DEFAULT_ICON_SIZE 32
+#endif
+
+#ifndef DEFAULT_SNAPSHOT_SIZE
+#define DEFAULT_SNAPSHOT_SIZE 128
+#endif
+
+#define DIALOG_RESPONSE_LOCK_SCREEN 1
+
+struct _GsmInhibitDialog
+{
+        GtkDialog          parent;
+        GtkBuilder        *xml;
+        int                action;
+        gboolean           is_done;
+        GsmStore          *inhibitors;
+        GsmStore          *clients;
+        GtkListStore      *list_store;
+        gboolean           have_xrender;
+        int                xrender_event_base;
+        int                xrender_error_base;
+};
+
+enum {
+        PROP_0,
+        PROP_ACTION,
+        PROP_INHIBITOR_STORE,
+        PROP_CLIENT_STORE
+};
+
+enum {
+        INHIBIT_IMAGE_COLUMN = 0,
+        INHIBIT_NAME_COLUMN,
+        INHIBIT_REASON_COLUMN,
+        INHIBIT_ID_COLUMN,
+        NUMBER_OF_COLUMNS
+};
+
+static void     gsm_inhibit_dialog_finalize    (GObject               *object);
+
+G_DEFINE_TYPE (GsmInhibitDialog, gsm_inhibit_dialog, GTK_TYPE_DIALOG)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void
+lock_screen (GsmInhibitDialog *dialog)
+{
+        gchar **screen_locker_command;
+
+        if ((screen_locker_command = gsm_get_screen_locker_command ()) != NULL) {
+                GError *error = NULL;
+
+                g_spawn_async (NULL, screen_locker_command, NULL,
+                               G_SPAWN_DEFAULT | G_SPAWN_SEARCH_PATH,
+                               NULL, NULL, NULL, &error);
+
+                if (error != NULL) {
+                        g_warning ("Couldn't lock screen: %s", error->message);
+                        g_error_free (error);
+                }
+
+        } else {
+                g_warning ("Couldn't find any screen locker");
+        }
+
+        g_strfreev (screen_locker_command);
+}
+
+static void
+on_response (GsmInhibitDialog *dialog,
+             gint              response_id)
+
+{
+        if (dialog->is_done) {
+                g_signal_stop_emission_by_name (dialog, "response");
+                return;
+        }
+
+        switch (response_id) {
+        case DIALOG_RESPONSE_LOCK_SCREEN:
+                g_signal_stop_emission_by_name (dialog, "response");
+                lock_screen (dialog);
+                break;
+        default:
+                dialog->is_done = TRUE;
+                break;
+        }
+}
+
+static void
+gsm_inhibit_dialog_set_action (GsmInhibitDialog *dialog,
+                               int               action)
+{
+        dialog->action = action;
+}
+
+static gboolean
+find_inhibitor (GsmInhibitDialog *dialog,
+                const char       *id,
+                GtkTreeIter      *iter)
+{
+        GtkTreeModel *model;
+        gboolean      found_item;
+
+        g_assert (GSM_IS_INHIBIT_DIALOG (dialog));
+
+        found_item = FALSE;
+        model = GTK_TREE_MODEL (dialog->list_store);
+
+        if (!gtk_tree_model_get_iter_first (model, iter)) {
+                return FALSE;
+        }
+
+        do {
+                char *item_id;
+
+                gtk_tree_model_get (model,
+                                    iter,
+                                    INHIBIT_ID_COLUMN, &item_id,
+                                    -1);
+                if (item_id != NULL
+                    && id != NULL
+                    && strcmp (item_id, id) == 0) {
+                        found_item = TRUE;
+                }
+                g_free (item_id);
+        } while (!found_item && gtk_tree_model_iter_next (model, iter));
+
+        return found_item;
+}
+
+/* copied from mate-panel panel-util.c */
+static char *
+_util_icon_remove_extension (const char *icon)
+{
+        char *icon_no_extension;
+        char *p;
+
+        icon_no_extension = g_strdup (icon);
+        p = strrchr (icon_no_extension, '.');
+        if (p &&
+            (strcmp (p, ".png") == 0 ||
+             strcmp (p, ".xpm") == 0 ||
+             strcmp (p, ".svg") == 0)) {
+            *p = 0;
+        }
+
+        return icon_no_extension;
+}
+
+/* copied from mate-panel panel-util.c */
+static char *
+_find_icon (GtkIconTheme  *icon_theme,
+            const char    *icon_name,
+            gint           size)
+{
+        GtkIconInfo *info;
+        char        *retval;
+        char        *icon_no_extension;
+
+        if (icon_name == NULL || strcmp (icon_name, "") == 0)
+                return NULL;
+
+        if (g_path_is_absolute (icon_name)) {
+                if (g_file_test (icon_name, G_FILE_TEST_EXISTS)) {
+                        return g_strdup (icon_name);
+                } else {
+                        char *basename;
+
+                        basename = g_path_get_basename (icon_name);
+                        retval = _find_icon (icon_theme, basename,
+                                             size);
+                        g_free (basename);
+
+                        return retval;
+                }
+        }
+
+        /* This is needed because some .desktop files have an icon name *and*
+         * an extension as icon */
+        icon_no_extension = _util_icon_remove_extension (icon_name);
+
+        info = gtk_icon_theme_lookup_icon (icon_theme, icon_no_extension,
+                                           size, 0);
+
+        g_free (icon_no_extension);
+
+        if (info) {
+                retval = g_strdup (gtk_icon_info_get_filename (info));
+                g_object_unref (info);
+        } else
+                retval = NULL;
+
+        return retval;
+}
+
+/* copied from mate-panel panel-util.c */
+static GdkPixbuf *
+_load_icon (GtkIconTheme  *icon_theme,
+            const char    *icon_name,
+            int            size,
+            int            desired_width,
+            int            desired_height,
+            char         **error_msg)
+{
+        GdkPixbuf *retval;
+        char      *file;
+        GError    *error;
+
+        g_return_val_if_fail (error_msg == NULL || *error_msg == NULL, NULL);
+
+        file = _find_icon (icon_theme, icon_name, size);
+        if (!file) {
+                if (error_msg)
+                        *error_msg = g_strdup_printf (_("Icon '%s' not found"),
+                                                      icon_name);
+
+                return NULL;
+        }
+
+        error = NULL;
+        retval = gdk_pixbuf_new_from_file_at_size (file,
+                                                   desired_width,
+                                                   desired_height,
+                                                   &error);
+        if (error) {
+                if (error_msg)
+                        *error_msg = g_strdup (error->message);
+                g_error_free (error);
+        }
+
+        g_free (file);
+
+        return retval;
+}
+
+static GdkPixbuf *
+scale_pixbuf (GdkPixbuf *pixbuf,
+              int        max_width,
+              int        max_height,
+              gboolean   no_stretch_hint)
+{
+        int        pw;
+        int        ph;
+        float      scale_factor_x = 1.0;
+        float      scale_factor_y = 1.0;
+        float      scale_factor = 1.0;
+
+        pw = gdk_pixbuf_get_width (pixbuf);
+        ph = gdk_pixbuf_get_height (pixbuf);
+
+        /* Determine which dimension requires the smallest scale. */
+        scale_factor_x = (float) max_width / (float) pw;
+        scale_factor_y = (float) max_height / (float) ph;
+
+        if (scale_factor_x > scale_factor_y) {
+                scale_factor = scale_factor_y;
+        } else {
+                scale_factor = scale_factor_x;
+        }
+
+        /* always scale down, allow to disable scaling up */
+        if (scale_factor < 1.0 || !no_stretch_hint) {
+                int scale_x = (int) (scale_factor * (float) pw);
+                int scale_y = (int) (scale_factor * (float) ph);
+                g_debug ("Scaling to %dx%d", scale_x, scale_y);
+                return gdk_pixbuf_scale_simple (pixbuf,
+                                                scale_x,
+                                                scale_y,
+                                                GDK_INTERP_BILINEAR);
+        } else {
+                return g_object_ref (pixbuf);
+        }
+}
+
+#ifdef HAVE_XRENDER
+static GdkPixbuf *
+pixbuf_get_from_pixmap (Display *display,
+                        Pixmap xpixmap,
+                        int width,
+                        int height)
+{
+        GdkPixbuf   *retval;
+        cairo_surface_t *surface;
+        Visual *visual;
+        retval = NULL;
+
+        g_debug ("GsmInhibitDialog: getting foreign pixmap for %u", (guint)xpixmap);
+
+        visual = DefaultVisual (display, 0);
+        surface = cairo_xlib_surface_create (display,
+                                             xpixmap,
+                                             visual,
+                                             width,
+                                             height);
+        if (surface != NULL) {
+                g_debug ("GsmInhibitDialog: getting pixbuf w=%d h=%d", width, height);
+                retval = gdk_pixbuf_get_from_surface (surface,
+                                                      0, 0,
+                                                      width, height);
+                cairo_surface_destroy (surface);
+        }
+
+        return retval;
+}
+
+static Pixmap
+get_pixmap_for_window (Display *display,
+                       Window window,
+                       int *widthp,
+                       int *heightp)
+{
+        XWindowAttributes        attr;
+        XRenderPictureAttributes pa;
+        Pixmap                   pixmap;
+        XRenderPictFormat       *format;
+        Picture                  src_picture;
+        Picture                  dst_picture;
+        gboolean                 has_alpha;
+        int                      width;
+        int                      height;
+
+        XGetWindowAttributes (display, window, &attr);
+
+        format = XRenderFindVisualFormat (display, attr.visual);
+        has_alpha = (format->type == PictTypeDirect && format->direct.alphaMask);
+        width = attr.width;
+        height = attr.height;
+
+        pa.subwindow_mode = IncludeInferiors; /* Don't clip child widgets */
+
+        src_picture = XRenderCreatePicture (display, window, format, CPSubwindowMode, &pa);
+
+        pixmap = XCreatePixmap (display,
+                                window,
+                                width, height,
+                                attr.depth);
+
+        dst_picture = XRenderCreatePicture (display, pixmap, format, 0, 0);
+        XRenderComposite (display,
+                          has_alpha ? PictOpOver : PictOpSrc,
+                          src_picture,
+                          None,
+                          dst_picture,
+                          0, 0, 0, 0,
+                          0, 0,
+                          width, height);
+
+        if (widthp != NULL) {
+                *widthp = width;
+        }
+        if (heightp != NULL) {
+                *heightp = height;
+        }
+
+        return pixmap;
+}
+
+#endif /* HAVE_COMPOSITE */
+
+static GdkPixbuf *
+get_pixbuf_for_window (GdkDisplay *gdkdisplay,
+                       guint xid,
+                       int thumb_width,
+                       int thumb_height)
+{
+        GdkPixbuf *pixbuf = NULL;
+#ifdef HAVE_XRENDER
+        Display   *display;
+        Window     xwindow;
+        Pixmap     xpixmap;
+        int width;
+        int height;
+
+        display = GDK_DISPLAY_XDISPLAY (gdkdisplay);
+        xwindow = (Window) xid;
+        xpixmap = get_pixmap_for_window (display, xwindow, &width, &height);
+        if (xpixmap == None) {
+                g_debug ("GsmInhibitDialog: Unable to get window snapshot for %u", xid);
+                return NULL;
+        } else {
+                g_debug ("GsmInhibitDialog: Got xpixmap %u", (guint)xpixmap);
+        }
+
+        pixbuf = pixbuf_get_from_pixmap (display, xpixmap, width, height);
+
+        if (xpixmap != None) {
+                gdk_x11_display_error_trap_push (gdkdisplay);
+                XFreePixmap (display, xpixmap);
+                gdk_display_sync (gdkdisplay);
+                gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+        }
+
+        if (pixbuf != NULL) {
+                GdkPixbuf *scaled;
+                g_debug ("GsmInhibitDialog: scaling pixbuf to w=%d h=%d", width, height);
+                scaled = scale_pixbuf (pixbuf, thumb_width, thumb_height, TRUE);
+                g_object_unref (pixbuf);
+                pixbuf = scaled;
+        }
+#else
+        g_debug ("GsmInhibitDialog: no support for getting window snapshot");
+#endif
+        return pixbuf;
+}
+
+static void
+add_inhibitor (GsmInhibitDialog *dialog,
+               GsmInhibitor     *inhibitor)
+{
+        GdkDisplay     *gdkdisplay;
+        const char     *name;
+        const char     *icon_name;
+        const char     *app_id;
+        char           *desktop_filename;
+        GdkPixbuf      *pixbuf;
+        EggDesktopFile *desktop_file;
+        GError         *error;
+        char          **search_dirs;
+        guint           xid;
+        char           *freeme;
+
+        gdkdisplay = gtk_widget_get_display (GTK_WIDGET (dialog));
+
+        /* FIXME: get info from xid */
+
+        desktop_file = NULL;
+        name = NULL;
+        pixbuf = NULL;
+        freeme = NULL;
+
+        app_id = gsm_inhibitor_peek_app_id (inhibitor);
+
+        if (IS_STRING_EMPTY (app_id)) {
+                desktop_filename = NULL;
+        } else if (! g_str_has_suffix (app_id, ".desktop")) {
+                desktop_filename = g_strdup_printf ("%s.desktop", app_id);
+        } else {
+                desktop_filename = g_strdup (app_id);
+        }
+
+        xid = gsm_inhibitor_peek_toplevel_xid (inhibitor);
+        g_debug ("GsmInhibitDialog: inhibitor has XID %u", xid);
+        if (xid > 0 && dialog->have_xrender) {
+                pixbuf = get_pixbuf_for_window (gdkdisplay, xid, DEFAULT_SNAPSHOT_SIZE, DEFAULT_SNAPSHOT_SIZE);
+                if (pixbuf == NULL) {
+                        g_debug ("GsmInhibitDialog: unable to read pixbuf from %u", xid);
+                }
+        }
+
+        if (desktop_filename != NULL) {
+                search_dirs = gsm_util_get_desktop_dirs ();
+
+                if (g_path_is_absolute (desktop_filename)) {
+                        char *basename;
+
+                        error = NULL;
+                        desktop_file = egg_desktop_file_new (desktop_filename,
+                                                             &error);
+                        if (desktop_file == NULL) {
+                                if (error) {
+                                        g_warning ("Unable to load desktop file '%s': %s",
+                                                   desktop_filename, error->message);
+                                        g_error_free (error);
+                                } else {
+                                        g_warning ("Unable to load desktop file '%s'",
+                                                   desktop_filename);
+                                }
+
+                                basename = g_path_get_basename (desktop_filename);
+                                g_free (desktop_filename);
+                                desktop_filename = basename;
+                        }
+                }
+
+                if (desktop_file == NULL) {
+                        error = NULL;
+                        desktop_file = egg_desktop_file_new_from_dirs (desktop_filename,
+                                                                       (const char **)search_dirs,
+                                                                       &error);
+                }
+
+                /* look for a file with a vendor prefix */
+                if (desktop_file == NULL) {
+                        if (error) {
+                                g_warning ("Unable to find desktop file '%s': %s",
+                                           desktop_filename, error->message);
+                                g_error_free (error);
+                        } else {
+                                g_warning ("Unable to find desktop file '%s'",
+                                           desktop_filename);
+                        }
+                        g_free (desktop_filename);
+                        desktop_filename = g_strdup_printf ("mate-%s.desktop", app_id);
+                        error = NULL;
+                        desktop_file = egg_desktop_file_new_from_dirs (desktop_filename,
+                                                                       (const char **)search_dirs,
+                                                                       &error);
+                }
+                g_strfreev (search_dirs);
+
+                if (desktop_file == NULL) {
+                        if (error) {
+                                g_warning ("Unable to find desktop file '%s': %s",
+                                           desktop_filename, error->message);
+                                g_error_free (error);
+                        } else {
+                                g_warning ("Unable to find desktop file '%s'",
+                                           desktop_filename);
+                        }
+                } else {
+                        name = egg_desktop_file_get_name (desktop_file);
+                        icon_name = egg_desktop_file_get_icon (desktop_file);
+
+                        if (pixbuf == NULL) {
+                                pixbuf = _load_icon (gtk_icon_theme_get_default (),
+                                                     icon_name,
+                                                     DEFAULT_ICON_SIZE,
+                                                     DEFAULT_ICON_SIZE,
+                                                     DEFAULT_ICON_SIZE,
+                                                     NULL);
+                        }
+                }
+        }
+
+        /* try client info */
+        if (name == NULL) {
+                const char *client_id;
+                client_id = gsm_inhibitor_peek_client_id (inhibitor);
+                if (! IS_STRING_EMPTY (client_id)) {
+                        GsmClient *client;
+                        client = GSM_CLIENT (gsm_store_lookup (dialog->clients, client_id));
+                        if (client != NULL) {
+                                freeme = gsm_client_get_app_name (client);
+                                name = freeme;
+                        }
+                }
+        }
+
+        if (name == NULL) {
+                if (! IS_STRING_EMPTY (app_id)) {
+                        name = app_id;
+                } else {
+                        name = _("Unknown");
+                }
+        }
+
+        if (pixbuf == NULL) {
+                pixbuf = _load_icon (gtk_icon_theme_get_default (),
+                                     "mate-windows",
+                                     DEFAULT_ICON_SIZE,
+                                     DEFAULT_ICON_SIZE,
+                                     DEFAULT_ICON_SIZE,
+                                     NULL);
+        }
+
+        gtk_list_store_insert_with_values (dialog->list_store,
+                                           NULL, 0,
+                                           INHIBIT_IMAGE_COLUMN, pixbuf,
+                                           INHIBIT_NAME_COLUMN, name,
+                                           INHIBIT_REASON_COLUMN, gsm_inhibitor_peek_reason (inhibitor),
+                                           INHIBIT_ID_COLUMN, gsm_inhibitor_peek_id (inhibitor),
+                                           -1);
+
+        g_free (desktop_filename);
+        g_free (freeme);
+        if (pixbuf != NULL) {
+                g_object_unref (pixbuf);
+        }
+        if (desktop_file != NULL) {
+                egg_desktop_file_free (desktop_file);
+        }
+}
+
+static gboolean
+model_has_one_entry (GtkTreeModel *model)
+{
+        guint n_rows;
+
+        n_rows = gtk_tree_model_iter_n_children (model, NULL);
+        g_debug ("Model has %d rows", n_rows);
+
+        return (n_rows > 0 && n_rows < 2);
+}
+
+static void
+update_dialog_text (GsmInhibitDialog *dialog)
+{
+        const char *description_text;
+        const char *header_text;
+        GtkWidget  *widget;
+
+        if (model_has_one_entry (GTK_TREE_MODEL (dialog->list_store))) {
+                g_debug ("Found one entry in model");
+                header_text = _("A program is still running:");
+                description_text = _("Waiting for the program to finish.  Interrupting the program may cause you to lose work.");
+        } else {
+                g_debug ("Found multiple entries (or none) in model");
+                header_text = _("Some programs are still running:");
+                description_text = _("Waiting for programs to finish.  Interrupting these programs may cause you to lose work.");
+        }
+
+        widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     "header-label"));
+        if (widget != NULL) {
+                char *markup;
+                markup = g_strdup_printf ("<b>%s</b>", header_text);
+                gtk_label_set_markup (GTK_LABEL (widget), markup);
+                g_free (markup);
+        }
+
+        widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     "description-label"));
+        if (widget != NULL) {
+                gtk_label_set_text (GTK_LABEL (widget), description_text);
+        }
+}
+
+static void
+on_store_inhibitor_added (GsmStore          *store,
+                          const char        *id,
+                          GsmInhibitDialog  *dialog)
+{
+        GsmInhibitor *inhibitor;
+        GtkTreeIter   iter;
+
+        g_debug ("GsmInhibitDialog: inhibitor added: %s", id);
+
+        if (dialog->is_done) {
+                return;
+        }
+
+        inhibitor = (GsmInhibitor *)gsm_store_lookup (store, id);
+
+        /* Add to model */
+        if (! find_inhibitor (dialog, id, &iter)) {
+                add_inhibitor (dialog, inhibitor);
+                update_dialog_text (dialog);
+        }
+
+}
+
+static void
+on_store_inhibitor_removed (GsmStore          *store,
+                            const char        *id,
+                            GsmInhibitDialog  *dialog)
+{
+        GtkTreeIter   iter;
+
+        g_debug ("GsmInhibitDialog: inhibitor removed: %s", id);
+
+        if (dialog->is_done) {
+                return;
+        }
+
+        /* Remove from model */
+        if (find_inhibitor (dialog, id, &iter)) {
+                gtk_list_store_remove (dialog->list_store, &iter);
+                update_dialog_text (dialog);
+        }
+
+        /* if there are no inhibitors left then trigger response */
+        if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->list_store), &iter)) {
+                gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+        }
+}
+
+static void
+gsm_inhibit_dialog_set_inhibitor_store (GsmInhibitDialog *dialog,
+                                        GsmStore         *store)
+{
+        g_return_if_fail (GSM_IS_INHIBIT_DIALOG (dialog));
+
+        if (store != NULL) {
+                g_object_ref (store);
+        }
+
+        if (dialog->inhibitors != NULL) {
+                g_signal_handlers_disconnect_by_func (dialog->inhibitors,
+                                                      on_store_inhibitor_added,
+                                                      dialog);
+                g_signal_handlers_disconnect_by_func (dialog->inhibitors,
+                                                      on_store_inhibitor_removed,
+                                                      dialog);
+
+                g_object_unref (dialog->inhibitors);
+        }
+
+        g_debug ("GsmInhibitDialog: setting store %p", store);
+
+        dialog->inhibitors = store;
+
+        if (dialog->inhibitors != NULL) {
+                g_signal_connect (dialog->inhibitors,
+                                  "added",
+                                  G_CALLBACK (on_store_inhibitor_added),
+                                  dialog);
+                g_signal_connect (dialog->inhibitors,
+                                  "removed",
+                                  G_CALLBACK (on_store_inhibitor_removed),
+                                  dialog);
+        }
+}
+
+static void
+gsm_inhibit_dialog_set_client_store (GsmInhibitDialog *dialog,
+                                     GsmStore         *store)
+{
+        g_return_if_fail (GSM_IS_INHIBIT_DIALOG (dialog));
+
+        if (store != NULL) {
+                g_object_ref (store);
+        }
+
+        if (dialog->clients != NULL) {
+                g_object_unref (dialog->clients);
+        }
+
+        dialog->clients = store;
+}
+
+static void
+gsm_inhibit_dialog_set_property (GObject        *object,
+                                 guint           prop_id,
+                                 const GValue   *value,
+                                 GParamSpec     *pspec)
+{
+        GsmInhibitDialog *dialog = GSM_INHIBIT_DIALOG (object);
+
+        switch (prop_id) {
+        case PROP_ACTION:
+                gsm_inhibit_dialog_set_action (dialog, g_value_get_int (value));
+                break;
+        case PROP_INHIBITOR_STORE:
+                gsm_inhibit_dialog_set_inhibitor_store (dialog, g_value_get_object (value));
+                break;
+        case PROP_CLIENT_STORE:
+                gsm_inhibit_dialog_set_client_store (dialog, g_value_get_object (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_inhibit_dialog_get_property (GObject        *object,
+                                 guint           prop_id,
+                                 GValue         *value,
+                                 GParamSpec     *pspec)
+{
+        GsmInhibitDialog *dialog = GSM_INHIBIT_DIALOG (object);
+
+        switch (prop_id) {
+        case PROP_ACTION:
+                g_value_set_int (value, dialog->action);
+                break;
+        case PROP_INHIBITOR_STORE:
+                g_value_set_object (value, dialog->inhibitors);
+                break;
+        case PROP_CLIENT_STORE:
+                g_value_set_object (value, dialog->clients);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+name_cell_data_func (GtkTreeViewColumn *tree_column,
+                     GtkCellRenderer   *cell,
+                     GtkTreeModel      *model,
+                     GtkTreeIter       *iter,
+                     GsmInhibitDialog  *dialog)
+{
+        char    *name;
+        char    *reason;
+        char    *markup;
+
+        name = NULL;
+        reason = NULL;
+        gtk_tree_model_get (model,
+                            iter,
+                            INHIBIT_NAME_COLUMN, &name,
+                            INHIBIT_REASON_COLUMN, &reason,
+                            -1);
+
+        markup = g_strdup_printf ("<b>%s</b>\n"
+                                  "<span size=\"small\">%s</span>",
+                                  name ? name : "(null)",
+                                  reason ? reason : "(null)");
+
+        g_free (name);
+        g_free (reason);
+
+        g_object_set (cell, "markup", markup, NULL);
+        g_free (markup);
+}
+
+static gboolean
+add_to_model (const char       *id,
+              GsmInhibitor     *inhibitor,
+              GsmInhibitDialog *dialog)
+{
+        add_inhibitor (dialog, inhibitor);
+        return FALSE;
+}
+
+static void
+populate_model (GsmInhibitDialog *dialog)
+{
+        gsm_store_foreach_remove (dialog->inhibitors,
+                                  (GsmStoreFunc)add_to_model,
+                                  dialog);
+        update_dialog_text (dialog);
+}
+
+static void
+setup_dialog (GsmInhibitDialog *dialog)
+{
+        const char        *button_text;
+        GtkWidget         *treeview;
+        GtkTreeViewColumn *column;
+        GtkCellRenderer   *renderer;
+
+        switch (dialog->action) {
+        case GSM_LOGOUT_ACTION_SWITCH_USER:
+                button_text = _("Switch User Anyway");
+                break;
+        case GSM_LOGOUT_ACTION_LOGOUT:
+                button_text = _("Log Out Anyway");
+                break;
+        case GSM_LOGOUT_ACTION_SLEEP:
+                button_text = _("Suspend Anyway");
+                break;
+        case GSM_LOGOUT_ACTION_HIBERNATE:
+                button_text = _("Hibernate Anyway");
+                break;
+        case GSM_LOGOUT_ACTION_SHUTDOWN:
+                button_text = _("Shut Down Anyway");
+                break;
+        case GSM_LOGOUT_ACTION_REBOOT:
+                button_text = _("Reboot Anyway");
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        gtk_dialog_add_button (GTK_DIALOG (dialog),
+                               _("Lock Screen"),
+                               DIALOG_RESPONSE_LOCK_SCREEN);
+        gtk_dialog_add_button (GTK_DIALOG (dialog),
+                               _("Cancel"),
+                               GTK_RESPONSE_CANCEL);
+        gtk_dialog_add_button (GTK_DIALOG (dialog),
+                               button_text,
+                               GTK_RESPONSE_ACCEPT);
+        g_signal_connect (dialog,
+                          "response",
+                          G_CALLBACK (on_response),
+                          dialog);
+
+        dialog->list_store = gtk_list_store_new (NUMBER_OF_COLUMNS,
+                                                 GDK_TYPE_PIXBUF,
+                                                 G_TYPE_STRING,
+                                                 G_TYPE_STRING,
+                                                 G_TYPE_STRING);
+
+        treeview = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                       "inhibitors-treeview"));
+        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+        gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+                                 GTK_TREE_MODEL (dialog->list_store));
+
+        /* IMAGE COLUMN */
+        renderer = gtk_cell_renderer_pixbuf_new ();
+        column = gtk_tree_view_column_new ();
+        gtk_tree_view_column_pack_start (column, renderer, FALSE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+        gtk_tree_view_column_set_attributes (column,
+                                             renderer,
+                                             "pixbuf", INHIBIT_IMAGE_COLUMN,
+                                             NULL);
+
+        g_object_set (renderer, "xalign", 1.0, NULL);
+
+        /* NAME COLUMN */
+        renderer = gtk_cell_renderer_text_new ();
+        column = gtk_tree_view_column_new ();
+        gtk_tree_view_column_pack_start (column, renderer, FALSE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+        gtk_tree_view_column_set_cell_data_func (column,
+                                                 renderer,
+                                                 (GtkTreeCellDataFunc) name_cell_data_func,
+                                                 dialog,
+                                                 NULL);
+
+        gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview),
+                                          INHIBIT_REASON_COLUMN);
+
+        populate_model (dialog);
+}
+
+static GObject *
+gsm_inhibit_dialog_constructor (GType                  type,
+                                guint                  n_construct_properties,
+                                GObjectConstructParam *construct_properties)
+{
+        GsmInhibitDialog *dialog;
+#ifdef HAVE_XRENDER
+        GdkDisplay *gdkdisplay;
+#endif /* HAVE_XRENDER */
+        dialog = GSM_INHIBIT_DIALOG (G_OBJECT_CLASS (gsm_inhibit_dialog_parent_class)->constructor (type,
+                                                                                                    n_construct_properties,
+                                                                                                    construct_properties));
+
+#ifdef HAVE_XRENDER
+        gdkdisplay = gdk_display_get_default ();
+        gdk_x11_display_error_trap_push (gdkdisplay);
+        if (XRenderQueryExtension (GDK_DISPLAY_XDISPLAY (gdkdisplay), &dialog->xrender_event_base, &dialog->xrender_error_base)) {
+                g_debug ("GsmInhibitDialog: Initialized XRender extension");
+                dialog->have_xrender = TRUE;
+        } else {
+                g_debug ("GsmInhibitDialog: Unable to initialize XRender extension");
+                dialog->have_xrender = FALSE;
+        }
+        gdk_display_sync (gdkdisplay);
+        gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+#endif /* HAVE_XRENDER */
+
+        /* FIXME: turn this on when it is ready */
+        dialog->have_xrender = FALSE;
+
+        setup_dialog (dialog);
+
+        gtk_widget_show_all (GTK_WIDGET (dialog));
+
+        return G_OBJECT (dialog);
+}
+
+static void
+gsm_inhibit_dialog_dispose (GObject *object)
+{
+        GsmInhibitDialog *dialog;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_INHIBIT_DIALOG (object));
+
+        dialog = GSM_INHIBIT_DIALOG (object);
+
+        g_debug ("GsmInhibitDialog: dispose called");
+
+        if (dialog->list_store != NULL) {
+                g_object_unref (dialog->list_store);
+                dialog->list_store = NULL;
+        }
+
+        if (dialog->inhibitors != NULL) {
+                g_signal_handlers_disconnect_by_func (dialog->inhibitors,
+                                                      on_store_inhibitor_added,
+                                                      dialog);
+                g_signal_handlers_disconnect_by_func (dialog->inhibitors,
+                                                      on_store_inhibitor_removed,
+                                                      dialog);
+
+                g_object_unref (dialog->inhibitors);
+                dialog->inhibitors = NULL;
+        }
+
+        if (dialog->xml != NULL) {
+                g_object_unref (dialog->xml);
+                dialog->xml = NULL;
+        }
+
+        G_OBJECT_CLASS (gsm_inhibit_dialog_parent_class)->dispose (object);
+}
+
+static void
+gsm_inhibit_dialog_class_init (GsmInhibitDialogClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsm_inhibit_dialog_get_property;
+        object_class->set_property = gsm_inhibit_dialog_set_property;
+        object_class->constructor = gsm_inhibit_dialog_constructor;
+        object_class->dispose = gsm_inhibit_dialog_dispose;
+        object_class->finalize = gsm_inhibit_dialog_finalize;
+
+        g_object_class_install_property (object_class,
+                                         PROP_ACTION,
+                                         g_param_spec_int ("action",
+                                                           "action",
+                                                           "action",
+                                                           -1,
+                                                           G_MAXINT,
+                                                           -1,
+                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_INHIBITOR_STORE,
+                                         g_param_spec_object ("inhibitor-store",
+                                                              NULL,
+                                                              NULL,
+                                                              GSM_TYPE_STORE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_CLIENT_STORE,
+                                         g_param_spec_object ("client-store",
+                                                              NULL,
+                                                              NULL,
+                                                              GSM_TYPE_STORE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+static void
+gsm_inhibit_dialog_init (GsmInhibitDialog *dialog)
+{
+        GtkWidget *content_area;
+        GtkWidget *widget;
+        GError    *error;
+
+        dialog->xml = gtk_builder_new ();
+        gtk_builder_set_translation_domain (dialog->xml, GETTEXT_PACKAGE);
+
+        error = NULL;
+        if (!gtk_builder_add_from_file (dialog->xml,
+                                        GTKBUILDER_DIR "/" GTKBUILDER_FILE,
+                                        &error)) {
+                if (error) {
+                        g_warning ("Could not load inhibitor UI file: %s",
+                                   error->message);
+                        g_error_free (error);
+                } else {
+                        g_warning ("Could not load inhibitor UI file.");
+                }
+        }
+
+        content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+        widget = GTK_WIDGET (gtk_builder_get_object (dialog->xml,
+                                                     "main-box"));
+        gtk_container_add (GTK_CONTAINER (content_area), widget);
+
+        gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
+        gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-log-out");
+        gtk_window_set_title (GTK_WINDOW (dialog), "");
+        g_object_set (dialog,
+                      "resizable", FALSE,
+                      NULL);
+}
+
+static void
+gsm_inhibit_dialog_finalize (GObject *object)
+{
+        GsmInhibitDialog *dialog;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_INHIBIT_DIALOG (object));
+
+        dialog = GSM_INHIBIT_DIALOG (object);
+
+        g_return_if_fail (dialog != NULL);
+
+        g_debug ("GsmInhibitDialog: finalizing");
+
+        G_OBJECT_CLASS (gsm_inhibit_dialog_parent_class)->finalize (object);
+}
+
+GtkWidget *
+gsm_inhibit_dialog_new (GsmStore *inhibitors,
+                        GsmStore *clients,
+                        int       action)
+{
+        GObject *object;
+
+        object = g_object_new (GSM_TYPE_INHIBIT_DIALOG,
+                               "action", action,
+                               "inhibitor-store", inhibitors,
+                               "client-store", clients,
+                               NULL);
+
+        return GTK_WIDGET (object);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/31.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/31.html new file mode 100644 index 0000000..8bf8a8a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/31.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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_INHIBIT_DIALOG_H
+#define __GSM_INHIBIT_DIALOG_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-store.h"
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_INHIBIT_DIALOG         (gsm_inhibit_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (GsmInhibitDialog, gsm_inhibit_dialog, GSM, INHIBIT_DIALOG, GtkDialog)
+
+typedef enum
+{
+        GSM_LOGOUT_ACTION_LOGOUT,
+        GSM_LOGOUT_ACTION_SWITCH_USER,
+        GSM_LOGOUT_ACTION_SHUTDOWN,
+        GSM_LOGOUT_ACTION_REBOOT,
+        GSM_LOGOUT_ACTION_HIBERNATE,
+        GSM_LOGOUT_ACTION_SLEEP
+} GsmLogoutAction;
+
+GtkWidget            * gsm_inhibit_dialog_new                (GsmStore         *inhibitors,
+                                                              GsmStore         *clients,
+                                                              int               action);
+GtkTreeModel         * gsm_inhibit_dialog_get_model          (GsmInhibitDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GSM_INHIBIT_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/32.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/32.html new file mode 100644 index 0000000..c513c0b --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/32.html @@ -0,0 +1,425 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_INHIBITOR_H__
+#define __GSM_INHIBITOR_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_INHIBITOR            (gsm_inhibitor_get_type ())
+#define GSM_INHIBITOR_ERROR           (gsm_inhibitor_error_quark ())
+#define GSM_INHIBITOR_TYPE_ERROR      (gsm_inhibitor_error_get_type ())
+G_DECLARE_FINAL_TYPE (GsmInhibitor, gsm_inhibitor, GSM, INHIBITOR, GObject)
+
+typedef enum {
+        GSM_INHIBITOR_FLAG_LOGOUT      = 1 << 0,
+        GSM_INHIBITOR_FLAG_SWITCH_USER = 1 << 1,
+        GSM_INHIBITOR_FLAG_SUSPEND     = 1 << 2,
+        GSM_INHIBITOR_FLAG_IDLE        = 1 << 3
+} GsmInhibitorFlag;
+
+typedef enum
+{
+        GSM_INHIBITOR_ERROR_GENERAL = 0,
+        GSM_INHIBITOR_ERROR_NOT_SET,
+        GSM_INHIBITOR_NUM_ERRORS
+} GsmInhibitorError;
+
+GType          gsm_inhibitor_error_get_type       (void);
+
+GQuark         gsm_inhibitor_error_quark          (void);
+
+GsmInhibitor * gsm_inhibitor_new                  (const char    *app_id,
+                                                   guint          toplevel_xid,
+                                                   guint          flags,
+                                                   const char    *reason,
+                                                   const char    *bus_name,
+                                                   guint          cookie);
+GsmInhibitor * gsm_inhibitor_new_for_client       (const char    *client_id,
+                                                   const char    *app_id,
+                                                   guint          flags,
+                                                   const char    *reason,
+                                                   const char    *bus_name,
+                                                   guint          cookie);
+
+const char *   gsm_inhibitor_peek_id              (GsmInhibitor  *inhibitor);
+const char *   gsm_inhibitor_peek_app_id          (GsmInhibitor  *inhibitor);
+const char *   gsm_inhibitor_peek_client_id       (GsmInhibitor  *inhibitor);
+const char *   gsm_inhibitor_peek_reason          (GsmInhibitor  *inhibitor);
+const char *   gsm_inhibitor_peek_bus_name        (GsmInhibitor  *inhibitor);
+guint          gsm_inhibitor_peek_cookie          (GsmInhibitor  *inhibitor);
+guint          gsm_inhibitor_peek_flags           (GsmInhibitor  *inhibitor);
+guint          gsm_inhibitor_peek_toplevel_xid    (GsmInhibitor  *inhibitor);
+
+/* exported to bus */
+gboolean       gsm_inhibitor_get_app_id           (GsmInhibitor  *inhibitor,
+                                                   char         **id,
+                                                   GError       **error);
+gboolean       gsm_inhibitor_get_client_id        (GsmInhibitor  *inhibitor,
+                                                   char         **id,
+                                                   GError       **error);
+gboolean       gsm_inhibitor_get_reason           (GsmInhibitor  *inhibitor,
+                                                   char         **reason,
+                                                   GError       **error);
+gboolean       gsm_inhibitor_get_flags            (GsmInhibitor  *inhibitor,
+                                                   guint         *flags,
+                                                   GError       **error);
+gboolean       gsm_inhibitor_get_toplevel_xid     (GsmInhibitor  *inhibitor,
+                                                   guint         *xid,
+                                                   GError       **error);
+
+G_END_DECLS
+
+#endif /* __GSM_INHIBITOR_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/33.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/33.html new file mode 100644 index 0000000..4820269 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/33.html @@ -0,0 +1,1441 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-inhibitor.h"
+#include "gsm-inhibitor-glue.h"
+#include "gsm-util.h"
+
+static guint32 inhibitor_serial = 1;
+
+struct _GsmInhibitor
+{
+        GObject parent;
+        char *id;
+        char *bus_name;
+        char *app_id;
+        char *client_id;
+        char *reason;
+        guint flags;
+        guint toplevel_xid;
+        guint cookie;
+        DBusGConnection *connection;
+};
+
+enum {
+        PROP_0,
+        PROP_BUS_NAME,
+        PROP_REASON,
+        PROP_APP_ID,
+        PROP_CLIENT_ID,
+        PROP_FLAGS,
+        PROP_TOPLEVEL_XID,
+        PROP_COOKIE
+};
+
+G_DEFINE_TYPE (GsmInhibitor, gsm_inhibitor, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+GQuark
+gsm_inhibitor_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_inhibitor_error");
+        }
+
+        return ret;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+gsm_inhibitor_error_get_type (void)
+{
+        static GType etype = 0;
+
+        if (etype == 0) {
+                static const GEnumValue values[] = {
+                        ENUM_ENTRY (GSM_INHIBITOR_ERROR_GENERAL, "GeneralError"),
+                        ENUM_ENTRY (GSM_INHIBITOR_ERROR_NOT_SET, "NotSet"),
+                        { 0, 0, 0 }
+                };
+
+                g_assert (GSM_INHIBITOR_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+
+                etype = g_enum_register_static ("GsmInhibitorError", values);
+        }
+
+        return etype;
+}
+
+static guint32
+get_next_inhibitor_serial (void)
+{
+        guint32 serial;
+
+        serial = inhibitor_serial++;
+
+        if ((gint32)inhibitor_serial < 0) {
+                inhibitor_serial = 1;
+        }
+
+        return serial;
+}
+
+static gboolean
+register_inhibitor (GsmInhibitor *inhibitor)
+{
+        GError *error;
+
+        error = NULL;
+        inhibitor->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (inhibitor->connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                return FALSE;
+        }
+
+        dbus_g_connection_register_g_object (inhibitor->connection, inhibitor->id, G_OBJECT (inhibitor));
+
+        return TRUE;
+}
+
+static GObject *
+gsm_inhibitor_constructor (GType                  type,
+                           guint                  n_construct_properties,
+                           GObjectConstructParam *construct_properties)
+{
+        GsmInhibitor *inhibitor;
+        gboolean      res;
+
+        inhibitor = GSM_INHIBITOR (G_OBJECT_CLASS (gsm_inhibitor_parent_class)->constructor (type,
+                                                                                             n_construct_properties,
+                                                                                             construct_properties));
+
+        g_free (inhibitor->id);
+        inhibitor->id = g_strdup_printf ("/org/gnome/SessionManager/Inhibitor%u", get_next_inhibitor_serial ());
+        res = register_inhibitor (inhibitor);
+        if (! res) {
+                g_warning ("Unable to register inhibitor with session bus");
+        }
+
+        return G_OBJECT (inhibitor);
+}
+
+static void
+gsm_inhibitor_init (GsmInhibitor *inhibitor)
+{
+}
+
+static void
+gsm_inhibitor_set_bus_name (GsmInhibitor  *inhibitor,
+                            const char    *bus_name)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        g_free (inhibitor->bus_name);
+
+        if (bus_name != NULL) {
+                inhibitor->bus_name = g_strdup (bus_name);
+        } else {
+                inhibitor->bus_name = g_strdup ("");
+        }
+        g_object_notify (G_OBJECT (inhibitor), "bus-name");
+}
+
+static void
+gsm_inhibitor_set_app_id (GsmInhibitor  *inhibitor,
+                          const char    *app_id)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        g_free (inhibitor->app_id);
+
+        inhibitor->app_id = g_strdup (app_id);
+        g_object_notify (G_OBJECT (inhibitor), "app-id");
+}
+
+static void
+gsm_inhibitor_set_client_id (GsmInhibitor  *inhibitor,
+                             const char    *client_id)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        g_free (inhibitor->client_id);
+
+        g_debug ("GsmInhibitor: setting client-id = %s", client_id);
+
+        if (client_id != NULL) {
+                inhibitor->client_id = g_strdup (client_id);
+        } else {
+                inhibitor->client_id = g_strdup ("");
+        }
+        g_object_notify (G_OBJECT (inhibitor), "client-id");
+}
+
+static void
+gsm_inhibitor_set_reason (GsmInhibitor  *inhibitor,
+                          const char    *reason)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        g_free (inhibitor->reason);
+
+        if (reason != NULL) {
+                inhibitor->reason = g_strdup (reason);
+        } else {
+                inhibitor->reason = g_strdup ("");
+        }
+        g_object_notify (G_OBJECT (inhibitor), "reason");
+}
+
+static void
+gsm_inhibitor_set_cookie (GsmInhibitor  *inhibitor,
+                          guint          cookie)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        if (inhibitor->cookie != cookie) {
+                inhibitor->cookie = cookie;
+                g_object_notify (G_OBJECT (inhibitor), "cookie");
+        }
+}
+
+static void
+gsm_inhibitor_set_flags (GsmInhibitor  *inhibitor,
+                         guint          flags)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        if (inhibitor->flags != flags) {
+                inhibitor->flags = flags;
+                g_object_notify (G_OBJECT (inhibitor), "flags");
+        }
+}
+
+static void
+gsm_inhibitor_set_toplevel_xid (GsmInhibitor  *inhibitor,
+                                guint          xid)
+{
+        g_return_if_fail (GSM_IS_INHIBITOR (inhibitor));
+
+        if (inhibitor->toplevel_xid != xid) {
+                inhibitor->toplevel_xid = xid;
+                g_object_notify (G_OBJECT (inhibitor), "toplevel-xid");
+        }
+}
+
+const char *
+gsm_inhibitor_peek_bus_name (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+        return inhibitor->bus_name;
+}
+
+gboolean
+gsm_inhibitor_get_app_id (GsmInhibitor *inhibitor,
+                          char        **id,
+                          GError      **error)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
+
+        if (inhibitor->app_id != NULL) {
+                *id = g_strdup (inhibitor->app_id);
+        } else {
+                *id = g_strdup ("");
+        }
+
+        return TRUE;
+}
+
+gboolean
+gsm_inhibitor_get_client_id (GsmInhibitor *inhibitor,
+                             char        **id,
+                             GError      **error)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
+
+        /* object paths are not allowed to be NULL or blank */
+        if (IS_STRING_EMPTY (inhibitor->client_id)) {
+                g_set_error (error,
+                             GSM_INHIBITOR_ERROR,
+                             GSM_INHIBITOR_ERROR_NOT_SET,
+                             "Value is not set");
+                return FALSE;
+        }
+
+        *id = g_strdup (inhibitor->client_id);
+
+        g_debug ("GsmInhibitor: getting client-id = '%s'", *id);
+
+        return TRUE;
+}
+
+gboolean
+gsm_inhibitor_get_reason (GsmInhibitor *inhibitor,
+                          char        **reason,
+                          GError      **error)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
+
+        if (inhibitor->reason != NULL) {
+                *reason = g_strdup (inhibitor->reason);
+        } else {
+                *reason = g_strdup ("");
+        }
+
+        return TRUE;
+}
+
+gboolean
+gsm_inhibitor_get_flags (GsmInhibitor *inhibitor,
+                         guint        *flags,
+                         GError      **error)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
+
+        *flags = inhibitor->flags;
+
+        return TRUE;
+}
+
+gboolean
+gsm_inhibitor_get_toplevel_xid (GsmInhibitor *inhibitor,
+                                guint        *xid,
+                                GError      **error)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), FALSE);
+
+        *xid = inhibitor->toplevel_xid;
+
+        return TRUE;
+}
+
+const char *
+gsm_inhibitor_peek_id (GsmInhibitor *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+        return inhibitor->id;
+}
+
+const char *
+gsm_inhibitor_peek_app_id (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+        return inhibitor->app_id;
+}
+
+const char *
+gsm_inhibitor_peek_client_id (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+        return inhibitor->client_id;
+}
+
+const char *
+gsm_inhibitor_peek_reason (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), NULL);
+
+        return inhibitor->reason;
+}
+
+guint
+gsm_inhibitor_peek_flags (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0);
+
+        return inhibitor->flags;
+}
+
+guint
+gsm_inhibitor_peek_toplevel_xid (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0);
+
+        return inhibitor->toplevel_xid;
+}
+
+guint
+gsm_inhibitor_peek_cookie (GsmInhibitor  *inhibitor)
+{
+        g_return_val_if_fail (GSM_IS_INHIBITOR (inhibitor), 0);
+
+        return inhibitor->cookie;
+}
+
+static void
+gsm_inhibitor_set_property (GObject       *object,
+                            guint          prop_id,
+                            const GValue  *value,
+                            GParamSpec    *pspec)
+{
+        GsmInhibitor *self;
+
+        self = GSM_INHIBITOR (object);
+
+        switch (prop_id) {
+        case PROP_BUS_NAME:
+                gsm_inhibitor_set_bus_name (self, g_value_get_string (value));
+                break;
+        case PROP_APP_ID:
+                gsm_inhibitor_set_app_id (self, g_value_get_string (value));
+                break;
+        case PROP_CLIENT_ID:
+                gsm_inhibitor_set_client_id (self, g_value_get_string (value));
+                break;
+        case PROP_REASON:
+                gsm_inhibitor_set_reason (self, g_value_get_string (value));
+                break;
+        case PROP_FLAGS:
+                gsm_inhibitor_set_flags (self, g_value_get_uint (value));
+                break;
+        case PROP_COOKIE:
+                gsm_inhibitor_set_cookie (self, g_value_get_uint (value));
+                break;
+        case PROP_TOPLEVEL_XID:
+                gsm_inhibitor_set_toplevel_xid (self, g_value_get_uint (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_inhibitor_get_property (GObject    *object,
+                            guint       prop_id,
+                            GValue     *value,
+                            GParamSpec *pspec)
+{
+        GsmInhibitor *self;
+
+        self = GSM_INHIBITOR (object);
+
+        switch (prop_id) {
+        case PROP_BUS_NAME:
+                g_value_set_string (value, self->bus_name);
+                break;
+        case PROP_APP_ID:
+                g_value_set_string (value, self->app_id);
+                break;
+        case PROP_CLIENT_ID:
+                g_value_set_string (value, self->client_id);
+                break;
+        case PROP_REASON:
+                g_value_set_string (value, self->reason);
+                break;
+        case PROP_FLAGS:
+                g_value_set_uint (value, self->flags);
+                break;
+        case PROP_COOKIE:
+                g_value_set_uint (value, self->cookie);
+                break;
+        case PROP_TOPLEVEL_XID:
+                g_value_set_uint (value, self->toplevel_xid);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_inhibitor_finalize (GObject *object)
+{
+        GsmInhibitor *inhibitor = (GsmInhibitor *) object;
+
+        g_free (inhibitor->id);
+        g_free (inhibitor->bus_name);
+        g_free (inhibitor->app_id);
+        g_free (inhibitor->client_id);
+        g_free (inhibitor->reason);
+
+        G_OBJECT_CLASS (gsm_inhibitor_parent_class)->finalize (object);
+}
+
+static void
+gsm_inhibitor_class_init (GsmInhibitorClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize             = gsm_inhibitor_finalize;
+        object_class->constructor          = gsm_inhibitor_constructor;
+        object_class->get_property         = gsm_inhibitor_get_property;
+        object_class->set_property         = gsm_inhibitor_set_property;
+
+        g_object_class_install_property (object_class,
+                                         PROP_BUS_NAME,
+                                         g_param_spec_string ("bus-name",
+                                                              "bus-name",
+                                                              "bus-name",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_APP_ID,
+                                         g_param_spec_string ("app-id",
+                                                              "app-id",
+                                                              "app-id",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_CLIENT_ID,
+                                         g_param_spec_string ("client-id",
+                                                              "client-id",
+                                                              "client-id",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_REASON,
+                                         g_param_spec_string ("reason",
+                                                              "reason",
+                                                              "reason",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_FLAGS,
+                                         g_param_spec_uint ("flags",
+                                                            "flags",
+                                                            "flags",
+                                                            0,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_TOPLEVEL_XID,
+                                         g_param_spec_uint ("toplevel-xid",
+                                                            "toplevel-xid",
+                                                            "toplevel-xid",
+                                                            0,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_COOKIE,
+                                         g_param_spec_uint ("cookie",
+                                                            "cookie",
+                                                            "cookie",
+                                                            0,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+        dbus_g_object_type_install_info (GSM_TYPE_INHIBITOR, &dbus_glib_gsm_inhibitor_object_info);
+        dbus_g_error_domain_register (GSM_INHIBITOR_ERROR, NULL, GSM_INHIBITOR_TYPE_ERROR);
+}
+
+GsmInhibitor *
+gsm_inhibitor_new (const char    *app_id,
+                   guint          toplevel_xid,
+                   guint          flags,
+                   const char    *reason,
+                   const char    *bus_name,
+                   guint          cookie)
+{
+        GsmInhibitor *inhibitor;
+
+        inhibitor = g_object_new (GSM_TYPE_INHIBITOR,
+                                  "app-id", app_id,
+                                  "reason", reason,
+                                  "bus-name", bus_name,
+                                  "flags", flags,
+                                  "toplevel-xid", toplevel_xid,
+                                  "cookie", cookie,
+                                  NULL);
+
+        return inhibitor;
+}
+
+GsmInhibitor *
+gsm_inhibitor_new_for_client (const char    *client_id,
+                              const char    *app_id,
+                              guint          flags,
+                              const char    *reason,
+                              const char    *bus_name,
+                              guint          cookie)
+{
+        GsmInhibitor *inhibitor;
+
+        inhibitor = g_object_new (GSM_TYPE_INHIBITOR,
+                                  "client-id", client_id,
+                                  "app-id", app_id,
+                                  "reason", reason,
+                                  "bus-name", bus_name,
+                                  "flags", flags,
+                                  "cookie", cookie,
+                                  NULL);
+
+        return inhibitor;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/34.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/34.html new file mode 100644 index 0000000..13d2dbf --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/34.html @@ -0,0 +1,473 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                               GValue       *return_value,
+                                                               guint         n_param_values,
+                                                               const GValue *param_values,
+                                                               gpointer      invocation_hint,
+                                                               gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                          GValue       *return_value,
+                                                          guint         n_param_values,
+                                                          const GValue *param_values,
+                                                          gpointer      invocation_hint G_GNUC_UNUSED,
+                                                          gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+                                                             gpointer arg1,
+                                                             gpointer arg2,
+                                                             gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gsm_inhibitor_methods[] = {
+  { (GCallback) gsm_inhibitor_get_app_id, dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER, 0 },
+  { (GCallback) gsm_inhibitor_get_client_id, dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER, 62 },
+  { (GCallback) gsm_inhibitor_get_reason, dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER, 130 },
+  { (GCallback) gsm_inhibitor_get_flags, dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER, 193 },
+  { (GCallback) gsm_inhibitor_get_toplevel_xid, dbus_glib_marshal_gsm_inhibitor_BOOLEAN__POINTER_POINTER, 254 },
+};
+
+const DBusGObjectInfo dbus_glib_gsm_inhibitor_object_info = {  1,
+  dbus_glib_gsm_inhibitor_methods,
+  5,
+"org.gnome.SessionManager.Inhibitor\0GetAppId\0S\0app_id\0O\0F\0N\0s\0\0org.gnome.SessionManager.Inhibitor\0GetClientId\0S\0client_id\0O\0F\0N\0o\0\0org.gnome.SessionManager.Inhibitor\0GetReason\0S\0reason\0O\0F\0N\0s\0\0org.gnome.SessionManager.Inhibitor\0GetFlags\0S\0flags\0O\0F\0N\0u\0\0org.gnome.SessionManager.Inhibitor\0GetToplevelXid\0S\0xid\0O\0F\0N\0u\0\0\0",
+"\0",
+"\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/35.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/35.html new file mode 100644 index 0000000..4040ea4 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/35.html @@ -0,0 +1,1311 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Vincent Untz
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *	Vincent Untz <vuntz@gnome.org>
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-logout-dialog.h"
+#ifdef HAVE_SYSTEMD
+#include "gsm-systemd.h"
+#endif
+#include "gsm-consolekit.h"
+#include "mdm.h"
+#include "gsm-util.h"
+
+#define GSM_ICON_LOGOUT   "system-log-out"
+#define GSM_ICON_SHUTDOWN "system-shutdown"
+
+#define SESSION_SCHEMA     "org.mate.session"
+#define KEY_LOGOUT_TIMEOUT "logout-timeout"
+
+#define LOCKDOWN_SCHEMA            "org.mate.lockdown"
+#define KEY_USER_SWITCHING_DISABLE "disable-user-switching"
+
+typedef enum {
+        GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
+        GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN
+} GsmDialogLogoutType;
+
+struct _GsmLogoutDialog
+{
+        GtkMessageDialog     parent;
+        GsmDialogLogoutType  type;
+#ifdef HAVE_SYSTEMD
+        GsmSystemd          *systemd;
+#endif
+        GsmConsolekit       *consolekit;
+
+        GtkWidget           *progressbar;
+
+        int                  timeout;
+        unsigned int         timeout_id;
+
+        unsigned int         default_response;
+};
+
+static GsmLogoutDialog *current_dialog = NULL;
+
+static void gsm_logout_dialog_set_timeout  (GsmLogoutDialog *logout_dialog);
+
+static void gsm_logout_dialog_destroy  (GsmLogoutDialog *logout_dialog,
+                                        gpointer         data);
+
+static void gsm_logout_dialog_show     (GsmLogoutDialog *logout_dialog,
+                                        gpointer         data);
+
+enum {
+        PROP_0,
+        PROP_MESSAGE_TYPE
+};
+
+G_DEFINE_TYPE (GsmLogoutDialog, gsm_logout_dialog, GTK_TYPE_MESSAGE_DIALOG);
+
+static void
+gsm_logout_dialog_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+        switch (prop_id) {
+        case PROP_MESSAGE_TYPE:
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_logout_dialog_get_property (GObject     *object,
+                                guint        prop_id,
+                                GValue      *value,
+                                GParamSpec  *pspec)
+{
+        switch (prop_id) {
+        case PROP_MESSAGE_TYPE:
+                g_value_set_enum (value, GTK_MESSAGE_WARNING);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_logout_dialog_class_init (GsmLogoutDialogClass *klass)
+{
+        GObjectClass *gobject_class;
+
+        gobject_class = G_OBJECT_CLASS (klass);
+
+        /* This is a workaround to avoid a stupid crash: libmateui
+         * listens for the "show" signal on all GtkMessageDialog and
+         * gets the "message-type" of the dialogs. We will crash when
+         * it accesses this property if we don't override it since we
+         * didn't define it. */
+        gobject_class->set_property = gsm_logout_dialog_set_property;
+        gobject_class->get_property = gsm_logout_dialog_get_property;
+
+        g_object_class_override_property (gobject_class,
+                                          PROP_MESSAGE_TYPE,
+                                          "message-type");
+}
+
+static void
+gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog)
+{
+        logout_dialog->timeout_id = 0;
+        logout_dialog->timeout = 0;
+        logout_dialog->default_response = GTK_RESPONSE_CANCEL;
+
+        GtkStyleContext *context;
+        context = gtk_widget_get_style_context (GTK_WIDGET (logout_dialog));
+        gtk_style_context_add_class (context, "logout-dialog");
+
+        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
+        gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
+        gtk_window_stick (GTK_WINDOW (logout_dialog));
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING())
+            logout_dialog->systemd = gsm_get_systemd ();
+        else
+#endif
+        logout_dialog->consolekit = gsm_get_consolekit ();
+
+        g_signal_connect (logout_dialog,
+                          "destroy",
+                          G_CALLBACK (gsm_logout_dialog_destroy),
+                          NULL);
+
+        g_signal_connect (logout_dialog,
+                          "show",
+                          G_CALLBACK (gsm_logout_dialog_show),
+                          NULL);
+}
+
+static void
+gsm_logout_dialog_destroy (GsmLogoutDialog *logout_dialog,
+                           gpointer         data)
+{
+        if (logout_dialog->timeout_id != 0) {
+                g_source_remove (logout_dialog->timeout_id);
+                logout_dialog->timeout_id = 0;
+        }
+#ifdef HAVE_SYSTEMD
+        if (logout_dialog->systemd) {
+                g_object_unref (logout_dialog->systemd);
+                logout_dialog->systemd = NULL;
+        }
+#endif
+
+        if (logout_dialog->consolekit) {
+                g_object_unref (logout_dialog->consolekit);
+                logout_dialog->consolekit = NULL;
+        }
+
+        current_dialog = NULL;
+}
+
+static gboolean
+gsm_logout_supports_system_suspend (GsmLogoutDialog *logout_dialog)
+{
+        gboolean ret;
+        ret = FALSE;
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING())
+            ret = gsm_systemd_can_suspend (logout_dialog->systemd);
+        else
+#endif
+        ret = gsm_consolekit_can_suspend (logout_dialog->consolekit);
+        return ret;
+}
+
+static gboolean
+gsm_logout_supports_system_hibernate (GsmLogoutDialog *logout_dialog)
+{
+        gboolean ret;
+        ret = FALSE;
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING())
+            ret = gsm_systemd_can_hibernate (logout_dialog->systemd);
+        else
+#endif
+        ret = gsm_consolekit_can_hibernate (logout_dialog->consolekit);
+        return ret;
+}
+
+static gboolean
+gsm_logout_supports_switch_user (GsmLogoutDialog *logout_dialog)
+{
+        GSettings *settings;
+        gboolean   ret = FALSE;
+        gboolean   locked;
+
+        settings = g_settings_new (LOCKDOWN_SCHEMA);
+
+        locked = g_settings_get_boolean (settings, KEY_USER_SWITCHING_DISABLE);
+        g_object_unref (settings);
+
+        if (!locked) {
+#ifdef HAVE_SYSTEMD
+            if (LOGIND_RUNNING())
+                ret = gsm_systemd_can_switch_user (logout_dialog->systemd);
+            else
+#endif
+            ret = gsm_consolekit_can_switch_user (logout_dialog->consolekit);
+        }
+
+        return ret;
+}
+
+static gboolean
+gsm_logout_supports_reboot (GsmLogoutDialog *logout_dialog)
+{
+        gboolean ret;
+
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING())
+            ret = gsm_systemd_can_restart (logout_dialog->systemd);
+        else
+#endif
+        ret = gsm_consolekit_can_restart (logout_dialog->consolekit);
+        if (!ret) {
+                ret = mdm_supports_logout_action (MDM_LOGOUT_ACTION_REBOOT);
+        }
+
+        return ret;
+}
+
+static gboolean
+gsm_logout_supports_shutdown (GsmLogoutDialog *logout_dialog)
+{
+        gboolean ret;
+
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING())
+            ret = gsm_systemd_can_stop (logout_dialog->systemd);
+        else
+#endif
+        ret = gsm_consolekit_can_stop (logout_dialog->consolekit);
+
+        if (!ret) {
+                ret = mdm_supports_logout_action (MDM_LOGOUT_ACTION_SHUTDOWN);
+        }
+
+        return ret;
+}
+
+static void
+gsm_logout_dialog_show (GsmLogoutDialog *logout_dialog, gpointer user_data)
+{
+        gsm_logout_dialog_set_timeout (logout_dialog);
+}
+
+static gboolean
+gsm_logout_dialog_timeout (gpointer data)
+{
+        GsmLogoutDialog *logout_dialog;
+        char            *seconds_warning;
+        char            *secondary_text;
+        static char     *session_type = NULL;
+        static gboolean  is_not_login;
+
+        logout_dialog = (GsmLogoutDialog *) data;
+
+        if (!logout_dialog->timeout) {
+                gtk_dialog_response (GTK_DIALOG (logout_dialog),
+                                     logout_dialog->default_response);
+
+                return FALSE;
+        }
+
+        switch (logout_dialog->type) {
+        case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
+                seconds_warning = ngettext ("You will be automatically logged "
+                                            "out in %d second",
+                                            "You will be automatically logged "
+                                            "out in %d seconds",
+                                            logout_dialog->timeout);
+                break;
+
+        case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
+                seconds_warning = ngettext ("This system will be automatically "
+                                            "shut down in %d second",
+                                            "This system will be automatically "
+                                            "shut down in %d seconds",
+                                            logout_dialog->timeout);
+                break;
+
+        default:
+                g_assert_not_reached ();
+        }
+        seconds_warning = g_strdup_printf (seconds_warning, logout_dialog->timeout);
+
+        if (session_type == NULL) {
+#ifdef HAVE_SYSTEMD
+                if (LOGIND_RUNNING()) {
+                    GsmSystemd *systemd;
+                    systemd = gsm_get_systemd ();
+                    session_type = gsm_systemd_get_current_session_type (systemd);
+                    g_object_unref (systemd);
+                    is_not_login = (g_strcmp0 (session_type, GSM_SYSTEMD_SESSION_TYPE_LOGIN_WINDOW) != 0);
+                }
+                else {
+#endif
+                GsmConsolekit *consolekit;
+                consolekit = gsm_get_consolekit ();
+                session_type = gsm_consolekit_get_current_session_type (consolekit);
+                g_object_unref (consolekit);
+                is_not_login = (g_strcmp0 (session_type, GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW) != 0);
+#ifdef HAVE_SYSTEMD
+                }
+#endif
+        }
+
+        if (is_not_login) {
+                char *name;
+
+                name = g_locale_to_utf8 (g_get_real_name (), -1, NULL, NULL, NULL);
+
+                if (!name || name[0] == '\0' || strcmp (name, "Unknown") == 0) {
+                        name = g_locale_to_utf8 (g_get_user_name (), -1 , NULL, NULL, NULL);
+                }
+
+                if (!name) {
+                        name = g_strdup (g_get_user_name ());
+                }
+
+                secondary_text = g_strdup_printf (_("You are currently logged in as \"%s\"."), name);
+
+                g_free (name);
+        } else {
+                secondary_text = g_strdup (seconds_warning);
+        }
+
+        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->progressbar),
+                                       logout_dialog->timeout / 60.0);
+        gtk_progress_bar_set_text (GTK_PROGRESS_BAR (logout_dialog->progressbar),
+                                   seconds_warning);
+
+        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (logout_dialog),
+                                                  secondary_text,
+                                                  NULL);
+
+        logout_dialog->timeout--;
+
+        g_free (secondary_text);
+        g_free (seconds_warning);
+
+        return TRUE;
+}
+
+static void
+gsm_logout_dialog_set_timeout (GsmLogoutDialog *logout_dialog)
+{
+        GSettings *settings;
+
+        settings = g_settings_new (SESSION_SCHEMA);
+
+        logout_dialog->timeout = g_settings_get_int (settings, KEY_LOGOUT_TIMEOUT);
+
+        if (logout_dialog->timeout > 0) {
+                /* Sets the secondary text */
+                gsm_logout_dialog_timeout (logout_dialog);
+
+                if (logout_dialog->timeout_id != 0) {
+                        g_source_remove (logout_dialog->timeout_id);
+                }
+
+                logout_dialog->timeout_id = g_timeout_add (1000,
+                                                           gsm_logout_dialog_timeout,
+                                                           logout_dialog);
+        }
+        else {
+                gtk_widget_hide (logout_dialog->progressbar);
+        }
+
+        g_object_unref (settings);
+}
+
+static GtkWidget *
+gsm_get_dialog (GsmDialogLogoutType type,
+                GdkScreen          *screen,
+                guint32             activate_time)
+{
+        GsmLogoutDialog *logout_dialog;
+        GtkWidget       *hbox;
+        const char      *primary_text;
+        const char      *icon_name;
+
+        if (current_dialog != NULL) {
+                gtk_widget_destroy (GTK_WIDGET (current_dialog));
+        }
+
+        logout_dialog = g_object_new (GSM_TYPE_LOGOUT_DIALOG, NULL);
+
+        current_dialog = logout_dialog;
+
+        gtk_window_set_title (GTK_WINDOW (logout_dialog), "");
+
+        logout_dialog->type = type;
+
+        icon_name = NULL;
+        primary_text = NULL;
+
+        switch (type) {
+        case GSM_DIALOG_LOGOUT_TYPE_LOGOUT:
+                icon_name    = GSM_ICON_LOGOUT;
+                primary_text = _("Log out of this system now?");
+
+                logout_dialog->default_response = GSM_LOGOUT_RESPONSE_LOGOUT;
+
+                if (gsm_logout_supports_switch_user (logout_dialog)) {
+                        gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                                    _("_Switch User"), "system-users",
+                                                    GSM_LOGOUT_RESPONSE_SWITCH_USER);
+                }
+
+                gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                            _("_Cancel"), "process-stop",
+                                            GTK_RESPONSE_CANCEL);
+
+                gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                            _("_Log Out"), "system-log-out",
+                                            GSM_LOGOUT_RESPONSE_LOGOUT);
+
+                break;
+        case GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN:
+                icon_name    = GSM_ICON_SHUTDOWN;
+                primary_text = _("Shut down this system now?");
+
+                logout_dialog->default_response = GSM_LOGOUT_RESPONSE_SHUTDOWN;
+
+                if (gsm_logout_supports_system_suspend (logout_dialog)) {
+                        gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                                    _("S_uspend"), "battery",
+                                                    GSM_LOGOUT_RESPONSE_SLEEP);
+                }
+
+                if (gsm_logout_supports_system_hibernate (logout_dialog)) {
+                        gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                                    _("_Hibernate"), "drive-harddisk",
+                                                    GSM_LOGOUT_RESPONSE_HIBERNATE);
+                }
+
+                if (gsm_logout_supports_reboot (logout_dialog)) {
+                        gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                                    _("_Restart"), "view-refresh",
+                                                    GSM_LOGOUT_RESPONSE_REBOOT);
+                }
+
+                gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                            _("_Cancel"), "process-stop",
+                                            GTK_RESPONSE_CANCEL);
+
+                if (gsm_logout_supports_shutdown (logout_dialog)) {
+                        gsm_util_dialog_add_button (GTK_DIALOG (logout_dialog),
+                                                    _("_Shut Down"), "system-shutdown",
+                                                    GSM_LOGOUT_RESPONSE_SHUTDOWN);
+                }
+                break;
+        default:
+                g_assert_not_reached ();
+        }
+
+        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        logout_dialog->progressbar = gtk_progress_bar_new ();
+        gtk_progress_bar_set_show_text (GTK_PROGRESS_BAR (logout_dialog->progressbar), TRUE);
+        gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (logout_dialog->progressbar), 1.0);
+        gtk_box_pack_start (GTK_BOX (hbox),
+                            logout_dialog->progressbar,
+                            TRUE, TRUE, 12);
+        gtk_widget_show_all (hbox);
+        gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (logout_dialog))), hbox);
+
+        gtk_window_set_icon_name (GTK_WINDOW (logout_dialog), icon_name);
+        gtk_window_set_position (GTK_WINDOW (logout_dialog), GTK_WIN_POS_CENTER_ALWAYS);
+        gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (logout_dialog), primary_text);
+
+        gtk_dialog_set_default_response (GTK_DIALOG (logout_dialog),
+                                         logout_dialog->default_response);
+
+        gtk_window_set_screen (GTK_WINDOW (logout_dialog), screen);
+
+        return GTK_WIDGET (logout_dialog);
+}
+
+GtkWidget *
+gsm_get_shutdown_dialog (GdkScreen *screen,
+                         guint32    activate_time)
+{
+        return gsm_get_dialog (GSM_DIALOG_LOGOUT_TYPE_SHUTDOWN,
+                               screen,
+                               activate_time);
+}
+
+GtkWidget *
+gsm_get_logout_dialog (GdkScreen *screen,
+                       guint32    activate_time)
+{
+        return gsm_get_dialog (GSM_DIALOG_LOGOUT_TYPE_LOGOUT,
+                               screen,
+                               activate_time);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/36.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/36.html new file mode 100644 index 0000000..18efbc1 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/36.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Vincent Untz
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *	Vincent Untz <vuntz@gnome.org>
+ */
+
+#ifndef __GSM_LOGOUT_DIALOG_H__
+#define __GSM_LOGOUT_DIALOG_H__
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_LOGOUT_DIALOG         (gsm_logout_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (GsmLogoutDialog, gsm_logout_dialog, GSM, LOGOUT_DIALOG, GtkMessageDialog)
+
+enum
+{
+        GSM_LOGOUT_RESPONSE_LOGOUT,
+        GSM_LOGOUT_RESPONSE_SWITCH_USER,
+        GSM_LOGOUT_RESPONSE_SHUTDOWN,
+        GSM_LOGOUT_RESPONSE_REBOOT,
+        GSM_LOGOUT_RESPONSE_HIBERNATE,
+        GSM_LOGOUT_RESPONSE_SLEEP
+};
+
+GtkWidget   *gsm_get_logout_dialog        (GdkScreen           *screen,
+                                           guint32              activate_time);
+GtkWidget   *gsm_get_shutdown_dialog      (GdkScreen           *screen,
+                                           guint32              activate_time);
+
+G_END_DECLS<--- syntax error
+
+#endif /* __GSM_LOGOUT_DIALOG_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/37.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/37.html new file mode 100644 index 0000000..8984423 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/37.html @@ -0,0 +1,355 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* mdm.h
+ * Copyright (C) 2005 Raffaele Sandrini
+ * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2002, 2003 George Lebl
+ * Copyright (C) 2001 Queen of England,
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *      Raffaele Sandrini <rasa@gmx.ch>
+ *      George Lebl <jirka@5z.com>
+ *      Mark McLoughlin <mark@skynet.ie>
+ */
+
+#ifndef __MDM_LOGOUT_ACTION_H__
+#define __MDM_LOGOUT_ACTION_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+	MDM_LOGOUT_ACTION_NONE = 0,
+	MDM_LOGOUT_ACTION_SHUTDOWN = 1 << 0,
+	MDM_LOGOUT_ACTION_REBOOT = 1 << 1,
+	MDM_LOGOUT_ACTION_SUSPEND = 1 << 2
+} MdmLogoutAction;
+
+gboolean mdm_is_available(void);
+
+void mdm_new_login(void);
+
+void mdm_set_logout_action(MdmLogoutAction action);
+
+MdmLogoutAction mdm_get_logout_action(void);
+
+gboolean mdm_supports_logout_action(MdmLogoutAction action);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MDM_LOGOUT_ACTION_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/38.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/38.html new file mode 100644 index 0000000..7517b56 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/38.html @@ -0,0 +1,431 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/*
+ * Copyright (C) 2013 Stefano Karapetsas
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *  Stefano Karapetsas <stefano@karapetsas.com>
+ */
+
+#ifndef __GSM_SYSTEMD_H__
+#define __GSM_SYSTEMD_H__
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_SYSTEMD             (gsm_systemd_get_type ())
+#define GSM_SYSTEMD_ERROR            (gsm_systemd_error_quark ())
+G_DECLARE_DERIVABLE_TYPE (GsmSystemd, gsm_systemd, GSM, SYSTEMD, GObject)
+
+#define LOGIND_RUNNING() (access("/run/systemd/seats/", F_OK) >= 0)
+typedef enum   _GsmSystemdError   GsmSystemdError;
+
+struct _GsmSystemdClass
+{
+        GObjectClass parent_class;
+
+        void (* request_completed) (GsmSystemd *manager,
+                                    GError        *error);
+
+        void (* privileges_completed) (GsmSystemd *manager,
+                                       gboolean       success,
+                                       gboolean       ask_later,
+                                       GError        *error);
+};
+
+enum _GsmSystemdError {
+        GSM_SYSTEMD_ERROR_RESTARTING = 0,
+        GSM_SYSTEMD_ERROR_STOPPING
+};
+
+#define GSM_SYSTEMD_SESSION_TYPE_LOGIN_WINDOW "greeter"
+
+GQuark           gsm_systemd_error_quark     (void);
+
+GsmSystemd      *gsm_systemd_new             (void) G_GNUC_MALLOC;
+
+gboolean         gsm_systemd_can_switch_user (GsmSystemd *manager);
+
+gboolean         gsm_systemd_get_restart_privileges (GsmSystemd *manager);
+
+gboolean         gsm_systemd_get_stop_privileges    (GsmSystemd *manager);
+
+gboolean         gsm_systemd_can_stop        (GsmSystemd *manager);
+
+gboolean         gsm_systemd_can_restart     (GsmSystemd *manager);
+
+gboolean         gsm_systemd_can_hibernate     (GsmSystemd *manager);
+
+gboolean         gsm_systemd_can_suspend     (GsmSystemd *manager);
+
+gboolean         gsm_systemd_is_last_session_for_user (GsmSystemd *manager);
+
+void             gsm_systemd_attempt_stop    (GsmSystemd *manager);
+
+void             gsm_systemd_attempt_restart (GsmSystemd *manager);
+
+void             gsm_systemd_attempt_hibernate (GsmSystemd *manager);
+
+void             gsm_systemd_attempt_suspend (GsmSystemd *manager);
+
+void             gsm_systemd_set_session_idle (GsmSystemd *manager,
+                                                  gboolean       is_idle);
+
+gchar           *gsm_systemd_get_current_session_type (GsmSystemd *manager);
+
+GsmSystemd      *gsm_get_systemd             (void);
+
+G_END_DECLS
+
+#endif /* __GSM_SYSTEMD_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/39.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/39.html new file mode 100644 index 0000000..39c3cef --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/39.html @@ -0,0 +1,8747 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
+1539
+1540
+1541
+1542
+1543
+1544
+1545
+1546
+1547
+1548
+1549
+1550
+1551
+1552
+1553
+1554
+1555
+1556
+1557
+1558
+1559
+1560
+1561
+1562
+1563
+1564
+1565
+1566
+1567
+1568
+1569
+1570
+1571
+1572
+1573
+1574
+1575
+1576
+1577
+1578
+1579
+1580
+1581
+1582
+1583
+1584
+1585
+1586
+1587
+1588
+1589
+1590
+1591
+1592
+1593
+1594
+1595
+1596
+1597
+1598
+1599
+1600
+1601
+1602
+1603
+1604
+1605
+1606
+1607
+1608
+1609
+1610
+1611
+1612
+1613
+1614
+1615
+1616
+1617
+1618
+1619
+1620
+1621
+1622
+1623
+1624
+1625
+1626
+1627
+1628
+1629
+1630
+1631
+1632
+1633
+1634
+1635
+1636
+1637
+1638
+1639
+1640
+1641
+1642
+1643
+1644
+1645
+1646
+1647
+1648
+1649
+1650
+1651
+1652
+1653
+1654
+1655
+1656
+1657
+1658
+1659
+1660
+1661
+1662
+1663
+1664
+1665
+1666
+1667
+1668
+1669
+1670
+1671
+1672
+1673
+1674
+1675
+1676
+1677
+1678
+1679
+1680
+1681
+1682
+1683
+1684
+1685
+1686
+1687
+1688
+1689
+1690
+1691
+1692
+1693
+1694
+1695
+1696
+1697
+1698
+1699
+1700
+1701
+1702
+1703
+1704
+1705
+1706
+1707
+1708
+1709
+1710
+1711
+1712
+1713
+1714
+1715
+1716
+1717
+1718
+1719
+1720
+1721
+1722
+1723
+1724
+1725
+1726
+1727
+1728
+1729
+1730
+1731
+1732
+1733
+1734
+1735
+1736
+1737
+1738
+1739
+1740
+1741
+1742
+1743
+1744
+1745
+1746
+1747
+1748
+1749
+1750
+1751
+1752
+1753
+1754
+1755
+1756
+1757
+1758
+1759
+1760
+1761
+1762
+1763
+1764
+1765
+1766
+1767
+1768
+1769
+1770
+1771
+1772
+1773
+1774
+1775
+1776
+1777
+1778
+1779
+1780
+1781
+1782
+1783
+1784
+1785
+1786
+1787
+1788
+1789
+1790
+1791
+1792
+1793
+1794
+1795
+1796
+1797
+1798
+1799
+1800
+1801
+1802
+1803
+1804
+1805
+1806
+1807
+1808
+1809
+1810
+1811
+1812
+1813
+1814
+1815
+1816
+1817
+1818
+1819
+1820
+1821
+1822
+1823
+1824
+1825
+1826
+1827
+1828
+1829
+1830
+1831
+1832
+1833
+1834
+1835
+1836
+1837
+1838
+1839
+1840
+1841
+1842
+1843
+1844
+1845
+1846
+1847
+1848
+1849
+1850
+1851
+1852
+1853
+1854
+1855
+1856
+1857
+1858
+1859
+1860
+1861
+1862
+1863
+1864
+1865
+1866
+1867
+1868
+1869
+1870
+1871
+1872
+1873
+1874
+1875
+1876
+1877
+1878
+1879
+1880
+1881
+1882
+1883
+1884
+1885
+1886
+1887
+1888
+1889
+1890
+1891
+1892
+1893
+1894
+1895
+1896
+1897
+1898
+1899
+1900
+1901
+1902
+1903
+1904
+1905
+1906
+1907
+1908
+1909
+1910
+1911
+1912
+1913
+1914
+1915
+1916
+1917
+1918
+1919
+1920
+1921
+1922
+1923
+1924
+1925
+1926
+1927
+1928
+1929
+1930
+1931
+1932
+1933
+1934
+1935
+1936
+1937
+1938
+1939
+1940
+1941
+1942
+1943
+1944
+1945
+1946
+1947
+1948
+1949
+1950
+1951
+1952
+1953
+1954
+1955
+1956
+1957
+1958
+1959
+1960
+1961
+1962
+1963
+1964
+1965
+1966
+1967
+1968
+1969
+1970
+1971
+1972
+1973
+1974
+1975
+1976
+1977
+1978
+1979
+1980
+1981
+1982
+1983
+1984
+1985
+1986
+1987
+1988
+1989
+1990
+1991
+1992
+1993
+1994
+1995
+1996
+1997
+1998
+1999
+2000
+2001
+2002
+2003
+2004
+2005
+2006
+2007
+2008
+2009
+2010
+2011
+2012
+2013
+2014
+2015
+2016
+2017
+2018
+2019
+2020
+2021
+2022
+2023
+2024
+2025
+2026
+2027
+2028
+2029
+2030
+2031
+2032
+2033
+2034
+2035
+2036
+2037
+2038
+2039
+2040
+2041
+2042
+2043
+2044
+2045
+2046
+2047
+2048
+2049
+2050
+2051
+2052
+2053
+2054
+2055
+2056
+2057
+2058
+2059
+2060
+2061
+2062
+2063
+2064
+2065
+2066
+2067
+2068
+2069
+2070
+2071
+2072
+2073
+2074
+2075
+2076
+2077
+2078
+2079
+2080
+2081
+2082
+2083
+2084
+2085
+2086
+2087
+2088
+2089
+2090
+2091
+2092
+2093
+2094
+2095
+2096
+2097
+2098
+2099
+2100
+2101
+2102
+2103
+2104
+2105
+2106
+2107
+2108
+2109
+2110
+2111
+2112
+2113
+2114
+2115
+2116
+2117
+2118
+2119
+2120
+2121
+2122
+2123
+2124
+2125
+2126
+2127
+2128
+2129
+2130
+2131
+2132
+2133
+2134
+2135
+2136
+2137
+2138
+2139
+2140
+2141
+2142
+2143
+2144
+2145
+2146
+2147
+2148
+2149
+2150
+2151
+2152
+2153
+2154
+2155
+2156
+2157
+2158
+2159
+2160
+2161
+2162
+2163
+2164
+2165
+2166
+2167
+2168
+2169
+2170
+2171
+2172
+2173
+2174
+2175
+2176
+2177
+2178
+2179
+2180
+2181
+2182
+2183
+2184
+2185
+2186
+2187
+2188
+2189
+2190
+2191
+2192
+2193
+2194
+2195
+2196
+2197
+2198
+2199
+2200
+2201
+2202
+2203
+2204
+2205
+2206
+2207
+2208
+2209
+2210
+2211
+2212
+2213
+2214
+2215
+2216
+2217
+2218
+2219
+2220
+2221
+2222
+2223
+2224
+2225
+2226
+2227
+2228
+2229
+2230
+2231
+2232
+2233
+2234
+2235
+2236
+2237
+2238
+2239
+2240
+2241
+2242
+2243
+2244
+2245
+2246
+2247
+2248
+2249
+2250
+2251
+2252
+2253
+2254
+2255
+2256
+2257
+2258
+2259
+2260
+2261
+2262
+2263
+2264
+2265
+2266
+2267
+2268
+2269
+2270
+2271
+2272
+2273
+2274
+2275
+2276
+2277
+2278
+2279
+2280
+2281
+2282
+2283
+2284
+2285
+2286
+2287
+2288
+2289
+2290
+2291
+2292
+2293
+2294
+2295
+2296
+2297
+2298
+2299
+2300
+2301
+2302
+2303
+2304
+2305
+2306
+2307
+2308
+2309
+2310
+2311
+2312
+2313
+2314
+2315
+2316
+2317
+2318
+2319
+2320
+2321
+2322
+2323
+2324
+2325
+2326
+2327
+2328
+2329
+2330
+2331
+2332
+2333
+2334
+2335
+2336
+2337
+2338
+2339
+2340
+2341
+2342
+2343
+2344
+2345
+2346
+2347
+2348
+2349
+2350
+2351
+2352
+2353
+2354
+2355
+2356
+2357
+2358
+2359
+2360
+2361
+2362
+2363
+2364
+2365
+2366
+2367
+2368
+2369
+2370
+2371
+2372
+2373
+2374
+2375
+2376
+2377
+2378
+2379
+2380
+2381
+2382
+2383
+2384
+2385
+2386
+2387
+2388
+2389
+2390
+2391
+2392
+2393
+2394
+2395
+2396
+2397
+2398
+2399
+2400
+2401
+2402
+2403
+2404
+2405
+2406
+2407
+2408
+2409
+2410
+2411
+2412
+2413
+2414
+2415
+2416
+2417
+2418
+2419
+2420
+2421
+2422
+2423
+2424
+2425
+2426
+2427
+2428
+2429
+2430
+2431
+2432
+2433
+2434
+2435
+2436
+2437
+2438
+2439
+2440
+2441
+2442
+2443
+2444
+2445
+2446
+2447
+2448
+2449
+2450
+2451
+2452
+2453
+2454
+2455
+2456
+2457
+2458
+2459
+2460
+2461
+2462
+2463
+2464
+2465
+2466
+2467
+2468
+2469
+2470
+2471
+2472
+2473
+2474
+2475
+2476
+2477
+2478
+2479
+2480
+2481
+2482
+2483
+2484
+2485
+2486
+2487
+2488
+2489
+2490
+2491
+2492
+2493
+2494
+2495
+2496
+2497
+2498
+2499
+2500
+2501
+2502
+2503
+2504
+2505
+2506
+2507
+2508
+2509
+2510
+2511
+2512
+2513
+2514
+2515
+2516
+2517
+2518
+2519
+2520
+2521
+2522
+2523
+2524
+2525
+2526
+2527
+2528
+2529
+2530
+2531
+2532
+2533
+2534
+2535
+2536
+2537
+2538
+2539
+2540
+2541
+2542
+2543
+2544
+2545
+2546
+2547
+2548
+2549
+2550
+2551
+2552
+2553
+2554
+2555
+2556
+2557
+2558
+2559
+2560
+2561
+2562
+2563
+2564
+2565
+2566
+2567
+2568
+2569
+2570
+2571
+2572
+2573
+2574
+2575
+2576
+2577
+2578
+2579
+2580
+2581
+2582
+2583
+2584
+2585
+2586
+2587
+2588
+2589
+2590
+2591
+2592
+2593
+2594
+2595
+2596
+2597
+2598
+2599
+2600
+2601
+2602
+2603
+2604
+2605
+2606
+2607
+2608
+2609
+2610
+2611
+2612
+2613
+2614
+2615
+2616
+2617
+2618
+2619
+2620
+2621
+2622
+2623
+2624
+2625
+2626
+2627
+2628
+2629
+2630
+2631
+2632
+2633
+2634
+2635
+2636
+2637
+2638
+2639
+2640
+2641
+2642
+2643
+2644
+2645
+2646
+2647
+2648
+2649
+2650
+2651
+2652
+2653
+2654
+2655
+2656
+2657
+2658
+2659
+2660
+2661
+2662
+2663
+2664
+2665
+2666
+2667
+2668
+2669
+2670
+2671
+2672
+2673
+2674
+2675
+2676
+2677
+2678
+2679
+2680
+2681
+2682
+2683
+2684
+2685
+2686
+2687
+2688
+2689
+2690
+2691
+2692
+2693
+2694
+2695
+2696
+2697
+2698
+2699
+2700
+2701
+2702
+2703
+2704
+2705
+2706
+2707
+2708
+2709
+2710
+2711
+2712
+2713
+2714
+2715
+2716
+2717
+2718
+2719
+2720
+2721
+2722
+2723
+2724
+2725
+2726
+2727
+2728
+2729
+2730
+2731
+2732
+2733
+2734
+2735
+2736
+2737
+2738
+2739
+2740
+2741
+2742
+2743
+2744
+2745
+2746
+2747
+2748
+2749
+2750
+2751
+2752
+2753
+2754
+2755
+2756
+2757
+2758
+2759
+2760
+2761
+2762
+2763
+2764
+2765
+2766
+2767
+2768
+2769
+2770
+2771
+2772
+2773
+2774
+2775
+2776
+2777
+2778
+2779
+2780
+2781
+2782
+2783
+2784
+2785
+2786
+2787
+2788
+2789
+2790
+2791
+2792
+2793
+2794
+2795
+2796
+2797
+2798
+2799
+2800
+2801
+2802
+2803
+2804
+2805
+2806
+2807
+2808
+2809
+2810
+2811
+2812
+2813
+2814
+2815
+2816
+2817
+2818
+2819
+2820
+2821
+2822
+2823
+2824
+2825
+2826
+2827
+2828
+2829
+2830
+2831
+2832
+2833
+2834
+2835
+2836
+2837
+2838
+2839
+2840
+2841
+2842
+2843
+2844
+2845
+2846
+2847
+2848
+2849
+2850
+2851
+2852
+2853
+2854
+2855
+2856
+2857
+2858
+2859
+2860
+2861
+2862
+2863
+2864
+2865
+2866
+2867
+2868
+2869
+2870
+2871
+2872
+2873
+2874
+2875
+2876
+2877
+2878
+2879
+2880
+2881
+2882
+2883
+2884
+2885
+2886
+2887
+2888
+2889
+2890
+2891
+2892
+2893
+2894
+2895
+2896
+2897
+2898
+2899
+2900
+2901
+2902
+2903
+2904
+2905
+2906
+2907
+2908
+2909
+2910
+2911
+2912
+2913
+2914
+2915
+2916
+2917
+2918
+2919
+2920
+2921
+2922
+2923
+2924
+2925
+2926
+2927
+2928
+2929
+2930
+2931
+2932
+2933
+2934
+2935
+2936
+2937
+2938
+2939
+2940
+2941
+2942
+2943
+2944
+2945
+2946
+2947
+2948
+2949
+2950
+2951
+2952
+2953
+2954
+2955
+2956
+2957
+2958
+2959
+2960
+2961
+2962
+2963
+2964
+2965
+2966
+2967
+2968
+2969
+2970
+2971
+2972
+2973
+2974
+2975
+2976
+2977
+2978
+2979
+2980
+2981
+2982
+2983
+2984
+2985
+2986
+2987
+2988
+2989
+2990
+2991
+2992
+2993
+2994
+2995
+2996
+2997
+2998
+2999
+3000
+3001
+3002
+3003
+3004
+3005
+3006
+3007
+3008
+3009
+3010
+3011
+3012
+3013
+3014
+3015
+3016
+3017
+3018
+3019
+3020
+3021
+3022
+3023
+3024
+3025
+3026
+3027
+3028
+3029
+3030
+3031
+3032
+3033
+3034
+3035
+3036
+3037
+3038
+3039
+3040
+3041
+3042
+3043
+3044
+3045
+3046
+3047
+3048
+3049
+3050
+3051
+3052
+3053
+3054
+3055
+3056
+3057
+3058
+3059
+3060
+3061
+3062
+3063
+3064
+3065
+3066
+3067
+3068
+3069
+3070
+3071
+3072
+3073
+3074
+3075
+3076
+3077
+3078
+3079
+3080
+3081
+3082
+3083
+3084
+3085
+3086
+3087
+3088
+3089
+3090
+3091
+3092
+3093
+3094
+3095
+3096
+3097
+3098
+3099
+3100
+3101
+3102
+3103
+3104
+3105
+3106
+3107
+3108
+3109
+3110
+3111
+3112
+3113
+3114
+3115
+3116
+3117
+3118
+3119
+3120
+3121
+3122
+3123
+3124
+3125
+3126
+3127
+3128
+3129
+3130
+3131
+3132
+3133
+3134
+3135
+3136
+3137
+3138
+3139
+3140
+3141
+3142
+3143
+3144
+3145
+3146
+3147
+3148
+3149
+3150
+3151
+3152
+3153
+3154
+3155
+3156
+3157
+3158
+3159
+3160
+3161
+3162
+3163
+3164
+3165
+3166
+3167
+3168
+3169
+3170
+3171
+3172
+3173
+3174
+3175
+3176
+3177
+3178
+3179
+3180
+3181
+3182
+3183
+3184
+3185
+3186
+3187
+3188
+3189
+3190
+3191
+3192
+3193
+3194
+3195
+3196
+3197
+3198
+3199
+3200
+3201
+3202
+3203
+3204
+3205
+3206
+3207
+3208
+3209
+3210
+3211
+3212
+3213
+3214
+3215
+3216
+3217
+3218
+3219
+3220
+3221
+3222
+3223
+3224
+3225
+3226
+3227
+3228
+3229
+3230
+3231
+3232
+3233
+3234
+3235
+3236
+3237
+3238
+3239
+3240
+3241
+3242
+3243
+3244
+3245
+3246
+3247
+3248
+3249
+3250
+3251
+3252
+3253
+3254
+3255
+3256
+3257
+3258
+3259
+3260
+3261
+3262
+3263
+3264
+3265
+3266
+3267
+3268
+3269
+3270
+3271
+3272
+3273
+3274
+3275
+3276
+3277
+3278
+3279
+3280
+3281
+3282
+3283
+3284
+3285
+3286
+3287
+3288
+3289
+3290
+3291
+3292
+3293
+3294
+3295
+3296
+3297
+3298
+3299
+3300
+3301
+3302
+3303
+3304
+3305
+3306
+3307
+3308
+3309
+3310
+3311
+3312
+3313
+3314
+3315
+3316
+3317
+3318
+3319
+3320
+3321
+3322
+3323
+3324
+3325
+3326
+3327
+3328
+3329
+3330
+3331
+3332
+3333
+3334
+3335
+3336
+3337
+3338
+3339
+3340
+3341
+3342
+3343
+3344
+3345
+3346
+3347
+3348
+3349
+3350
+3351
+3352
+3353
+3354
+3355
+3356
+3357
+3358
+3359
+3360
+3361
+3362
+3363
+3364
+3365
+3366
+3367
+3368
+3369
+3370
+3371
+3372
+3373
+3374
+3375
+3376
+3377
+3378
+3379
+3380
+3381
+3382
+3383
+3384
+3385
+3386
+3387
+3388
+3389
+3390
+3391
+3392
+3393
+3394
+3395
+3396
+3397
+3398
+3399
+3400
+3401
+3402
+3403
+3404
+3405
+3406
+3407
+3408
+3409
+3410
+3411
+3412
+3413
+3414
+3415
+3416
+3417
+3418
+3419
+3420
+3421
+3422
+3423
+3424
+3425
+3426
+3427
+3428
+3429
+3430
+3431
+3432
+3433
+3434
+3435
+3436
+3437
+3438
+3439
+3440
+3441
+3442
+3443
+3444
+3445
+3446
+3447
+3448
+3449
+3450
+3451
+3452
+3453
+3454
+3455
+3456
+3457
+3458
+3459
+3460
+3461
+3462
+3463
+3464
+3465
+3466
+3467
+3468
+3469
+3470
+3471
+3472
+3473
+3474
+3475
+3476
+3477
+3478
+3479
+3480
+3481
+3482
+3483
+3484
+3485
+3486
+3487
+3488
+3489
+3490
+3491
+3492
+3493
+3494
+3495
+3496
+3497
+3498
+3499
+3500
+3501
+3502
+3503
+3504
+3505
+3506
+3507
+3508
+3509
+3510
+3511
+3512
+3513
+3514
+3515
+3516
+3517
+3518
+3519
+3520
+3521
+3522
+3523
+3524
+3525
+3526
+3527
+3528
+3529
+3530
+3531
+3532
+3533
+3534
+3535
+3536
+3537
+3538
+3539
+3540
+3541
+3542
+3543
+3544
+3545
+3546
+3547
+3548
+3549
+3550
+3551
+3552
+3553
+3554
+3555
+3556
+3557
+3558
+3559
+3560
+3561
+3562
+3563
+3564
+3565
+3566
+3567
+3568
+3569
+3570
+3571
+3572
+3573
+3574
+3575
+3576
+3577
+3578
+3579
+3580
+3581
+3582
+3583
+3584
+3585
+3586
+3587
+3588
+3589
+3590
+3591
+3592
+3593
+3594
+3595
+3596
+3597
+3598
+3599
+3600
+3601
+3602
+3603
+3604
+3605
+3606
+3607
+3608
+3609
+3610
+3611
+3612
+3613
+3614
+3615
+3616
+3617
+3618
+3619
+3620
+3621
+3622
+3623
+3624
+3625
+3626
+3627
+3628
+3629
+3630
+3631
+3632
+3633
+3634
+3635
+3636
+3637
+3638
+3639
+3640
+3641
+3642
+3643
+3644
+3645
+3646
+3647
+3648
+3649
+3650
+3651
+3652
+3653
+3654
+3655
+3656
+3657
+3658
+3659
+3660
+3661
+3662
+3663
+3664
+3665
+3666
+3667
+3668
+3669
+3670
+3671
+3672
+3673
+3674
+3675
+3676
+3677
+3678
+3679
+3680
+3681
+3682
+3683
+3684
+3685
+3686
+3687
+3688
+3689
+3690
+3691
+3692
+3693
+3694
+3695
+3696
+3697
+3698
+3699
+3700
+3701
+3702
+3703
+3704
+3705
+3706
+3707
+3708
+3709
+3710
+3711
+3712
+3713
+3714
+3715
+3716
+3717
+3718
+3719
+3720
+3721
+3722
+3723
+3724
+3725
+3726
+3727
+3728
+3729
+3730
+3731
+3732
+3733
+3734
+3735
+3736
+3737
+3738
+3739
+3740
+3741
+3742
+3743
+3744
+3745
+3746
+3747
+3748
+3749
+3750
+3751
+3752
+3753
+3754
+3755
+3756
+3757
+3758
+3759
+3760
+3761
+3762
+3763
+3764
+3765
+3766
+3767
+3768
+3769
+3770
+3771
+3772
+3773
+3774
+3775
+3776
+3777
+3778
+3779
+3780
+3781
+3782
+3783
+3784
+3785
+3786
+3787
+3788
+3789
+3790
+3791
+3792
+3793
+3794
+3795
+3796
+3797
+3798
+3799
+3800
+3801
+3802
+3803
+3804
+3805
+3806
+3807
+3808
+3809
+3810
+3811
+3812
+3813
+3814
+3815
+3816
+3817
+3818
+3819
+3820
+3821
+3822
+3823
+3824
+3825
+3826
+3827
+3828
+3829
+3830
+3831
+3832
+3833
+3834
+3835
+3836
+3837
+3838
+3839
+3840
+3841
+3842
+3843
+3844
+3845
+3846
+3847
+3848
+3849
+3850
+3851
+3852
+3853
+3854
+3855
+3856
+3857
+3858
+3859
+3860
+3861
+3862
+3863
+3864
+3865
+3866
+3867
+3868
+3869
+3870
+3871
+3872
+3873
+3874
+3875
+3876
+3877
+3878
+3879
+3880
+3881
+3882
+3883
+3884
+3885
+3886
+3887
+3888
+3889
+3890
+3891
+3892
+3893
+3894
+3895
+3896
+3897
+3898
+3899
+3900
+3901
+3902
+3903
+3904
+3905
+3906
+3907
+3908
+3909
+3910
+3911
+3912
+3913
+3914
+3915
+3916
+3917
+3918
+3919
+3920
+3921
+3922
+3923
+3924
+3925
+3926
+3927
+3928
+3929
+3930
+3931
+3932
+3933
+3934
+3935
+3936
+3937
+3938
+3939
+3940
+3941
+3942
+3943
+3944
+3945
+3946
+3947
+3948
+3949
+3950
+3951
+3952
+3953
+3954
+3955
+3956
+3957
+3958
+3959
+3960
+3961
+3962
+3963
+3964
+3965
+3966
+3967
+3968
+3969
+3970
+3971
+3972
+3973
+3974
+3975
+3976
+3977
+3978
+3979
+3980
+3981
+3982
+3983
+3984
+3985
+3986
+3987
+3988
+3989
+3990
+3991
+3992
+3993
+3994
+3995
+3996
+3997
+3998
+3999
+4000
+4001
+4002
+4003
+4004
+4005
+4006
+4007
+4008
+4009
+4010
+4011
+4012
+4013
+4014
+4015
+4016
+4017
+4018
+4019
+4020
+4021
+4022
+4023
+4024
+4025
+4026
+4027
+4028
+4029
+4030
+4031
+4032
+4033
+4034
+4035
+4036
+4037
+4038
+4039
+4040
+4041
+4042
+4043
+4044
+4045
+4046
+4047
+4048
+4049
+4050
+4051
+4052
+4053
+4054
+4055
+4056
+4057
+4058
+4059
+4060
+4061
+4062
+4063
+4064
+4065
+4066
+4067
+4068
+4069
+4070
+4071
+4072
+4073
+4074
+4075
+4076
+4077
+4078
+4079
+4080
+4081
+4082
+4083
+4084
+4085
+4086
+4087
+4088
+4089
+4090
+4091
+4092
+4093
+4094
+4095
+4096
+4097
+4098
+4099
+4100
+4101
+4102
+4103
+4104
+4105
+4106
+4107
+4108
+4109
+4110
+4111
+4112
+4113
+4114
+4115
+4116
+4117
+4118
+4119
+4120
+4121
+4122
+4123
+4124
+4125
+4126
+4127
+4128
+4129
+4130
+4131
+4132
+4133
+4134
+4135
+4136
+4137
+4138
+4139
+4140
+4141
+4142
+4143
+4144
+4145
+4146
+4147
+4148
+4149
+4150
+4151
+4152
+4153
+4154
+4155
+4156
+4157
+4158
+4159
+4160
+4161
+4162
+4163
+4164
+4165
+4166
+4167
+4168
+4169
+4170
+4171
+4172
+4173
+4174
+4175
+4176
+4177
+4178
+4179
+4180
+4181
+4182
+4183
+4184
+4185
+4186
+4187
+4188
+4189
+4190
+4191
+4192
+4193
+4194
+4195
+4196
+4197
+4198
+4199
+4200
+4201
+4202
+4203
+4204
+4205
+4206
+4207
+4208
+4209
+4210
+4211
+4212
+4213
+4214
+4215
+4216
+4217
+4218
+4219
+4220
+4221
+4222
+4223
+4224
+4225
+4226
+4227
+4228
+4229
+4230
+4231
+4232
+4233
+4234
+4235
+4236
+4237
+4238
+4239
+4240
+4241
+4242
+4243
+4244
+4245
+4246
+4247
+4248
+4249
+4250
+4251
+4252
+4253
+4254
+4255
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h> /* for logout dialog */<--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h> /* for gsettings */<--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-manager.h"
+#include "gsm-manager-glue.h"
+
+#include "gsm-store.h"
+#include "gsm-inhibitor.h"
+#include "gsm-presence.h"
+
+#include "gsm-xsmp-client.h"
+#include "gsm-dbus-client.h"
+
+#include "gsm-autostart-app.h"
+
+#include "gsm-util.h"
+#include "mdm.h"
+#include "gsm-logout-dialog.h"
+#include "gsm-inhibit-dialog.h"
+#include "gsm-consolekit.h"
+#ifdef HAVE_SYSTEMD
+#include "gsm-systemd.h"
+#endif
+#include "gsm-session-save.h"
+
+#define GSM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSM_TYPE_MANAGER, GsmManagerPrivate))
+
+#define GSM_MANAGER_DBUS_PATH "/org/gnome/SessionManager"
+#define GSM_MANAGER_DBUS_NAME "org.gnome.SessionManager"
+
+#define GSM_MANAGER_PHASE_TIMEOUT 30 /* seconds */
+
+/* In the exit phase, all apps were already given the chance to inhibit the session end
+ * At that stage we don't want to wait much for apps to respond, we want to exit, and fast.
+ */
+#define GSM_MANAGER_EXIT_PHASE_TIMEOUT 1 /* seconds */
+
+#define MDM_FLEXISERVER_COMMAND "mdmflexiserver"
+#define MDM_FLEXISERVER_ARGS    "--startnew Standard"
+
+#define GDM_FLEXISERVER_COMMAND "gdmflexiserver"
+#define GDM_FLEXISERVER_ARGS    "--startnew Standard"
+
+#define LOCKDOWN_SCHEMA              "org.mate.lockdown"
+#define KEY_LOCK_DISABLE             "disable-lock-screen"
+#define KEY_LOG_OUT_DISABLE          "disable-log-out"
+#define KEY_USER_SWITCH_DISABLE      "disable-user-switching"
+
+#define SESSION_SCHEMA               "org.mate.session"
+#define KEY_IDLE_DELAY               "idle-delay"
+#define KEY_AUTOSAVE                 "auto-save-session"
+
+#define SCREENSAVER_SCHEMA           "org.mate.screensaver"
+#define KEY_SLEEP_LOCK               "lock-enabled"
+
+#ifdef __GNUC__
+#define UNUSED_VARIABLE __attribute__ ((unused))
+#else
+#define UNUSED_VARIABLE
+#endif
+
+typedef enum
+{
+        GSM_MANAGER_LOGOUT_NONE,
+        GSM_MANAGER_LOGOUT_LOGOUT,
+        GSM_MANAGER_LOGOUT_REBOOT,
+        GSM_MANAGER_LOGOUT_REBOOT_INTERACT,
+        GSM_MANAGER_LOGOUT_REBOOT_MDM,
+        GSM_MANAGER_LOGOUT_SHUTDOWN,
+        GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT,
+        GSM_MANAGER_LOGOUT_SHUTDOWN_MDM
+} GsmManagerLogoutType;
+
+typedef struct {
+        gboolean                failsafe;
+        GsmStore               *clients;
+        GsmStore               *inhibitors;
+        GsmStore               *apps;
+        GsmPresence            *presence;
+
+        /* Current status */
+        GsmManagerPhase         phase;
+        guint                   phase_timeout_id;
+        GSList                 *pending_apps;
+        GsmManagerLogoutMode    logout_mode;
+        GSList                 *query_clients;
+        guint                   query_timeout_id;
+        /* This is used for GSM_MANAGER_PHASE_END_SESSION only at the moment,
+         * since it uses a sublist of all running client that replied in a
+         * specific way */
+        GSList                 *next_query_clients;
+        /* This is the action that will be done just before we exit */
+        GsmManagerLogoutType    logout_type;
+
+        GtkWidget              *inhibit_dialog;
+
+        /* List of clients which were disconnected due to disabled condition
+         * and shouldn't be automatically restarted */
+        GSList                 *condition_clients;
+
+        GSettings              *settings_session;
+        GSettings              *settings_lockdown;
+        GSettings              *settings_screensaver;
+
+        char                   *renderer;
+
+        DBusGProxy             *bus_proxy;
+        DBusGConnection        *connection;
+        gboolean                dbus_disconnected : 1;
+} GsmManagerPrivate;
+
+enum {
+        PROP_0,
+        PROP_CLIENT_STORE,
+        PROP_RENDERER,
+        PROP_FAILSAFE
+};
+
+enum {
+        PHASE_CHANGED,
+        CLIENT_ADDED,
+        CLIENT_REMOVED,
+        INHIBITOR_ADDED,
+        INHIBITOR_REMOVED,
+        SESSION_RUNNING,
+        SESSION_OVER,
+        LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+static void     gsm_manager_finalize    (GObject         *object);
+
+static gboolean _log_out_is_locked_down     (GsmManager *manager);
+static gboolean _switch_user_is_locked_down (GsmManager *manager);
+
+static void     _handle_client_end_session_response (GsmManager *manager,
+                                                     GsmClient  *client,
+                                                     gboolean    is_ok,
+                                                     gboolean    do_last,
+                                                     gboolean    cancel,
+                                                     const char *reason);
+
+static gboolean auto_save_is_enabled (GsmManager *manager);
+static void     maybe_save_session   (GsmManager *manager);
+
+static gpointer manager_object = NULL;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmManager, gsm_manager, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+GQuark
+gsm_manager_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_manager_error");
+        }
+
+        return ret;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+gsm_manager_error_get_type (void)
+{
+        static GType etype = 0;
+
+        if (etype == 0) {
+                static const GEnumValue values[] = {
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_GENERAL, "GeneralError"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION, "NotInInitialization"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_IN_RUNNING, "NotInRunning"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_ALREADY_REGISTERED, "AlreadyRegistered"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_NOT_REGISTERED, "NotRegistered"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_INVALID_OPTION, "InvalidOption"),
+                        ENUM_ENTRY (GSM_MANAGER_ERROR_LOCKED_DOWN, "LockedDown"),
+                        { 0, 0, 0 }
+                };
+
+                g_assert (GSM_MANAGER_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+
+                etype = g_enum_register_static ("GsmManagerError", values);
+        }
+
+        return etype;
+}
+
+static gboolean
+_debug_client (const char *id,
+               GsmClient  *client,
+               GsmManager *manager)
+{
+        g_debug ("GsmManager: Client %s", gsm_client_peek_id (client));
+        return FALSE;
+}
+
+static void
+debug_clients (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+        priv = gsm_manager_get_instance_private (manager);
+        gsm_store_foreach (priv->clients,
+                           (GsmStoreFunc)_debug_client,
+                           manager);
+}
+
+static gboolean
+_debug_inhibitor (const char    *id,
+                  GsmInhibitor  *inhibitor,
+                  GsmManager    *manager)
+{
+        g_debug ("GsmManager: Inhibitor app:%s client:%s bus-name:%s reason:%s",
+                 gsm_inhibitor_peek_app_id (inhibitor),
+                 gsm_inhibitor_peek_client_id (inhibitor),
+                 gsm_inhibitor_peek_bus_name (inhibitor),
+                 gsm_inhibitor_peek_reason (inhibitor));
+        return FALSE;
+}
+
+static void
+debug_inhibitors (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        gsm_store_foreach (priv->inhibitors,
+                           (GsmStoreFunc)_debug_inhibitor,
+                           manager);
+}
+
+static gboolean
+_find_by_cookie (const char   *id,
+                 GsmInhibitor *inhibitor,
+                 guint        *cookie_ap)
+{
+        guint cookie_b;
+
+        cookie_b = gsm_inhibitor_peek_cookie (inhibitor);
+
+        return (*cookie_ap == cookie_b);
+}
+
+static gboolean
+_find_by_startup_id (const char *id,
+                     GsmClient  *client,
+                     const char *startup_id_a)
+{
+        const char *startup_id_b;
+
+        startup_id_b = gsm_client_peek_startup_id (client);
+        if (IS_STRING_EMPTY (startup_id_b)) {
+                return FALSE;
+        }
+
+        return (strcmp (startup_id_a, startup_id_b) == 0);
+}
+
+static void
+app_condition_changed (GsmApp     *app,
+                       gboolean    condition,
+                       GsmManager *manager)
+{
+        GsmClient *client;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        g_debug ("GsmManager: app:%s condition changed condition:%d",
+                 gsm_app_peek_id (app),
+                 condition);
+
+        client = (GsmClient *)gsm_store_find (priv->clients,
+                                              (GsmStoreFunc)_find_by_startup_id,
+                                              (char *)gsm_app_peek_startup_id (app));
+
+        if (condition) {
+                if (!gsm_app_is_running (app) && client == NULL) {
+                        GError  *error = NULL;
+                        gboolean UNUSED_VARIABLE res;
+
+                        g_debug ("GsmManager: starting app '%s'", gsm_app_peek_id (app));
+
+                        res = gsm_app_start (app, &error);
+                        if (error != NULL) {
+                                g_warning ("Not able to start app from its condition: %s",
+                                           error->message);
+                                g_error_free (error);
+                        }
+                } else {
+                        g_debug ("GsmManager: not starting - app still running '%s'", gsm_app_peek_id (app));
+                }
+        } else {
+                GError  *error;
+                gboolean UNUSED_VARIABLE res;
+
+                if (client != NULL) {
+                        /* Kill client in case condition if false and make sure it won't
+                         * be automatically restarted by adding the client to
+                         * condition_clients */
+                        priv->condition_clients =
+                                g_slist_prepend (priv->condition_clients, client);
+
+                        g_debug ("GsmManager: stopping client %s for app", gsm_client_peek_id (client));
+
+                        error = NULL;
+                        res = gsm_client_stop (client, &error);
+                        if (error != NULL) {
+                                g_warning ("Not able to stop app client from its condition: %s",
+                                           error->message);
+                                g_error_free (error);
+                        }
+                } else {
+                        g_debug ("GsmManager: stopping app %s", gsm_app_peek_id (app));
+
+                        /* If we don't have a client then we should try to kill the app,
+                         * if it is running */
+                        error = NULL;
+                        if (gsm_app_is_running (app)) {
+                                res = gsm_app_stop (app, &error);
+                                if (error != NULL) {
+                                       g_warning ("Not able to stop app from its condition: %s",
+                                                error->message);
+                                   g_error_free (error);
+                                }
+                        }
+                }
+        }
+}
+
+static const char *
+phase_num_to_name (guint phase)
+{
+        const char *name;
+
+        switch (phase) {
+        case GSM_MANAGER_PHASE_STARTUP:
+                name = "STARTUP";
+                break;
+        case GSM_MANAGER_PHASE_INITIALIZATION:
+                name = "INITIALIZATION";
+                break;
+        case GSM_MANAGER_PHASE_WINDOW_MANAGER:
+                name = "WINDOW_MANAGER";
+                break;
+        case GSM_MANAGER_PHASE_PANEL:
+                name = "PANEL";
+                break;
+        case GSM_MANAGER_PHASE_DESKTOP:
+                name = "DESKTOP";
+                break;
+        case GSM_MANAGER_PHASE_APPLICATION:
+                name = "APPLICATION";
+                break;
+        case GSM_MANAGER_PHASE_RUNNING:
+                name = "RUNNING";
+                break;
+        case GSM_MANAGER_PHASE_QUERY_END_SESSION:
+                name = "QUERY_END_SESSION";
+                break;
+        case GSM_MANAGER_PHASE_END_SESSION:
+                name = "END_SESSION";
+                break;
+        case GSM_MANAGER_PHASE_EXIT:
+                name = "EXIT";
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        return name;
+}
+
+static void start_phase (GsmManager *manager);
+
+static void
+quit_request_completed_consolekit (GsmConsolekit *consolekit,
+                                   GError        *error,
+                                   gpointer       user_data)
+{
+        MdmLogoutAction fallback_action = GPOINTER_TO_INT (user_data);
+
+        if (error != NULL) {
+                mdm_set_logout_action (fallback_action);
+        }
+
+        g_object_unref (consolekit);
+
+        gtk_main_quit ();
+}
+
+#ifdef HAVE_SYSTEMD
+static void
+quit_request_completed_systemd (GsmSystemd *systemd,
+                                GError     *error,
+                                gpointer    user_data)
+{
+        MdmLogoutAction fallback_action = GPOINTER_TO_INT (user_data);
+
+        if (error != NULL) {
+                mdm_set_logout_action (fallback_action);
+        }
+
+        g_object_unref (systemd);
+
+        gtk_main_quit ();
+}
+#endif
+
+static void
+gsm_manager_quit (GsmManager *manager)
+{
+        GsmConsolekit *consolekit;
+        GsmManagerPrivate *priv;
+#ifdef HAVE_SYSTEMD
+        GsmSystemd *systemd;
+#endif
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* See the comment in request_reboot() for some more details about how
+         * this works. */
+
+        switch (priv->logout_type) {
+        case GSM_MANAGER_LOGOUT_LOGOUT:
+                gtk_main_quit ();
+                break;
+        case GSM_MANAGER_LOGOUT_REBOOT:
+        case GSM_MANAGER_LOGOUT_REBOOT_INTERACT:
+                mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE);
+
+#ifdef HAVE_SYSTEMD
+                if (LOGIND_RUNNING()) {
+                    systemd = gsm_get_systemd ();
+                    g_signal_connect (systemd,
+                                      "request-completed",
+                                      G_CALLBACK (quit_request_completed_systemd),
+                                      GINT_TO_POINTER (MDM_LOGOUT_ACTION_REBOOT));
+                    gsm_systemd_attempt_restart (systemd);
+                }
+                else {
+#endif
+                consolekit = gsm_get_consolekit ();
+                g_signal_connect (consolekit,
+                                  "request-completed",
+                                  G_CALLBACK (quit_request_completed_consolekit),
+                                  GINT_TO_POINTER (MDM_LOGOUT_ACTION_REBOOT));
+                gsm_consolekit_attempt_restart (consolekit);
+#ifdef HAVE_SYSTEMD
+                }
+#endif
+                break;
+        case GSM_MANAGER_LOGOUT_REBOOT_MDM:
+                mdm_set_logout_action (MDM_LOGOUT_ACTION_REBOOT);
+                gtk_main_quit ();
+                break;
+        case GSM_MANAGER_LOGOUT_SHUTDOWN:
+        case GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
+                mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE);
+
+#ifdef HAVE_SYSTEMD
+                if (LOGIND_RUNNING()) {
+                    systemd = gsm_get_systemd ();
+                    g_signal_connect (systemd,
+                                      "request-completed",
+                                      G_CALLBACK (quit_request_completed_systemd),
+                                      GINT_TO_POINTER (MDM_LOGOUT_ACTION_SHUTDOWN));
+                    gsm_systemd_attempt_stop (systemd);
+                }
+                else {
+#endif
+                consolekit = gsm_get_consolekit ();
+                g_signal_connect (consolekit,
+                                  "request-completed",
+                                  G_CALLBACK (quit_request_completed_consolekit),
+                                  GINT_TO_POINTER (MDM_LOGOUT_ACTION_SHUTDOWN));
+                gsm_consolekit_attempt_stop (consolekit);
+#ifdef HAVE_SYSTEMD
+                }
+#endif
+                break;
+        case GSM_MANAGER_LOGOUT_SHUTDOWN_MDM:
+                mdm_set_logout_action (MDM_LOGOUT_ACTION_SHUTDOWN);
+                gtk_main_quit ();
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+}
+
+static void
+end_phase (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+        gboolean start_next_phase = TRUE;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        g_debug ("GsmManager: ending phase %s\n",
+                 phase_num_to_name (priv->phase));
+
+        g_slist_free (priv->pending_apps);
+        priv->pending_apps = NULL;
+
+        g_slist_free (priv->query_clients);
+        priv->query_clients = NULL;
+
+        g_slist_free (priv->next_query_clients);
+        priv->next_query_clients = NULL;
+
+        if (priv->phase_timeout_id > 0) {
+                g_source_remove (priv->phase_timeout_id);
+                priv->phase_timeout_id = 0;
+        }
+
+        switch (priv->phase) {
+        case GSM_MANAGER_PHASE_STARTUP:
+        case GSM_MANAGER_PHASE_INITIALIZATION:
+        case GSM_MANAGER_PHASE_WINDOW_MANAGER:
+        case GSM_MANAGER_PHASE_PANEL:
+        case GSM_MANAGER_PHASE_DESKTOP:
+        case GSM_MANAGER_PHASE_APPLICATION:
+                break;
+        case GSM_MANAGER_PHASE_RUNNING:
+                if (_log_out_is_locked_down (manager)) {
+                        g_warning ("Unable to logout: Logout has been locked down");
+                        start_next_phase = FALSE;
+                }
+                break;
+        case GSM_MANAGER_PHASE_QUERY_END_SESSION:
+                break;
+        case GSM_MANAGER_PHASE_END_SESSION:
+                if (auto_save_is_enabled (manager))
+                        maybe_save_session (manager);
+                break;
+        case GSM_MANAGER_PHASE_EXIT:
+                start_next_phase = FALSE;
+                gsm_manager_quit (manager);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        if (start_next_phase) {
+                priv->phase++;
+                start_phase (manager);
+        }
+}
+
+static void
+app_registered (GsmApp     *app,
+                GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        priv->pending_apps = g_slist_remove (priv->pending_apps, app);
+        g_signal_handlers_disconnect_by_func (app, app_registered, manager);
+
+        if (priv->pending_apps == NULL) {
+                if (priv->phase_timeout_id > 0) {
+                        g_source_remove (priv->phase_timeout_id);
+                        priv->phase_timeout_id = 0;
+                }
+
+                end_phase (manager);
+        }
+}
+
+static gboolean
+on_phase_timeout (GsmManager *manager)
+{
+        GSList *a;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        priv->phase_timeout_id = 0;
+
+        switch (priv->phase) {
+        case GSM_MANAGER_PHASE_STARTUP:
+        case GSM_MANAGER_PHASE_INITIALIZATION:
+        case GSM_MANAGER_PHASE_WINDOW_MANAGER:
+        case GSM_MANAGER_PHASE_PANEL:
+        case GSM_MANAGER_PHASE_DESKTOP:
+        case GSM_MANAGER_PHASE_APPLICATION:
+                for (a = priv->pending_apps; a; a = a->next) {
+                        g_warning ("Application '%s' failed to register before timeout",
+                                   gsm_app_peek_app_id (a->data));
+                        g_signal_handlers_disconnect_by_func (a->data, app_registered, manager);
+                        /* FIXME: what if the app was filling in a required slot? */
+                }
+                break;
+        case GSM_MANAGER_PHASE_RUNNING:
+                break;
+        case GSM_MANAGER_PHASE_QUERY_END_SESSION:
+        case GSM_MANAGER_PHASE_END_SESSION:
+                break;
+        case GSM_MANAGER_PHASE_EXIT:
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+
+        end_phase (manager);
+
+        return FALSE;
+}
+
+static gboolean
+_autostart_delay_timeout (GsmApp *app)
+{
+        GError *error = NULL;
+        gboolean res;
+
+        if (!gsm_app_peek_is_disabled (app)
+            && !gsm_app_peek_is_conditionally_disabled (app)) {
+                res = gsm_app_start (app, &error);
+                if (!res) {
+                        if (error != NULL) {
+                                g_warning ("Could not launch application '%s': %s",
+                                           gsm_app_peek_app_id (app),
+                                           error->message);
+                                g_error_free (error);
+                        }
+                }
+        }
+
+        g_object_unref (app);
+
+        return FALSE;
+}
+
+static gboolean
+_start_app (const char *id,
+            GsmApp     *app,
+            GsmManager *manager)
+{
+        GError  *error;
+        gboolean res;
+        int      delay;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (gsm_app_peek_phase (app) != priv->phase) {
+                goto out;
+        }
+
+        /* Keep track of app autostart condition in order to react
+         * accordingly in the future. */
+        g_signal_connect (app,
+                          "condition-changed",
+                          G_CALLBACK (app_condition_changed),
+                          manager);
+
+        if (gsm_app_peek_is_disabled (app)
+            || gsm_app_peek_is_conditionally_disabled (app)) {
+                g_debug ("GsmManager: Skipping disabled app: %s", id);
+                goto out;
+        }
+
+        delay = gsm_app_peek_autostart_delay (app);
+        if (delay > 0) {
+                g_timeout_add_seconds (delay,
+                                       (GSourceFunc)_autostart_delay_timeout,
+                                       g_object_ref (app));
+                g_debug ("GsmManager: %s is scheduled to start in %d seconds", id, delay);
+                goto out;
+        }
+
+        error = NULL;
+        res = gsm_app_start (app, &error);
+        if (!res) {
+                if (error != NULL) {
+                        g_warning ("Could not launch application '%s': %s",
+                                   gsm_app_peek_app_id (app),
+                                   error->message);
+                        g_error_free (error);
+                        error = NULL;
+                }
+                goto out;
+        }
+
+        if (priv->phase < GSM_MANAGER_PHASE_APPLICATION) {
+                g_signal_connect (app,
+                                  "exited",
+                                  G_CALLBACK (app_registered),
+                                  manager);
+                g_signal_connect (app,
+                                  "registered",
+                                  G_CALLBACK (app_registered),
+                                  manager);
+                priv->pending_apps = g_slist_prepend (priv->pending_apps, app);
+        }
+ out:
+        return FALSE;
+}
+
+static void
+do_phase_startup (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        gsm_store_foreach (priv->apps,
+                           (GsmStoreFunc)_start_app,
+                           manager);
+
+        if (priv->pending_apps != NULL) {
+                if (priv->phase < GSM_MANAGER_PHASE_APPLICATION) {
+                        priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_PHASE_TIMEOUT,
+                                                                        (GSourceFunc)on_phase_timeout,
+                                                                        manager);
+                }
+        } else {
+                end_phase (manager);
+        }
+}
+
+typedef struct {
+        GsmManager *manager;
+        guint       flags;
+} ClientEndSessionData;
+
+static gboolean
+_client_end_session (GsmClient            *client,
+                     ClientEndSessionData *data)
+{
+        gboolean ret;
+        GError  *error;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (data->manager);
+
+        error = NULL;
+        ret = gsm_client_end_session (client, data->flags, &error);
+        if (! ret) {
+                g_warning ("Unable to query client: %s", error->message);
+                g_error_free (error);
+                /* FIXME: what should we do if we can't communicate with client? */
+        } else {
+                g_debug ("GsmManager: adding client to end-session clients: %s", gsm_client_peek_id (client));
+                priv->query_clients = g_slist_prepend (priv->query_clients,
+                                                       client);
+        }
+
+        return FALSE;
+}
+
+static gboolean
+_client_end_session_helper (const char           *id,
+                            GsmClient            *client,
+                            ClientEndSessionData *data)
+{
+        return _client_end_session (client, data);
+}
+
+static void
+do_phase_end_session (GsmManager *manager)
+{
+        ClientEndSessionData data;
+        GsmManagerPrivate *priv;
+
+        data.manager = manager;
+        data.flags = 0;
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL;
+        }
+        if (auto_save_is_enabled (manager)) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_SAVE;
+        }
+
+        if (priv->phase_timeout_id > 0) {
+                g_source_remove (priv->phase_timeout_id);
+                priv->phase_timeout_id = 0;
+        }
+
+        if (gsm_store_size (priv->clients) > 0) {
+                priv->phase_timeout_id = g_timeout_add_seconds (GSM_MANAGER_PHASE_TIMEOUT,
+                                                                (GSourceFunc)on_phase_timeout,
+                                                                manager);
+
+                gsm_store_foreach (priv->clients,
+                                   (GsmStoreFunc)_client_end_session_helper,
+                                   &data);
+        } else {
+                end_phase (manager);
+        }
+}
+
+static void
+do_phase_end_session_part_2 (GsmManager *manager)
+{
+        ClientEndSessionData data;
+        GsmManagerPrivate *priv;
+
+        data.manager = manager;
+        data.flags = 0;
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL;
+        }
+        if (auto_save_is_enabled (manager)) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_SAVE;
+        }
+        data.flags |= GSM_CLIENT_END_SESSION_FLAG_LAST;
+
+        /* keep the timeout that was started at the beginning of the
+         * GSM_MANAGER_PHASE_END_SESSION phase */
+
+        if (g_slist_length (priv->next_query_clients) > 0) {
+                g_slist_foreach (priv->next_query_clients,
+                                 (GFunc)_client_end_session,
+                                 &data);
+
+                g_slist_free (priv->next_query_clients);
+                priv->next_query_clients = NULL;
+        } else {
+                end_phase (manager);
+        }
+}
+
+static gboolean
+_client_stop (const char *id,
+              GsmClient  *client,
+              gpointer    user_data)
+{
+        gboolean ret;
+        GError  *error;
+
+        error = NULL;
+        ret = gsm_client_stop (client, &error);
+        if (! ret) {
+                g_warning ("Unable to stop client: %s", error->message);
+                g_error_free (error);
+                /* FIXME: what should we do if we can't communicate with client? */
+        } else {
+                g_debug ("GsmManager: stopped client: %s", gsm_client_peek_id (client));
+        }
+
+        return FALSE;
+}
+
+#ifdef HAVE_SYSTEMD
+static void
+maybe_restart_user_bus (GsmManager *manager)
+{
+        GsmSystemd *systemd;
+        GsmManagerPrivate *priv;
+        GDBusConnection *connection;
+
+        g_autoptr(GVariant) reply = NULL;
+        g_autoptr(GError) error = NULL;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->dbus_disconnected)
+                return;
+
+        systemd = gsm_get_systemd ();
+
+        if (!gsm_systemd_is_last_session_for_user (systemd))
+                return;
+
+        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+
+        if (error != NULL) {
+                g_debug ("GsmManager: failed to connect to session bus: %s", error->message);
+                return;
+        }
+
+        reply = g_dbus_connection_call_sync (connection,
+                                             "org.freedesktop.systemd1",
+                                             "/org/freedesktop/systemd1",
+                                             "org.freedesktop.systemd1.Manager",
+                                             "TryRestartUnit",
+                                             g_variant_new ("(ss)", "dbus.service", "replace"),
+                                             NULL,
+                                             G_DBUS_CALL_FLAGS_NONE,
+                                             -1,
+                                             NULL,
+                                             &error);
+
+        if (error != NULL) {
+                g_debug ("GsmManager: reloading user bus failed: %s", error->message);
+        }
+}
+#endif
+
+static void
+do_phase_exit (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (gsm_store_size (priv->clients) > 0) {
+                gsm_store_foreach (priv->clients,
+                                   (GsmStoreFunc)_client_stop,
+                                   NULL);
+        }
+
+#ifdef HAVE_SYSTEMD
+        maybe_restart_user_bus (manager);
+#endif
+
+        end_phase (manager);
+}
+
+static gboolean
+_client_query_end_session (const char           *id,
+                           GsmClient            *client,
+                           ClientEndSessionData *data)
+{
+        gboolean ret;
+        GError  *error;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (data->manager);
+
+        error = NULL;
+        ret = gsm_client_query_end_session (client, data->flags, &error);
+        if (! ret) {
+                g_warning ("Unable to query client: %s", error->message);
+                g_error_free (error);
+                /* FIXME: what should we do if we can't communicate with client? */
+        } else {
+                g_debug ("GsmManager: adding client to query clients: %s", gsm_client_peek_id (client));
+                priv->query_clients = g_slist_prepend (priv->query_clients, client);
+        }
+
+        return FALSE;
+}
+
+static gboolean
+inhibitor_has_flag (gpointer      key,
+                    GsmInhibitor *inhibitor,
+                    gpointer      data)
+{
+        guint flag;
+        guint flags;
+
+        flag = GPOINTER_TO_UINT (data);
+
+        flags = gsm_inhibitor_peek_flags (inhibitor);
+
+        return (flags & flag);
+}
+
+static gboolean
+gsm_manager_is_logout_inhibited (GsmManager *manager)
+{
+        GsmInhibitor *inhibitor;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->inhibitors == NULL) {
+                return FALSE;
+        }
+
+        inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors,
+                                                    (GsmStoreFunc)inhibitor_has_flag,
+                                                    GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_LOGOUT));
+        if (inhibitor == NULL) {
+                return FALSE;
+        }
+        return TRUE;
+}
+
+static gboolean
+gsm_manager_is_idle_inhibited (GsmManager *manager)
+{
+        GsmInhibitor *inhibitor;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->inhibitors == NULL) {
+                return FALSE;
+        }
+
+        inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors,
+                                                    (GsmStoreFunc)inhibitor_has_flag,
+                                                    GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_IDLE));
+        if (inhibitor == NULL) {
+                return FALSE;
+        }
+        return TRUE;
+}
+
+static gboolean
+_client_cancel_end_session (const char *id,
+                            GsmClient  *client,
+                            GsmManager *manager)
+{
+        gboolean res;
+        GError  *error;
+
+        error = NULL;
+        res = gsm_client_cancel_end_session (client, &error);
+        if (! res) {
+                g_warning ("Unable to cancel end session: %s", error->message);
+                g_error_free (error);
+        }
+
+        return FALSE;
+}
+
+static gboolean
+inhibitor_is_jit (gpointer      key,
+                  GsmInhibitor *inhibitor,
+                  GsmManager   *manager)
+{
+        gboolean    matches;
+        const char *id;
+
+        id = gsm_inhibitor_peek_client_id (inhibitor);
+
+        matches = (id != NULL && id[0] != '\0');
+
+        return matches;
+}
+
+static void
+cancel_end_session (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* just ignore if received outside of shutdown */
+        if (priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                return;
+        }
+
+        /* switch back to running phase */
+        g_debug ("GsmManager: Cancelling the end of session");
+
+        /* remove the dialog before we remove the inhibitors, else the dialog
+         * will activate itself automatically when the last inhibitor will be
+         * removed */
+        if (priv->inhibit_dialog)
+                gtk_widget_destroy (GTK_WIDGET (priv->inhibit_dialog));
+        priv->inhibit_dialog = NULL;
+
+        /* clear all JIT inhibitors */
+        gsm_store_foreach_remove (priv->inhibitors,
+                                  (GsmStoreFunc)inhibitor_is_jit,
+                                  (gpointer)manager);
+
+        gsm_store_foreach (priv->clients,
+                           (GsmStoreFunc)_client_cancel_end_session,
+                           NULL);
+
+        gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_RUNNING);
+        priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL;
+
+        priv->logout_type = GSM_MANAGER_LOGOUT_NONE;
+        mdm_set_logout_action (MDM_LOGOUT_ACTION_NONE);
+
+        start_phase (manager);
+}
+
+static gboolean
+process_is_running (const char * name)
+{
+       int num_processes;
+       char * command = g_strdup_printf ("pidof %s | wc -l", name);
+       FILE *fp = popen(command, "r");
+
+       if (fscanf(fp, "%d", &num_processes) != 1)
+           num_processes = 0;
+
+       pclose(fp);
+       g_free (command);
+
+       if (num_processes > 0) {
+           return TRUE;
+       }
+       else {
+           return FALSE;
+       }
+}
+
+static void
+manager_switch_user (GsmManager *manager)
+{
+        GError  *error;
+        gboolean res;
+        char    *command;
+        const gchar *xdg_seat_path = g_getenv ("XDG_SEAT_PATH");
+
+        /* We have to do this here and in request_switch_user() because this
+         * function can be called at a later time, not just directly after
+         * request_switch_user(). */
+        if (_switch_user_is_locked_down (manager)) {
+                g_warning ("Unable to switch user: User switching has been locked down");
+                return;
+        }
+
+        if (process_is_running("mdm")) {
+                /* MDM */
+                command = g_strdup_printf ("%s %s",
+                                           MDM_FLEXISERVER_COMMAND,
+                                           MDM_FLEXISERVER_ARGS);
+
+                error = NULL;
+                res = g_spawn_command_line_sync (command, NULL, NULL, NULL, &error);
+
+                g_free (command);
+
+                if (! res) {
+                        g_debug ("GsmManager: Unable to start MDM greeter: %s", error->message);
+                        g_error_free (error);
+                }
+        }
+        else if (process_is_running("gdm") || process_is_running("gdm3") || process_is_running("gdm-binary")) {
+                /* GDM */
+                command = g_strdup_printf ("%s %s",
+                                           GDM_FLEXISERVER_COMMAND,
+                                           GDM_FLEXISERVER_ARGS);
+
+                error = NULL;
+                res = g_spawn_command_line_sync (command, NULL, NULL, NULL, &error);
+
+                g_free (command);
+
+                if (! res) {
+                        g_debug ("GsmManager: Unable to start GDM greeter: %s", error->message);
+                        g_error_free (error);
+                }
+        }
+        else if (xdg_seat_path != NULL) {
+                /* LightDM */
+                GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START;
+                GDBusProxy *proxy = NULL;
+                error = NULL;
+
+                proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
+                                                      flags,
+                                                      NULL,
+                                                      "org.freedesktop.DisplayManager",
+                                                      xdg_seat_path,
+                                                      "org.freedesktop.DisplayManager.Seat",
+                                                      NULL,
+                                                      &error);
+                if (proxy != NULL) {
+                        g_dbus_proxy_call_sync (proxy,
+                                                "SwitchToGreeter",
+                                                g_variant_new ("()"),
+                                                G_DBUS_CALL_FLAGS_NONE,
+                                                -1,
+                                                NULL,
+                                                NULL);
+                        g_object_unref (proxy);
+                }
+                else {
+                        g_debug ("GsmManager: Unable to start LightDM greeter: %s", error->message);
+                        g_error_free (error);
+                }
+         }
+}
+
+static gboolean
+sleep_lock_is_enabled (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->settings_screensaver != NULL)
+                return g_settings_get_boolean (priv->settings_screensaver,
+                                               KEY_SLEEP_LOCK);
+        else
+                return FALSE;
+}
+
+static void
+manager_perhaps_lock (GsmManager *manager)
+{
+        gchar **screen_locker_command;
+
+        if ((screen_locker_command = gsm_get_screen_locker_command ()) != NULL) {
+                GError *error = NULL;
+
+                /* only lock if mate-screensaver is set to lock */
+                if (!g_strcmp0 (screen_locker_command[0], "mate-screensaver-command") &&
+                    !sleep_lock_is_enabled (manager)) {
+                        goto clear_screen_locker_command;
+                }
+
+                /* do this sync to ensure it's on the screen when we start suspending */
+                g_spawn_sync (NULL, screen_locker_command, NULL,
+                              G_SPAWN_DEFAULT | G_SPAWN_SEARCH_PATH,
+                              NULL, NULL, NULL, NULL, NULL, &error);
+
+                if (error) {
+                        g_warning ("Couldn't lock screen: %s", error->message);
+                        g_error_free (error);
+                }
+
+        } else {
+                g_warning ("Couldn't find any screen locker");
+        }
+
+clear_screen_locker_command:
+
+        g_strfreev (screen_locker_command);
+}
+
+static void
+manager_attempt_hibernate (GsmManager *manager)
+{
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+
+                GsmSystemd *systemd;
+
+                systemd = gsm_get_systemd ();
+
+                /* lock the screen before we suspend */
+                manager_perhaps_lock (manager);
+
+                gsm_systemd_attempt_hibernate (systemd);
+        }
+        else {
+#endif
+        GsmConsolekit *consolekit;
+        consolekit = gsm_get_consolekit ();
+
+        gboolean can_hibernate = gsm_consolekit_can_hibernate (consolekit);
+        if (can_hibernate) {
+                /* lock the screen before we suspend */
+                manager_perhaps_lock (manager);
+
+                gsm_consolekit_attempt_hibernate (consolekit);
+        }
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+}
+
+static void
+manager_attempt_suspend (GsmManager *manager)
+{
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+
+                GsmSystemd *systemd;
+
+                systemd = gsm_get_systemd ();
+
+                /* lock the screen before we suspend */
+                manager_perhaps_lock (manager);
+
+                gsm_systemd_attempt_suspend (systemd);
+        }
+        else {
+#endif
+        GsmConsolekit *consolekit;
+        consolekit = gsm_get_consolekit ();
+
+        gboolean can_suspend = gsm_consolekit_can_suspend (consolekit);
+        if (can_suspend) {
+                /* lock the screen before we suspend */
+                manager_perhaps_lock (manager);
+
+                gsm_consolekit_attempt_suspend (consolekit);
+        }
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+}
+
+static void
+do_inhibit_dialog_action (GsmManager *manager,
+                          int         action)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        switch (action) {
+        case GSM_LOGOUT_ACTION_SWITCH_USER:
+                manager_switch_user (manager);
+                break;
+        case GSM_LOGOUT_ACTION_HIBERNATE:
+                manager_attempt_hibernate (manager);
+                break;
+        case GSM_LOGOUT_ACTION_SLEEP:
+                manager_attempt_suspend (manager);
+                break;
+        case GSM_LOGOUT_ACTION_SHUTDOWN:
+        case GSM_LOGOUT_ACTION_REBOOT:
+        case GSM_LOGOUT_ACTION_LOGOUT:
+                priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_FORCE;
+                end_phase (manager);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+}
+
+static void
+inhibit_dialog_response (GsmInhibitDialog *dialog,
+                         guint             response_id,
+                         GsmManager       *manager)
+{
+        int action;
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: Inhibit dialog response: %d", response_id);
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* must destroy dialog before cancelling since we'll
+           remove JIT inhibitors and we don't want to trigger
+           action. */
+        g_object_get (dialog, "action", &action, NULL);
+        gtk_widget_destroy (GTK_WIDGET (dialog));
+        priv->inhibit_dialog = NULL;
+
+        /* In case of dialog cancel, switch user, hibernate and
+         * suspend, we just perform the respective action and return,
+         * without shutting down the session. */
+        switch (response_id) {
+        case GTK_RESPONSE_CANCEL:
+        case GTK_RESPONSE_NONE:
+        case GTK_RESPONSE_DELETE_EVENT:
+                if (action == GSM_LOGOUT_ACTION_LOGOUT
+                    || action == GSM_LOGOUT_ACTION_SHUTDOWN
+                    || action == GSM_LOGOUT_ACTION_REBOOT) {
+                        cancel_end_session (manager);
+                }
+                break;
+        case GTK_RESPONSE_ACCEPT:
+                g_debug ("GsmManager: doing action %d", action);
+                do_inhibit_dialog_action (manager, action);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+}
+
+static void
+query_end_session_complete (GsmManager *manager)
+{
+        GsmLogoutAction action;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        g_debug ("GsmManager: query end session complete");
+
+        /* Remove the timeout since this can be called from outside the timer
+         * and we don't want to have it called twice */
+        if (priv->query_timeout_id > 0) {
+                g_source_remove (priv->query_timeout_id);
+                priv->query_timeout_id = 0;
+        }
+
+        if (! gsm_manager_is_logout_inhibited (manager)) {
+                end_phase (manager);
+                return;
+        }
+
+        if (priv->inhibit_dialog != NULL) {
+                g_debug ("GsmManager: inhibit dialog already up");
+                gtk_window_present (GTK_WINDOW (priv->inhibit_dialog));
+                return;
+        }
+
+        switch (priv->logout_type) {
+        case GSM_MANAGER_LOGOUT_LOGOUT:
+                action = GSM_LOGOUT_ACTION_LOGOUT;
+                break;
+        case GSM_MANAGER_LOGOUT_REBOOT:
+        case GSM_MANAGER_LOGOUT_REBOOT_INTERACT:
+        case GSM_MANAGER_LOGOUT_REBOOT_MDM:
+                action = GSM_LOGOUT_ACTION_REBOOT;
+                break;
+        case GSM_MANAGER_LOGOUT_SHUTDOWN:
+        case GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT:
+        case GSM_MANAGER_LOGOUT_SHUTDOWN_MDM:
+                action = GSM_LOGOUT_ACTION_SHUTDOWN;
+                break;
+        default:
+                g_warning ("Unexpected logout type %d when creating inhibit dialog",
+                           priv->logout_type);
+                action = GSM_LOGOUT_ACTION_LOGOUT;
+                break;
+        }
+
+        /* Note: GSM_LOGOUT_ACTION_SHUTDOWN and GSM_LOGOUT_ACTION_REBOOT are
+         * actually handled the same way as GSM_LOGOUT_ACTION_LOGOUT in the
+         * inhibit dialog; the action, if the button is clicked, will be to
+         * simply go to the next phase. */
+        priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors,
+                                                       priv->clients,
+                                                       action);
+
+        g_signal_connect (priv->inhibit_dialog,
+                          "response",
+                          G_CALLBACK (inhibit_dialog_response),
+                          manager);
+        gtk_widget_show (priv->inhibit_dialog);
+
+}
+
+static guint32
+generate_cookie (void)
+{
+        guint32 cookie;
+
+        cookie = (guint32)g_random_int_range (1, G_MAXINT32);
+
+        return cookie;
+}
+
+static guint32
+_generate_unique_cookie (GsmManager *manager)
+{
+        guint32 cookie;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        do {
+                cookie = generate_cookie ();
+        } while (gsm_store_find (priv->inhibitors, (GsmStoreFunc)_find_by_cookie, &cookie) != NULL);
+
+        return cookie;
+}
+
+static gboolean
+_on_query_end_session_timeout (GsmManager *manager)
+{
+        GSList *l;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        priv->query_timeout_id = 0;
+
+        g_debug ("GsmManager: query end session timed out");
+
+        for (l = priv->query_clients; l != NULL; l = l->next) {
+                guint         cookie;
+                GsmInhibitor *inhibitor;
+                const char   *bus_name;
+                char         *app_id;
+
+                g_warning ("Client '%s' failed to reply before timeout",
+                           gsm_client_peek_id (l->data));
+
+                /* Don't add "not responding" inhibitors if logout is forced
+                 */
+                if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) {
+                        continue;
+                }
+
+                /* Add JIT inhibit for unresponsive client */
+                if (GSM_IS_DBUS_CLIENT (l->data)) {
+                        bus_name = gsm_dbus_client_get_bus_name (l->data);
+                } else {
+                        bus_name = NULL;
+                }
+
+                app_id = g_strdup (gsm_client_peek_app_id (l->data));
+                if (IS_STRING_EMPTY (app_id)) {
+                        /* XSMP clients don't give us an app id unless we start them */
+                        g_free (app_id);
+                        app_id = gsm_client_get_app_name (l->data);
+                }
+
+                cookie = _generate_unique_cookie (manager);
+                inhibitor = gsm_inhibitor_new_for_client (gsm_client_peek_id (l->data),
+                                                          app_id,
+                                                          GSM_INHIBITOR_FLAG_LOGOUT,
+                                                          _("Not responding"),
+                                                          bus_name,
+                                                          cookie);
+                g_free (app_id);
+                gsm_store_add (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor));
+                g_object_unref (inhibitor);
+        }
+
+        g_slist_free (priv->query_clients);
+        priv->query_clients = NULL;
+
+        query_end_session_complete (manager);
+
+        return FALSE;
+}
+
+static void
+do_phase_query_end_session (GsmManager *manager)
+{
+        ClientEndSessionData data;
+        GsmManagerPrivate *priv;
+
+        data.manager = manager;
+        data.flags = 0;
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) {
+                data.flags |= GSM_CLIENT_END_SESSION_FLAG_FORCEFUL;
+        }
+        /* We only query if an app is ready to log out, so we don't use
+         * GSM_CLIENT_END_SESSION_FLAG_SAVE here.
+         */
+
+        debug_clients (manager);
+        g_debug ("GsmManager: sending query-end-session to clients (logout mode: %s)",
+                 priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL? "normal" :
+                 priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE? "forceful":
+                 "no confirmation");
+        gsm_store_foreach (priv->clients,
+                           (GsmStoreFunc)_client_query_end_session,
+                           &data);
+
+        /* This phase doesn't time out unless logout is forced. Typically, this
+         * separate timer is only used to show UI. */
+        priv->query_timeout_id = g_timeout_add_seconds (1, (GSourceFunc)_on_query_end_session_timeout, manager);
+}
+
+static void
+update_idle (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (gsm_manager_is_idle_inhibited (manager)) {
+                gsm_presence_set_idle_enabled (priv->presence, FALSE);
+        } else {
+                gsm_presence_set_idle_enabled (priv->presence, TRUE);
+        }
+}
+
+static void
+start_phase (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        g_debug ("GsmManager: starting phase %s\n",
+                 phase_num_to_name (priv->phase));
+
+        /* reset state */
+        g_slist_free (priv->pending_apps);
+        priv->pending_apps = NULL;
+        g_slist_free (priv->query_clients);
+        priv->query_clients = NULL;
+        g_slist_free (priv->next_query_clients);
+        priv->next_query_clients = NULL;
+
+        if (priv->query_timeout_id > 0) {
+                g_source_remove (priv->query_timeout_id);
+                priv->query_timeout_id = 0;
+        }
+        if (priv->phase_timeout_id > 0) {
+                g_source_remove (priv->phase_timeout_id);
+                priv->phase_timeout_id = 0;
+        }
+
+        switch (priv->phase) {
+        case GSM_MANAGER_PHASE_STARTUP:
+        case GSM_MANAGER_PHASE_INITIALIZATION:
+        case GSM_MANAGER_PHASE_WINDOW_MANAGER:
+        case GSM_MANAGER_PHASE_PANEL:
+        case GSM_MANAGER_PHASE_DESKTOP:
+        case GSM_MANAGER_PHASE_APPLICATION:
+                do_phase_startup (manager);
+                break;
+        case GSM_MANAGER_PHASE_RUNNING:
+                g_signal_emit (manager, signals[SESSION_RUNNING], 0);
+                update_idle (manager);
+                break;
+        case GSM_MANAGER_PHASE_QUERY_END_SESSION:
+                do_phase_query_end_session (manager);
+                break;
+        case GSM_MANAGER_PHASE_END_SESSION:
+                do_phase_end_session (manager);
+                break;
+        case GSM_MANAGER_PHASE_EXIT:
+                do_phase_exit (manager);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+}
+
+static gboolean
+_debug_app_for_phase (const char *id,
+                      GsmApp     *app,
+                      gpointer    data)
+{
+        guint phase;
+
+        phase = GPOINTER_TO_UINT (data);
+
+        if (gsm_app_peek_phase (app) != phase) {
+                return FALSE;
+        }
+
+        g_debug ("GsmManager:\tID: %s\tapp-id:%s\tis-disabled:%d\tis-conditionally-disabled:%d\tis-delayed:%d",
+                 gsm_app_peek_id (app),
+                 gsm_app_peek_app_id (app),
+                 gsm_app_peek_is_disabled (app),
+                 gsm_app_peek_is_conditionally_disabled (app),
+                 (gsm_app_peek_autostart_delay (app) > 0));
+
+        return FALSE;
+}
+
+static void
+debug_app_summary (GsmManager *manager)
+{
+        guint phase;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        g_debug ("GsmManager: App startup summary");
+        for (phase = GSM_MANAGER_PHASE_INITIALIZATION; phase < GSM_MANAGER_PHASE_RUNNING; phase++) {
+                g_debug ("GsmManager: Phase %s", phase_num_to_name (phase));
+                gsm_store_foreach (priv->apps,
+                                   (GsmStoreFunc)_debug_app_for_phase,
+                                   GUINT_TO_POINTER (phase));
+        }
+}
+
+void
+gsm_manager_start (GsmManager *manager)
+{
+        g_debug ("GsmManager: GSM starting to manage");
+
+        g_return_if_fail (GSM_IS_MANAGER (manager));
+
+        gsm_manager_set_phase (manager, GSM_MANAGER_PHASE_INITIALIZATION);
+        debug_app_summary (manager);
+        start_phase (manager);
+}
+
+void
+_gsm_manager_set_renderer (GsmManager *manager,
+                           const char *renderer)
+{
+        GsmManagerPrivate *priv;
+        priv = gsm_manager_get_instance_private (manager);
+        g_free (priv->renderer);
+        priv->renderer = g_strdup (renderer);
+}
+
+static gboolean
+_app_has_app_id (const char   *id,
+                 GsmApp       *app,
+                 const char   *app_id_a)
+{
+        const char *app_id_b;
+
+        app_id_b = gsm_app_peek_app_id (app);
+        return (app_id_b != NULL && strcmp (app_id_a, app_id_b) == 0);
+}
+
+static GsmApp *
+find_app_for_app_id (GsmManager *manager,
+                     const char *app_id)
+{
+        GsmApp *app;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        app = (GsmApp *)gsm_store_find (priv->apps,
+                                        (GsmStoreFunc)_app_has_app_id,
+                                        (char *)app_id);
+        return app;
+}
+
+static gboolean
+inhibitor_has_client_id (gpointer      key,
+                         GsmInhibitor *inhibitor,
+                         const char   *client_id_a)
+{
+        gboolean    matches;
+        const char *client_id_b;
+
+        client_id_b = gsm_inhibitor_peek_client_id (inhibitor);
+
+        matches = FALSE;
+        if (! IS_STRING_EMPTY (client_id_a) && ! IS_STRING_EMPTY (client_id_b)) {
+                matches = (strcmp (client_id_a, client_id_b) == 0);
+                if (matches) {
+                        g_debug ("GsmManager: removing JIT inhibitor for %s for reason '%s'",
+                                 gsm_inhibitor_peek_client_id (inhibitor),
+                                 gsm_inhibitor_peek_reason (inhibitor));
+                }
+        }
+
+        return matches;
+}
+
+static gboolean
+_app_has_startup_id (const char *id,
+                     GsmApp     *app,
+                     const char *startup_id_a)
+{
+        const char *startup_id_b;
+
+        startup_id_b = gsm_app_peek_startup_id (app);
+
+        if (IS_STRING_EMPTY (startup_id_b)) {
+                return FALSE;
+        }
+
+        return (strcmp (startup_id_a, startup_id_b) == 0);
+}
+
+static GsmApp *
+find_app_for_startup_id (GsmManager *manager,
+                        const char *startup_id)
+{
+        GsmApp *found_app;
+        GSList *a;
+        GsmManagerPrivate *priv;
+
+        found_app = NULL;
+        priv = gsm_manager_get_instance_private (manager);
+
+        /* If we're starting up the session, try to match the new client
+         * with one pending apps for the current phase. If not, try to match
+         * with any of the autostarted apps. */
+        if (priv->phase < GSM_MANAGER_PHASE_APPLICATION) {
+                for (a = priv->pending_apps; a != NULL; a = a->next) {
+                        GsmApp *app = GSM_APP (a->data);
+
+                        if (strcmp (startup_id, gsm_app_peek_startup_id (app)) == 0) {
+                                found_app = app;
+                                goto out;
+                        }
+                }
+        } else {
+                GsmApp *app;
+
+                app = (GsmApp *)gsm_store_find (priv->apps,
+                                                (GsmStoreFunc)_app_has_startup_id,
+                                                (char *)startup_id);
+                if (app != NULL) {
+                        found_app = app;
+                        goto out;
+                }
+        }
+ out:
+        return found_app;
+}
+
+static void
+_disconnect_client (GsmManager *manager,
+                    GsmClient  *client)
+{
+        gboolean              is_condition_client;
+        GsmApp               *app;
+        GError               *error;
+        gboolean UNUSED_VARIABLE res;
+        const char           *app_id;
+        const char           *startup_id;
+        gboolean              app_restart;
+        GsmClientRestartStyle client_restart_hint;
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: disconnect client: %s", gsm_client_peek_id (client));
+
+        /* take a ref so it doesn't get finalized */
+        g_object_ref (client);
+
+        gsm_client_set_status (client, GSM_CLIENT_FINISHED);
+
+        is_condition_client = FALSE;
+        priv = gsm_manager_get_instance_private (manager);
+        if (g_slist_find (priv->condition_clients, client)) {
+                priv->condition_clients = g_slist_remove (priv->condition_clients, client);
+
+                is_condition_client = TRUE;
+        }
+
+        /* remove any inhibitors for this client */
+        gsm_store_foreach_remove (priv->inhibitors,
+                                  (GsmStoreFunc)inhibitor_has_client_id,
+                                  (gpointer)gsm_client_peek_id (client));
+
+        app = NULL;
+
+        /* first try to match on startup ID */
+        startup_id = gsm_client_peek_startup_id (client);
+        if (! IS_STRING_EMPTY (startup_id)) {
+                app = find_app_for_startup_id (manager, startup_id);
+
+        }
+
+        /* then try to find matching app-id */
+        if (app == NULL) {
+                app_id = gsm_client_peek_app_id (client);
+                if (! IS_STRING_EMPTY (app_id)) {
+                        g_debug ("GsmManager: disconnect for app '%s'", app_id);
+                        app = find_app_for_app_id (manager, app_id);
+                }
+        }
+
+        if (priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                /* Instead of answering our end session query, the client just exited.
+                 * Treat that as an "okay, end the session" answer.
+                 *
+                 * This call implicitly removes any inhibitors for the client, along
+                 * with removing the client from the pending query list.
+                 */
+                _handle_client_end_session_response (manager,
+                                                     client,
+                                                     TRUE,
+                                                     FALSE,
+                                                     FALSE,
+                                                     "Client exited in "
+                                                     "query end session phase "
+                                                     "instead of end session "
+                                                     "phase");
+        }
+
+        if (priv->dbus_disconnected && GSM_IS_DBUS_CLIENT (client)) {
+                g_debug ("GsmManager: dbus disconnected, not restarting application");
+                goto out;
+        }
+
+        if (app == NULL) {
+                g_debug ("GsmManager: unable to find application for client - not restarting");
+                goto out;
+        }
+
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                g_debug ("GsmManager: in shutdown, not restarting application");
+                goto out;
+        }
+
+        app_restart = gsm_app_peek_autorestart (app);
+        client_restart_hint = gsm_client_peek_restart_style_hint (client);
+
+        /* allow legacy clients to override the app info */
+        if (! app_restart
+            && client_restart_hint != GSM_CLIENT_RESTART_IMMEDIATELY) {
+                g_debug ("GsmManager: autorestart not set, not restarting application");
+                goto out;
+        }
+
+        if (is_condition_client) {
+                g_debug ("GsmManager: app conditionally disabled, not restarting application");
+                goto out;
+        }
+
+        g_debug ("GsmManager: restarting app");
+
+        error = NULL;
+        res = gsm_app_restart (app, &error);
+        if (error != NULL) {
+                g_warning ("Error on restarting session managed app: %s", error->message);
+                g_error_free (error);
+        }
+
+ out:
+        g_object_unref (client);
+}
+
+typedef struct {
+        const char *service_name;
+        GsmManager *manager;
+} RemoveClientData;
+
+static gboolean
+_disconnect_dbus_client (const char       *id,
+                         GsmClient        *client,
+                         RemoveClientData *data)
+{
+        const char *name;
+
+        if (! GSM_IS_DBUS_CLIENT (client)) {
+                return FALSE;
+        }
+
+        /* If no service name, then we simply disconnect all clients */
+        if (!data->service_name) {
+                _disconnect_client (data->manager, client);
+                return TRUE;
+        }
+
+        name = gsm_dbus_client_get_bus_name (GSM_DBUS_CLIENT (client));
+        if (IS_STRING_EMPTY (name)) {
+                return FALSE;
+        }
+
+        if (strcmp (data->service_name, name) == 0) {
+                _disconnect_client (data->manager, client);
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+/**
+ * remove_clients_for_connection:
+ * @manager: a #GsmManager
+ * @service_name: a service name
+ *
+ * Disconnects clients that own @service_name.
+ *
+ * If @service_name is NULL, then disconnects all clients for the connection.
+ */
+static void
+remove_clients_for_connection (GsmManager *manager,
+                               const char *service_name)
+{
+        RemoveClientData data;
+        GsmManagerPrivate *priv;
+
+        data.service_name = service_name;
+        data.manager = manager;
+        priv = gsm_manager_get_instance_private (manager);
+
+        /* disconnect dbus clients for name */
+        gsm_store_foreach_remove (priv->clients,
+                                  (GsmStoreFunc)_disconnect_dbus_client,
+                                  &data);
+
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION
+            && gsm_store_size (priv->clients) == 0) {
+                g_debug ("GsmManager: last client disconnected - exiting");
+                end_phase (manager);
+        }
+}
+
+static gboolean
+inhibitor_has_bus_name (gpointer          key,
+                        GsmInhibitor     *inhibitor,
+                        RemoveClientData *data)
+{
+        gboolean    matches;
+        const char *bus_name_b;
+
+        bus_name_b = gsm_inhibitor_peek_bus_name (inhibitor);
+
+        matches = FALSE;
+        if (! IS_STRING_EMPTY (data->service_name) && ! IS_STRING_EMPTY (bus_name_b)) {
+                matches = (strcmp (data->service_name, bus_name_b) == 0);
+                if (matches) {
+                        g_debug ("GsmManager: removing inhibitor from %s for reason '%s' on connection %s",
+                                 gsm_inhibitor_peek_app_id (inhibitor),
+                                 gsm_inhibitor_peek_reason (inhibitor),
+                                 gsm_inhibitor_peek_bus_name (inhibitor));
+                }
+        }
+
+        return matches;
+}
+
+static void
+remove_inhibitors_for_connection (GsmManager *manager,
+                                  const char *service_name)
+{
+        guint UNUSED_VARIABLE n_removed;
+        RemoveClientData data;
+        GsmManagerPrivate *priv;
+
+        data.service_name = service_name;
+        data.manager = manager;
+        priv = gsm_manager_get_instance_private (manager);
+
+        debug_inhibitors (manager);
+
+        n_removed = gsm_store_foreach_remove (priv->inhibitors,
+                                              (GsmStoreFunc)inhibitor_has_bus_name,
+                                              &data);
+}
+
+static void
+bus_name_owner_changed (DBusGProxy  *bus_proxy,
+                        const char  *service_name,
+                        const char  *old_service_name,
+                        const char  *new_service_name,
+                        GsmManager  *manager)
+{
+        if (strlen (new_service_name) == 0
+            && strlen (old_service_name) > 0) {
+                /* service removed */
+                remove_inhibitors_for_connection (manager, old_service_name);
+                remove_clients_for_connection (manager, old_service_name);
+        } else if (strlen (old_service_name) == 0
+                   && strlen (new_service_name) > 0) {
+                /* service added */
+
+                /* use this if we support automatically registering
+                 * well known bus names */
+        }
+}
+
+static DBusHandlerResult
+gsm_manager_bus_filter (DBusConnection *connection,
+                        DBusMessage    *message,
+                        void           *user_data)
+{
+        GsmManager *manager;
+        GsmManagerPrivate *priv;
+
+        manager = GSM_MANAGER (user_data);
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (dbus_message_is_signal (message,
+                                    DBUS_INTERFACE_LOCAL, "Disconnected") &&
+            strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0) {
+                g_debug ("GsmManager: dbus disconnected; disconnecting dbus clients...");
+                priv->dbus_disconnected = TRUE;
+                remove_clients_for_connection (manager, NULL);
+                /* let other filters get this disconnected signal, so that they
+                 * can handle it too */
+        }
+
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static gboolean
+register_manager (GsmManager *manager)
+{
+        GError *error = NULL;
+        GsmManagerPrivate *priv;
+        DBusConnection *connection;
+
+        error = NULL;
+        priv = gsm_manager_get_instance_private (manager);
+
+        priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (priv->connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                exit (1);
+        }
+
+        connection = dbus_g_connection_get_connection (priv->connection);
+        dbus_connection_add_filter (connection,
+                                    gsm_manager_bus_filter,
+                                    manager, NULL);
+        priv->dbus_disconnected = FALSE;
+
+        priv->bus_proxy = dbus_g_proxy_new_for_name (priv->connection,
+                                                     DBUS_SERVICE_DBUS,
+                                                     DBUS_PATH_DBUS,
+                                                     DBUS_INTERFACE_DBUS);
+        dbus_g_proxy_add_signal (priv->bus_proxy,
+                                 "NameOwnerChanged",
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_INVALID);
+        dbus_g_proxy_connect_signal (priv->bus_proxy,
+                                     "NameOwnerChanged",
+                                     G_CALLBACK (bus_name_owner_changed),
+                                     manager,
+                                     NULL);
+
+        dbus_g_connection_register_g_object (priv->connection, GSM_MANAGER_DBUS_PATH, G_OBJECT (manager));
+
+        return TRUE;
+}
+
+static void
+gsm_manager_set_failsafe (GsmManager *manager,
+                          gboolean    enabled)
+{
+        GsmManagerPrivate *priv;
+
+        g_return_if_fail (GSM_IS_MANAGER (manager));
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        priv->failsafe = enabled;
+}
+
+static gboolean
+_client_has_startup_id (const char *id,
+                        GsmClient  *client,
+                        const char *startup_id_a)
+{
+        const char *startup_id_b;
+
+        startup_id_b = gsm_client_peek_startup_id (client);
+
+        if (IS_STRING_EMPTY (startup_id_b)) {
+                return FALSE;
+        }
+
+        return (strcmp (startup_id_a, startup_id_b) == 0);
+}
+
+static void
+on_client_disconnected (GsmClient  *client,
+                        GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: disconnect client");
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        _disconnect_client (manager, client);
+        gsm_store_remove (priv->clients, gsm_client_peek_id (client));
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION
+            && gsm_store_size (priv->clients) == 0) {
+                g_debug ("GsmManager: last client disconnected - exiting");
+                end_phase (manager);
+        }
+}
+
+static gboolean
+on_xsmp_client_register_request (GsmXSMPClient *client,
+                                 char         **id,
+                                 GsmManager    *manager)
+{
+        gboolean handled;
+        char    *new_id;
+        GsmApp  *app;
+        GsmManagerPrivate *priv;
+
+        handled = TRUE;
+        new_id = NULL;
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                goto out;
+        }
+
+        if (IS_STRING_EMPTY (*id)) {
+                new_id = gsm_util_generate_startup_id ();
+        } else {
+                GsmClient *sm_client;
+
+                sm_client = (GsmClient *)gsm_store_find (priv->clients,
+                                                         (GsmStoreFunc)_client_has_startup_id,
+                                                         *id);
+                /* We can't have two clients with the same id. */
+                if (sm_client != NULL) {
+                        goto out;
+                }
+
+                new_id = g_strdup (*id);
+        }
+
+        g_debug ("GsmManager: Adding new client %s to session", new_id);
+
+        g_signal_connect (client,
+                          "disconnected",
+                          G_CALLBACK (on_client_disconnected),
+                          manager);
+
+        /* If it's a brand new client id, we just accept the client*/
+        if (IS_STRING_EMPTY (*id)) {
+                goto out;
+        }
+
+        app = find_app_for_startup_id (manager, new_id);
+        if (app != NULL) {
+                gsm_client_set_app_id (GSM_CLIENT (client), gsm_app_peek_app_id (app));
+                gsm_app_registered (app);
+                goto out;
+        }
+
+        /* app not found */
+        g_free (new_id);
+        new_id = NULL;
+
+ out:
+        g_free (*id);
+        *id = new_id;
+
+        return handled;
+}
+
+static gboolean
+auto_save_is_enabled (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        return g_settings_get_boolean (priv->settings_session,
+                                       KEY_AUTOSAVE);
+}
+
+static void
+maybe_save_session (GsmManager *manager)
+{
+        GsmConsolekit *consolekit = NULL;
+#ifdef HAVE_SYSTEMD
+        GsmSystemd *systemd = NULL;
+#endif
+        char *session_type;
+        GError *error;
+        GsmManagerPrivate *priv;
+
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+                systemd = gsm_get_systemd ();
+                session_type = gsm_systemd_get_current_session_type (systemd);
+
+                if (g_strcmp0 (session_type, GSM_SYSTEMD_SESSION_TYPE_LOGIN_WINDOW) == 0) {
+                        goto out;
+                }
+        }
+        else {
+#endif
+        consolekit = gsm_get_consolekit ();
+        session_type = gsm_consolekit_get_current_session_type (consolekit);
+
+        if (g_strcmp0 (session_type, GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW) == 0) {
+                goto out;
+        }
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* We only allow session saving when session is running or when
+         * logging out */
+        if (priv->phase != GSM_MANAGER_PHASE_RUNNING &&
+            priv->phase != GSM_MANAGER_PHASE_END_SESSION) {
+                goto out;
+        }
+
+        error = NULL;
+        gsm_session_save (priv->clients, &error);
+
+        if (error) {
+                g_warning ("Error saving session: %s", error->message);
+                g_error_free (error);
+        }
+
+out:
+        if (consolekit != NULL)
+                g_object_unref (consolekit);
+#ifdef HAVE_SYSTEMD
+        if (systemd != NULL)
+                g_object_unref (systemd);
+#endif
+        g_free (session_type);
+}
+
+static void
+_handle_client_end_session_response (GsmManager *manager,
+                                     GsmClient  *client,
+                                     gboolean    is_ok,
+                                     gboolean    do_last,
+                                     gboolean    cancel,
+                                     const char *reason)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* just ignore if received outside of shutdown */
+        if (priv->phase < GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                return;
+        }
+
+        g_debug ("GsmManager: Response from end session request: is-ok=%d do-last=%d cancel=%d reason=%s", is_ok, do_last, cancel, reason ? reason :"");
+
+        if (cancel) {
+                cancel_end_session (manager);
+                return;
+        }
+
+        priv->query_clients = g_slist_remove (priv->query_clients, client);
+
+        if (! is_ok && priv->logout_mode != GSM_MANAGER_LOGOUT_MODE_FORCE) {
+                guint         cookie;
+                GsmInhibitor *inhibitor;
+                char         *app_id;
+                const char   *bus_name;
+
+                /* FIXME: do we support updating the reason? */
+
+                /* Create JIT inhibit */
+                if (GSM_IS_DBUS_CLIENT (client)) {
+                        bus_name = gsm_dbus_client_get_bus_name (GSM_DBUS_CLIENT (client));
+                } else {
+                        bus_name = NULL;
+                }
+
+                app_id = g_strdup (gsm_client_peek_app_id (client));
+                if (IS_STRING_EMPTY (app_id)) {
+                        /* XSMP clients don't give us an app id unless we start them */
+                        g_free (app_id);
+                        app_id = gsm_client_get_app_name (client);
+                }
+
+                cookie = _generate_unique_cookie (manager);
+                inhibitor = gsm_inhibitor_new_for_client (gsm_client_peek_id (client),
+                                                          app_id,
+                                                          GSM_INHIBITOR_FLAG_LOGOUT,
+                                                          reason != NULL ? reason : _("Not responding"),
+                                                          bus_name,
+                                                          cookie);
+                g_free (app_id);
+                gsm_store_add (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor));
+                g_object_unref (inhibitor);
+        } else {
+                gsm_store_foreach_remove (priv->inhibitors,
+                                          (GsmStoreFunc)inhibitor_has_client_id,
+                                          (gpointer)gsm_client_peek_id (client));
+        }
+
+        if (priv->phase == GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                if (priv->query_clients == NULL) {
+                        query_end_session_complete (manager);
+                }
+        } else if (priv->phase == GSM_MANAGER_PHASE_END_SESSION) {
+                if (do_last) {
+                        /* This only makes sense if we're in part 1 of
+                         * GSM_MANAGER_PHASE_END_SESSION. Doing this in part 2
+                         * can only happen because of a buggy client that loops
+                         * wanting to be last again and again. The phase
+                         * timeout will take care of this issue. */
+                        priv->next_query_clients = g_slist_prepend (priv->next_query_clients,
+                                                                    client);
+                }
+
+                /* we can continue to the next step if all clients have replied
+                 * and if there's no inhibitor */
+                if (priv->query_clients != NULL
+                    || gsm_manager_is_logout_inhibited (manager)) {
+                        return;
+                }
+
+                if (priv->next_query_clients != NULL) {
+                        do_phase_end_session_part_2 (manager);
+                } else {
+                        end_phase (manager);
+                }
+        }
+}
+
+static void
+on_client_end_session_response (GsmClient  *client,
+                                gboolean    is_ok,
+                                gboolean    do_last,
+                                gboolean    cancel,
+                                const char *reason,
+                                GsmManager *manager)
+{
+        _handle_client_end_session_response (manager,
+                                             client,
+                                             is_ok,
+                                             do_last,
+                                             cancel,
+                                             reason);
+}
+
+static void
+on_xsmp_client_logout_request (GsmXSMPClient *client,
+                               gboolean       show_dialog,
+                               GsmManager    *manager)
+{
+        GError *error;
+        int     logout_mode;
+
+        if (show_dialog) {
+                logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL;
+        } else {
+                logout_mode = GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION;
+        }
+
+        error = NULL;
+        gsm_manager_logout (manager, logout_mode, &error);
+        if (error != NULL) {
+                g_warning ("Unable to logout: %s", error->message);
+                g_error_free (error);
+        }
+}
+
+static void
+on_store_client_added (GsmStore   *store,
+                       const char *id,
+                       GsmManager *manager)
+{
+        GsmClient *client;
+
+        g_debug ("GsmManager: Client added: %s", id);
+
+        client = (GsmClient *)gsm_store_lookup (store, id);
+
+        /* a bit hacky */
+        if (GSM_IS_XSMP_CLIENT (client)) {
+                g_signal_connect (client,
+                                  "register-request",
+                                  G_CALLBACK (on_xsmp_client_register_request),
+                                  manager);
+                g_signal_connect (client,
+                                  "logout-request",
+                                  G_CALLBACK (on_xsmp_client_logout_request),
+                                  manager);
+        }
+
+        g_signal_connect (client,
+                          "end-session-response",
+                          G_CALLBACK (on_client_end_session_response),
+                          manager);
+
+        g_signal_emit (manager, signals [CLIENT_ADDED], 0, id);
+        /* FIXME: disconnect signal handler */
+}
+
+static void
+on_store_client_removed (GsmStore   *store,
+                         const char *id,
+                         GsmManager *manager)
+{
+        g_debug ("GsmManager: Client removed: %s", id);
+
+        g_signal_emit (manager, signals [CLIENT_REMOVED], 0, id);
+}
+
+static void
+gsm_manager_set_client_store (GsmManager *manager,
+                              GsmStore   *store)
+{
+        GsmManagerPrivate *priv;
+
+        g_return_if_fail (GSM_IS_MANAGER (manager));
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (store != NULL) {
+                g_object_ref (store);
+        }
+
+        if (priv->clients != NULL) {
+                g_signal_handlers_disconnect_by_func (priv->clients,
+                                                      on_store_client_added,
+                                                      manager);
+                g_signal_handlers_disconnect_by_func (priv->clients,
+                                                      on_store_client_removed,
+                                                      manager);
+
+                g_object_unref (priv->clients);
+        }
+
+        g_debug ("GsmManager: setting client store %p", store);
+
+        priv->clients = store;
+
+        if (priv->clients != NULL) {
+                g_signal_connect (priv->clients,
+                                  "added",
+                                  G_CALLBACK (on_store_client_added),
+                                  manager);
+                g_signal_connect (priv->clients,
+                                  "removed",
+                                  G_CALLBACK (on_store_client_removed),
+                                  manager);
+        }
+}
+
+static void
+gsm_manager_set_property (GObject       *object,
+                          guint          prop_id,
+                          const GValue  *value,
+                          GParamSpec    *pspec)
+{
+        GsmManager *self;
+
+        self = GSM_MANAGER (object);
+
+        switch (prop_id) {
+        case PROP_FAILSAFE:
+                gsm_manager_set_failsafe (self, g_value_get_boolean (value));
+                break;
+         case PROP_CLIENT_STORE:
+                gsm_manager_set_client_store (self, g_value_get_object (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_manager_get_property (GObject    *object,
+                          guint       prop_id,
+                          GValue     *value,
+                          GParamSpec *pspec)
+{
+        GsmManager *self;
+        GsmManagerPrivate *priv;
+
+        self = GSM_MANAGER (object);
+        priv = gsm_manager_get_instance_private (self);
+
+        switch (prop_id) {
+        case PROP_FAILSAFE:
+                g_value_set_boolean (value, priv->failsafe);
+                break;
+        case PROP_CLIENT_STORE:
+                g_value_set_object (value, priv->clients);
+                break;
+        case PROP_RENDERER:
+                g_value_set_string (value, priv->renderer);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static gboolean
+_find_app_provides (const char *id,
+                    GsmApp     *app,
+                    const char *service)
+{
+        return gsm_app_provides (app, service);
+}
+
+static GObject *
+gsm_manager_constructor (GType                  type,
+                         guint                  n_construct_properties,
+                         GObjectConstructParam *construct_properties)
+{
+        GsmManager *manager;
+
+        manager = GSM_MANAGER (G_OBJECT_CLASS (gsm_manager_parent_class)->constructor (type,
+                                                                                       n_construct_properties,
+                                                                                       construct_properties));
+        return G_OBJECT (manager);
+}
+
+static void
+on_store_inhibitor_added (GsmStore   *store,
+                          const char *id,
+                          GsmManager *manager)
+{
+        g_debug ("GsmManager: Inhibitor added: %s", id);
+        g_signal_emit (manager, signals [INHIBITOR_ADDED], 0, id);
+        update_idle (manager);
+}
+
+static void
+on_store_inhibitor_removed (GsmStore   *store,
+                            const char *id,
+                            GsmManager *manager)
+{
+        g_debug ("GsmManager: Inhibitor removed: %s", id);
+        g_signal_emit (manager, signals [INHIBITOR_REMOVED], 0, id);
+        update_idle (manager);
+}
+
+static void
+gsm_manager_dispose (GObject *object)
+{
+        GsmManagerPrivate *priv;
+        GsmManager *manager = GSM_MANAGER (object);
+
+        g_debug ("GsmManager: disposing manager");
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->clients != NULL) {
+                g_signal_handlers_disconnect_by_func (priv->clients,
+                                                      on_store_client_added,
+                                                      manager);
+                g_signal_handlers_disconnect_by_func (priv->clients,
+                                                      on_store_client_removed,
+                                                      manager);
+                g_object_unref (priv->clients);
+                priv->clients = NULL;
+        }
+
+        if (priv->apps != NULL) {
+                g_object_unref (priv->apps);
+                priv->apps = NULL;
+        }
+
+        if (priv->inhibitors != NULL) {
+                g_signal_handlers_disconnect_by_func (priv->inhibitors,
+                                                      on_store_inhibitor_added,
+                                                      manager);
+                g_signal_handlers_disconnect_by_func (priv->inhibitors,
+                                                      on_store_inhibitor_removed,
+                                                      manager);
+
+                g_object_unref (priv->inhibitors);
+                priv->inhibitors = NULL;
+        }
+
+        if (priv->presence != NULL) {
+                g_object_unref (priv->presence);
+                priv->presence = NULL;
+        }
+
+        if (priv->settings_session) {
+                g_object_unref (priv->settings_session);
+                priv->settings_session = NULL;
+        }
+
+        if (priv->settings_lockdown) {
+                g_object_unref (priv->settings_lockdown);
+                priv->settings_lockdown = NULL;
+        }
+
+        if (priv->settings_screensaver) {
+                g_object_unref (priv->settings_screensaver);
+                priv->settings_screensaver = NULL;
+        }
+
+        g_clear_pointer (&priv->renderer, g_free);
+
+        G_OBJECT_CLASS (gsm_manager_parent_class)->dispose (object);
+}
+
+static void
+gsm_manager_class_init (GsmManagerClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsm_manager_get_property;
+        object_class->set_property = gsm_manager_set_property;
+        object_class->constructor = gsm_manager_constructor;
+        object_class->finalize = gsm_manager_finalize;
+        object_class->dispose = gsm_manager_dispose;
+
+        signals [PHASE_CHANGED] =
+                g_signal_new ("phase-changed",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, phase_changed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+
+        signals [SESSION_RUNNING] =
+                g_signal_new ("session-running",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, session_running),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+
+        signals [SESSION_OVER] =
+                g_signal_new ("session-over",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, session_over),
+                              NULL, NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE,
+                              0);
+        signals [CLIENT_ADDED] =
+                g_signal_new ("client-added",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, client_added),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__BOXED,
+                              G_TYPE_NONE,
+                              1, DBUS_TYPE_G_OBJECT_PATH);
+        signals [CLIENT_REMOVED] =
+                g_signal_new ("client-removed",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, client_removed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__BOXED,
+                              G_TYPE_NONE,
+                              1, DBUS_TYPE_G_OBJECT_PATH);
+        signals [INHIBITOR_ADDED] =
+                g_signal_new ("inhibitor-added",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, inhibitor_added),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__BOXED,
+                              G_TYPE_NONE,
+                              1, DBUS_TYPE_G_OBJECT_PATH);
+        signals [INHIBITOR_REMOVED] =
+                g_signal_new ("inhibitor-removed",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmManagerClass, inhibitor_removed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__BOXED,
+                              G_TYPE_NONE,
+                              1, DBUS_TYPE_G_OBJECT_PATH);
+
+        g_object_class_install_property (object_class,
+                                         PROP_FAILSAFE,
+                                         g_param_spec_boolean ("failsafe",
+                                                               NULL,
+                                                               NULL,
+                                                               FALSE,
+                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_CLIENT_STORE,
+                                         g_param_spec_object ("client-store",
+                                                              NULL,
+                                                              NULL,
+                                                              GSM_TYPE_STORE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+        g_object_class_install_property (object_class,
+                                         PROP_RENDERER,
+                                         g_param_spec_string ("renderer",
+                                                              NULL,
+                                                              NULL,
+                                                              NULL,
+                                                              G_PARAM_READABLE));
+
+        dbus_g_object_type_install_info (GSM_TYPE_MANAGER, &dbus_glib_gsm_manager_object_info);
+        dbus_g_error_domain_register (GSM_MANAGER_ERROR, NULL, GSM_MANAGER_TYPE_ERROR);
+}
+
+static void
+load_idle_delay_from_gsettings (GsmManager *manager)
+{
+        glong   value;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        value = g_settings_get_int (priv->settings_session,
+                                    KEY_IDLE_DELAY);
+        gsm_presence_set_idle_timeout (priv->presence, value * 60000);
+}
+
+static void
+on_gsettings_key_changed (GSettings   *settings,
+                          gchar       *key,
+                          GsmManager  *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (g_strcmp0 (key, KEY_IDLE_DELAY) == 0) {
+                int delay;
+                delay = g_settings_get_int (settings, key);
+                gsm_presence_set_idle_timeout (priv->presence, delay * 60000);
+        } else if (g_strcmp0 (key, KEY_LOCK_DISABLE) == 0) {
+                /* ??? */
+                gboolean UNUSED_VARIABLE disabled;
+                disabled = g_settings_get_boolean (settings, key);
+        } else if (g_strcmp0 (key, KEY_USER_SWITCH_DISABLE) == 0) {
+                /* ??? */
+                gboolean UNUSED_VARIABLE disabled;
+                disabled = g_settings_get_boolean (settings, key);
+        } else {
+                g_debug ("Config key not handled: %s", key);
+        }
+}
+
+static void
+on_presence_status_changed (GsmPresence  *presence,
+                            guint         status,
+                            GsmManager   *manager)
+{
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+                GsmSystemd *systemd;
+
+                systemd = gsm_get_systemd ();
+                gsm_systemd_set_session_idle (systemd,
+                                              (status == GSM_PRESENCE_STATUS_IDLE));
+        }
+        else {
+#endif
+        GsmConsolekit *consolekit;
+
+        consolekit = gsm_get_consolekit ();
+        gsm_consolekit_set_session_idle (consolekit,
+                                         (status == GSM_PRESENCE_STATUS_IDLE));
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+}
+
+static void
+gsm_manager_init (GsmManager *manager)
+{
+        gchar **schemas = NULL;
+        gboolean schema_exists;
+        guint i;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        priv->settings_session = g_settings_new (SESSION_SCHEMA);
+        priv->settings_lockdown = g_settings_new (LOCKDOWN_SCHEMA);
+
+        /* check if mate-screensaver is installed */
+        g_settings_schema_source_list_schemas (g_settings_schema_source_get_default (), TRUE, &schemas, NULL);
+        schema_exists = FALSE;
+        for (i = 0; schemas[i] != NULL; i++) {
+                if (g_str_equal (schemas[i], SCREENSAVER_SCHEMA)) {
+                        schema_exists = TRUE;
+                        break;
+                }
+        }
+
+        g_strfreev (schemas);
+
+        if (schema_exists == TRUE)
+                priv->settings_screensaver = g_settings_new (SCREENSAVER_SCHEMA);
+        else
+                priv->settings_screensaver = NULL;
+
+        priv->inhibitors = gsm_store_new ();
+        g_signal_connect (priv->inhibitors,
+                          "added",
+                          G_CALLBACK (on_store_inhibitor_added),
+                          manager);
+        g_signal_connect (priv->inhibitors,
+                          "removed",
+                          G_CALLBACK (on_store_inhibitor_removed),
+                          manager);
+
+        priv->apps = gsm_store_new ();
+
+        priv->presence = gsm_presence_new ();
+        g_signal_connect (priv->presence,
+                          "status-changed",
+                          G_CALLBACK (on_presence_status_changed),
+                          manager);
+        g_signal_connect (priv->settings_session,
+                          "changed",
+                          G_CALLBACK (on_gsettings_key_changed),
+                          manager);
+        g_signal_connect (priv->settings_lockdown,
+                          "changed",
+                          G_CALLBACK (on_gsettings_key_changed),
+                          manager);
+
+        load_idle_delay_from_gsettings (manager);
+}
+
+static void
+gsm_manager_finalize (GObject *object)
+{
+        GsmManager *manager;
+        GsmManagerPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_MANAGER (object));
+
+        manager = GSM_MANAGER (object);
+        priv = gsm_manager_get_instance_private (manager);
+
+        g_return_if_fail (priv != NULL);
+
+        G_OBJECT_CLASS (gsm_manager_parent_class)->finalize (object);
+}
+
+GsmManager *
+gsm_manager_new (GsmStore *client_store,
+                 gboolean  failsafe)
+{
+        if (manager_object != NULL) {
+                g_object_ref (manager_object);
+        } else {
+                gboolean res;
+
+                manager_object = g_object_new (GSM_TYPE_MANAGER,
+                                               "client-store", client_store,
+                                               "failsafe", failsafe,
+                                               NULL);
+
+                g_object_add_weak_pointer (manager_object,
+                                           (gpointer *) &manager_object);
+                res = register_manager (manager_object);
+                if (! res) {
+                        g_object_unref (manager_object);
+                        return NULL;
+                }
+        }
+
+        return GSM_MANAGER (manager_object);
+}
+
+gboolean
+gsm_manager_setenv (GsmManager  *manager,
+                    const char  *variable,
+                    const char  *value,
+                    GError     **error)
+{
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase > GSM_MANAGER_PHASE_INITIALIZATION) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION,
+                             "Setenv interface is only available during the Initialization phase");
+                return FALSE;
+        }
+
+        gsm_util_setenv (variable, value);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_initialization_error (GsmManager  *manager,
+                                  const char  *message,
+                                  gboolean     fatal,
+                                  GError     **error)
+{
+        GsmManagerPrivate *priv;
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->phase > GSM_MANAGER_PHASE_INITIALIZATION) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_NOT_IN_INITIALIZATION,
+                             "InitializationError interface is only available during the Initialization phase");
+                return FALSE;
+        }
+
+        gsm_util_init_error (fatal, "%s", message);
+
+        return TRUE;
+}
+
+static gboolean
+gsm_manager_is_switch_user_inhibited (GsmManager *manager)
+{
+        GsmInhibitor *inhibitor;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->inhibitors == NULL) {
+                return FALSE;
+        }
+
+        inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors,
+                                                    (GsmStoreFunc)inhibitor_has_flag,
+                                                    GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_SWITCH_USER));
+        if (inhibitor == NULL) {
+                return FALSE;
+        }
+        return TRUE;
+}
+
+static gboolean
+gsm_manager_is_suspend_inhibited (GsmManager *manager)
+{
+        GsmInhibitor *inhibitor;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->inhibitors == NULL) {
+                return FALSE;
+        }
+
+        inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors,
+                                                    (GsmStoreFunc)inhibitor_has_flag,
+                                                    GUINT_TO_POINTER (GSM_INHIBITOR_FLAG_SUSPEND));
+        if (inhibitor == NULL) {
+                return FALSE;
+        }
+        return TRUE;
+}
+
+static void
+request_reboot_privileges_completed_consolekit (GsmConsolekit *consolekit,
+                                                gboolean       success,
+                                                gboolean       ask_later,
+                                                GError        *error,
+                                                GsmManager    *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* make sure we disconnect the signal handler so that it's not called
+         * again next time the event is fired -- this can happen if the reboot
+         * is cancelled. */
+        g_signal_handlers_disconnect_by_func (consolekit,
+                                              request_reboot_privileges_completed_consolekit,
+                                              manager);
+
+        g_object_unref (consolekit);
+
+        if (success) {
+                if (ask_later) {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT;
+                } else {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT;
+                }
+
+                end_phase (manager);
+        }
+}
+
+#ifdef HAVE_SYSTEMD
+static void
+request_reboot_privileges_completed_systemd (GsmSystemd *systemd,
+                                             gboolean    success,
+                                             gboolean    ask_later,
+                                             GError     *error,
+                                             GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* make sure we disconnect the signal handler so that it's not called
+         * again next time the event is fired -- this can happen if the reboot
+         * is cancelled. */
+        g_signal_handlers_disconnect_by_func (systemd,
+                                              request_reboot_privileges_completed_systemd,
+                                              manager);
+
+        g_object_unref (systemd);
+
+        if (success) {
+                if (ask_later) {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_INTERACT;
+                } else {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT;
+                }
+
+                end_phase (manager);
+        }
+}
+#endif
+
+static void
+request_reboot (GsmManager *manager)
+{
+        GsmConsolekit *consolekit;
+#ifdef HAVE_SYSTEMD
+        GsmSystemd *systemd;
+#endif
+        gboolean       success;
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: requesting reboot");
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        /* We request the privileges before doing anything. There are a few
+         * different cases here:
+         *
+         *   - no systemd: we fallback on ConsoleKit
+         *   - no ConsoleKit: we fallback on MDM
+         *   - no password required: everything is fine
+         *   - password asked once: we ask for it now. If the user enters it
+         *     fine, then all is great. If the user doesn't enter it fine, we
+         *     don't do anything (so no logout).
+         *   - password asked each time: we don't ask it for now since we don't
+         *     want to ask for it twice. Instead we'll ask for it at the very
+         *     end. If the user will enter it fine, then all is great again. If
+         *     the user doesn't enter it fine, then we'll just fallback to MDM.
+         *
+         * The last case (password asked each time) is a bit broken, but
+         * there's really nothing we can do about it. Generally speaking,
+         * though, the password will only be asked once (unless the system is
+         * configured in paranoid mode), and most probably only if there are
+         * more than one user connected. So the general case is that it will
+         * just work fine.
+         */
+
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+                systemd = gsm_get_systemd ();
+                g_signal_connect (systemd,
+                                  "privileges-completed",
+                                  G_CALLBACK (request_reboot_privileges_completed_systemd),
+                                  manager);
+                success = gsm_systemd_get_restart_privileges (systemd);
+
+                if (!success) {
+                        g_signal_handlers_disconnect_by_func (systemd,
+                                                              request_reboot_privileges_completed_systemd,
+                                                              manager);
+                        g_object_unref (systemd);
+
+                        priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_MDM;
+                        end_phase (manager);
+                }
+        }
+        else {
+#endif
+        consolekit = gsm_get_consolekit ();
+        g_signal_connect (consolekit,
+                          "privileges-completed",
+                          G_CALLBACK (request_reboot_privileges_completed_consolekit),
+                          manager);
+        success = gsm_consolekit_get_restart_privileges (consolekit);
+
+        if (!success) {
+                g_signal_handlers_disconnect_by_func (consolekit,
+                                                      request_reboot_privileges_completed_consolekit,
+                                                      manager);
+                g_object_unref (consolekit);
+
+                priv->logout_type = GSM_MANAGER_LOGOUT_REBOOT_MDM;
+                end_phase (manager);
+        }
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+}
+
+static void
+request_shutdown_privileges_completed_consolekit (GsmConsolekit *consolekit,
+                                                  gboolean       success,
+                                                  gboolean       ask_later,
+                                                  GError        *error,
+                                                  GsmManager    *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* make sure we disconnect the signal handler so that it's not called
+         * again next time the event is fired -- this can happen if the reboot
+         * is cancelled. */
+        g_signal_handlers_disconnect_by_func (consolekit,
+                                              request_shutdown_privileges_completed_consolekit,
+                                              manager);
+
+        g_object_unref (consolekit);
+
+        if (success) {
+                if (ask_later) {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT;
+                } else {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN;
+                }
+
+                end_phase (manager);
+        }
+}
+
+#ifdef HAVE_SYSTEMD
+static void
+request_shutdown_privileges_completed_systemd (GsmSystemd *systemd,
+                                               gboolean    success,
+                                               gboolean    ask_later,
+                                               GError     *error,
+                                               GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* make sure we disconnect the signal handler so that it's not called
+         * again next time the event is fired -- this can happen if the reboot
+         * is cancelled. */
+        g_signal_handlers_disconnect_by_func (systemd,
+                                              request_shutdown_privileges_completed_systemd,
+                                              manager);
+
+        g_object_unref (systemd);
+
+        if (success) {
+                if (ask_later) {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_INTERACT;
+                } else {
+                        priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN;
+                }
+
+                end_phase (manager);
+        }
+}
+#endif
+
+static void
+request_shutdown (GsmManager *manager)
+{
+        GsmConsolekit *consolekit;
+#ifdef HAVE_SYSTEMD
+        GsmSystemd *systemd;
+#endif
+        gboolean       success;
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: requesting shutdown");
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        /* See the comment in request_reboot() for some more details about how
+         * this works. */
+
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+                systemd = gsm_get_systemd ();
+                g_signal_connect (systemd,
+                                  "privileges-completed",
+                                  G_CALLBACK (request_shutdown_privileges_completed_systemd),
+                                  manager);
+                success = gsm_systemd_get_stop_privileges (systemd);
+
+                if (!success) {
+                        g_signal_handlers_disconnect_by_func (systemd,
+                                                              request_shutdown_privileges_completed_systemd,
+                                                              manager);
+                        g_object_unref (systemd);
+
+                        priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_MDM;
+                        end_phase (manager);
+                }
+        }
+        else {
+#endif
+        consolekit = gsm_get_consolekit ();
+        g_signal_connect (consolekit,
+                          "privileges-completed",
+                          G_CALLBACK (request_shutdown_privileges_completed_consolekit),
+                          manager);
+        success = gsm_consolekit_get_stop_privileges (consolekit);
+
+        if (!success) {
+                g_signal_handlers_disconnect_by_func (consolekit,
+                                                      request_shutdown_privileges_completed_consolekit,
+                                                      manager);
+                g_object_unref (consolekit);
+
+                priv->logout_type = GSM_MANAGER_LOGOUT_SHUTDOWN_MDM;
+                end_phase (manager);
+        }
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+}
+
+static void
+request_suspend (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: requesting suspend");
+
+        if (! gsm_manager_is_suspend_inhibited (manager)) {
+                manager_attempt_suspend (manager);
+                return;
+        }
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->inhibit_dialog != NULL) {
+                g_debug ("GsmManager: inhibit dialog already up");
+                gtk_window_present (GTK_WINDOW (priv->inhibit_dialog));
+                return;
+        }
+
+        priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors,
+                                                       priv->clients,
+                                                       GSM_LOGOUT_ACTION_SLEEP);
+
+        g_signal_connect (priv->inhibit_dialog,
+                          "response",
+                          G_CALLBACK (inhibit_dialog_response),
+                          manager);
+        gtk_widget_show (priv->inhibit_dialog);
+}
+
+static void
+request_hibernate (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: requesting hibernate");
+
+        /* hibernate uses suspend inhibit */
+        if (! gsm_manager_is_suspend_inhibited (manager)) {
+                manager_attempt_hibernate (manager);
+                return;
+        }
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->inhibit_dialog != NULL) {
+                g_debug ("GsmManager: inhibit dialog already up");
+                gtk_window_present (GTK_WINDOW (priv->inhibit_dialog));
+                return;
+        }
+
+        priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors,
+                                                       priv->clients,
+                                                       GSM_LOGOUT_ACTION_HIBERNATE);
+
+        g_signal_connect (priv->inhibit_dialog,
+                          "response",
+                          G_CALLBACK (inhibit_dialog_response),
+                          manager);
+        gtk_widget_show (priv->inhibit_dialog);
+}
+
+static void
+request_logout (GsmManager            *manager,
+                GsmManagerLogoutMode  mode)
+{
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: requesting logout");
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        priv->logout_mode = mode;
+        priv->logout_type = GSM_MANAGER_LOGOUT_LOGOUT;
+
+        end_phase (manager);
+}
+
+static void
+request_switch_user (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: requesting user switch");
+
+        /* See comment in manager_switch_user() to understand why we do this in
+         * both functions. */
+        if (_switch_user_is_locked_down (manager)) {
+                g_warning ("Unable to switch user: User switching has been locked down");
+                return;
+        }
+
+        if (! gsm_manager_is_switch_user_inhibited (manager)) {
+                manager_switch_user (manager);
+                return;
+        }
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->inhibit_dialog != NULL) {
+                g_debug ("GsmManager: inhibit dialog already up");
+                gtk_window_present (GTK_WINDOW (priv->inhibit_dialog));
+                return;
+        }
+
+        priv->inhibit_dialog = gsm_inhibit_dialog_new (priv->inhibitors,
+                                                       priv->clients,
+                                                       GSM_LOGOUT_ACTION_SWITCH_USER);
+
+        g_signal_connect (priv->inhibit_dialog,
+                          "response",
+                          G_CALLBACK (inhibit_dialog_response),
+                          manager);
+        gtk_widget_show (priv->inhibit_dialog);
+}
+
+static void
+logout_dialog_response (GsmLogoutDialog *logout_dialog,
+                        guint            response_id,
+                        GsmManager      *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* We should only be here if mode has already have been set from
+         * show_fallback_shutdown/logout_dialog
+         */
+        g_assert (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_NORMAL);
+
+        g_debug ("GsmManager: Logout dialog response: %d", response_id);
+
+        gtk_widget_destroy (GTK_WIDGET (logout_dialog));
+
+        /* In case of dialog cancel, switch user, hibernate and
+         * suspend, we just perform the respective action and return,
+         * without shutting down the session. */
+        switch (response_id) {
+        case GTK_RESPONSE_CANCEL:
+        case GTK_RESPONSE_NONE:
+        case GTK_RESPONSE_DELETE_EVENT:
+                break;
+        case GSM_LOGOUT_RESPONSE_SWITCH_USER:
+                request_switch_user (manager);
+                break;
+        case GSM_LOGOUT_RESPONSE_HIBERNATE:
+                request_hibernate (manager);
+                break;
+        case GSM_LOGOUT_RESPONSE_SLEEP:
+                request_suspend (manager);
+                break;
+        case GSM_LOGOUT_RESPONSE_SHUTDOWN:
+                request_shutdown (manager);
+                break;
+        case GSM_LOGOUT_RESPONSE_REBOOT:
+                request_reboot (manager);
+                break;
+        case GSM_LOGOUT_RESPONSE_LOGOUT:
+                /* We've already gotten confirmation from the user so
+                 * initiate the logout in NO_CONFIRMATION mode.
+                 *
+                 * (it shouldn't matter whether we use NO_CONFIRMATION or stay
+                 * with NORMAL, unless the shell happens to start after the
+                 * user confirmed)
+                 */
+                request_logout (manager, GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION);
+                break;
+        default:
+                g_assert_not_reached ();
+                break;
+        }
+}
+
+static void
+show_shutdown_dialog (GsmManager *manager)
+{
+        GtkWidget *dialog;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                /* Already shutting down, nothing more to do */
+                return;
+        }
+
+        priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL;
+
+        dialog = gsm_get_shutdown_dialog (gdk_screen_get_default (),
+                                          gtk_get_current_event_time ());
+
+        g_signal_connect (dialog,
+                          "response",
+                          G_CALLBACK (logout_dialog_response),
+                          manager);
+        gtk_widget_show (dialog);
+        gtk_window_present_with_time (GTK_WINDOW (dialog),
+                                      gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (dialog))));
+}
+
+static void
+show_logout_dialog (GsmManager *manager)
+{
+        GtkWidget *dialog;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                /* Already shutting down, nothing more to do */
+                return;
+        }
+
+        priv->logout_mode = GSM_MANAGER_LOGOUT_MODE_NORMAL;
+
+        dialog = gsm_get_logout_dialog (gdk_screen_get_default (),
+                                        gtk_get_current_event_time ());
+
+        g_signal_connect (dialog,
+                          "response",
+                          G_CALLBACK (logout_dialog_response),
+                          manager);
+        gtk_widget_show (dialog);
+        gtk_window_present_with_time (GTK_WINDOW (dialog),
+                                      gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (dialog))));
+}
+
+static void
+user_logout (GsmManager           *manager,
+             GsmManagerLogoutMode  mode)
+{
+        gboolean logout_prompt;
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                /* Already shutting down, nothing more to do */
+                return;
+        }
+
+        logout_prompt =
+               g_settings_get_boolean (priv->settings_session,
+                                       "logout-prompt");
+
+        /* If the shell isn't running, and this isn't a non-interative logout request,
+         * and the user has their settings configured to show a confirmation dialog for
+         * logout, then go ahead and show the confirmation dialog now.
+         */
+        if (mode == GSM_MANAGER_LOGOUT_MODE_NORMAL && logout_prompt) {
+                show_logout_dialog (manager);
+        } else {
+                request_logout (manager, mode);
+        }
+}
+
+/*
+  dbus-send --session --type=method_call --print-reply
+      --dest=org.gnome.SessionManager
+      /org/gnome/SessionManager
+      org.freedesktop.DBus.Introspectable.Introspect
+*/
+
+gboolean
+gsm_manager_set_phase (GsmManager      *manager,
+                       GsmManagerPhase  phase)
+{
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        priv->phase = phase;
+        return (TRUE);
+}
+
+gboolean
+gsm_manager_request_shutdown (GsmManager *manager,
+                              GError    **error)
+{
+        GsmManagerPrivate *priv;
+        g_debug ("GsmManager: RequestShutdown called");
+
+        g_return_val_if_fail(GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase != GSM_MANAGER_PHASE_RUNNING) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_NOT_IN_RUNNING,
+                             "RequestShutdown interface is only available during the Running phase");
+                return FALSE;
+        }
+
+        request_shutdown (manager);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_request_reboot (GsmManager *manager,
+                            GError    **error)
+{
+        GsmManagerPrivate *priv;
+
+        g_debug ("GsmManager: RequestReboot called");
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase != GSM_MANAGER_PHASE_RUNNING) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_NOT_IN_RUNNING,
+                             "RequestReboot interface is only available during the running phase");
+                return FALSE;
+        }
+
+        request_reboot (manager);
+
+        return TRUE;
+}
+
+static gboolean
+_log_out_is_locked_down (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+
+        return g_settings_get_boolean (priv->settings_lockdown,
+                                       KEY_LOG_OUT_DISABLE);
+}
+
+static gboolean
+_switch_user_is_locked_down (GsmManager *manager)
+{
+        GsmManagerPrivate *priv;
+
+        priv = gsm_manager_get_instance_private (manager);
+        return g_settings_get_boolean (priv->settings_lockdown,
+                                       KEY_USER_SWITCH_DISABLE);
+}
+
+gboolean
+gsm_manager_shutdown (GsmManager *manager,
+                      GError    **error)
+{
+        GsmManagerPrivate *priv;
+        g_debug ("GsmManager: Shutdown called");
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase != GSM_MANAGER_PHASE_RUNNING) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_NOT_IN_RUNNING,
+                             "Shutdown interface is only available during the Running phase");
+                return FALSE;
+        }
+
+        if (_log_out_is_locked_down (manager)) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_LOCKED_DOWN,
+                             "Logout has been locked down");
+                return FALSE;
+        }
+
+        show_shutdown_dialog (manager);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_can_shutdown (GsmManager *manager,
+                          gboolean   *shutdown_available,
+                          GError    **error)
+{
+        GsmConsolekit *consolekit;
+#ifdef HAVE_SYSTEMD
+        GsmSystemd *systemd;
+#endif
+        g_debug ("GsmManager: CanShutdown called");
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+#ifdef HAVE_SYSTEMD
+        if (LOGIND_RUNNING()) {
+                systemd = gsm_get_systemd ();
+                *shutdown_available = gsm_systemd_can_stop (systemd)
+                                      || gsm_systemd_can_restart (systemd)
+                                      || gsm_systemd_can_suspend (systemd)
+                                      || gsm_systemd_can_hibernate (systemd);
+                g_object_unref (systemd);
+        }
+        else {
+#endif
+        consolekit = gsm_get_consolekit ();
+        *shutdown_available = !_log_out_is_locked_down (manager) &&
+                              (gsm_consolekit_can_stop (consolekit)
+                               || gsm_consolekit_can_restart (consolekit)
+                               || gsm_consolekit_can_suspend (consolekit)
+                               || gsm_consolekit_can_hibernate (consolekit));
+        g_object_unref (consolekit);
+#ifdef HAVE_SYSTEMD
+        }
+#endif
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_logout (GsmManager *manager,
+                    guint       logout_mode,
+                    GError    **error)
+{
+        GsmManagerPrivate *priv;
+        g_debug ("GsmManager: Logout called");
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase != GSM_MANAGER_PHASE_RUNNING) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_NOT_IN_RUNNING,
+                             "Shutdown interface is only available during the Running phase");
+                return FALSE;
+        }
+
+        if (_log_out_is_locked_down (manager)) {
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_LOCKED_DOWN,
+                             "Logout has been locked down");
+                return FALSE;
+        }
+
+        switch (logout_mode) {
+        case GSM_MANAGER_LOGOUT_MODE_NORMAL:
+        case GSM_MANAGER_LOGOUT_MODE_NO_CONFIRMATION:
+        case GSM_MANAGER_LOGOUT_MODE_FORCE:
+                user_logout (manager, logout_mode);
+                break;
+
+        default:
+                g_debug ("Unknown logout mode option");
+
+                g_set_error (error,
+                             GSM_MANAGER_ERROR,
+                             GSM_MANAGER_ERROR_INVALID_OPTION,
+                             "Unknown logout mode flag");
+                return FALSE;
+        }
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_register_client (GsmManager            *manager,
+                             const char            *app_id,
+                             const char            *startup_id,
+                             DBusGMethodInvocation *context)
+{
+        char      *new_startup_id;
+        char      *sender;
+        GsmClient *client;
+        GsmApp    *app;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        app = NULL;
+        client = NULL;
+
+        g_debug ("GsmManager: RegisterClient %s", startup_id);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->phase >= GSM_MANAGER_PHASE_QUERY_END_SESSION) {
+                GError *new_error;
+
+                g_debug ("Unable to register client: shutting down");
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_NOT_IN_RUNNING,
+                                         "Unable to register client");
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        if (IS_STRING_EMPTY (startup_id)) {
+                new_startup_id = gsm_util_generate_startup_id ();
+        } else {
+
+                client = (GsmClient *)gsm_store_find (priv->clients,
+                                                      (GsmStoreFunc)_client_has_startup_id,
+                                                      (char *)startup_id);
+                /* We can't have two clients with the same startup id. */
+                if (client != NULL) {
+                        GError *new_error;
+
+                        g_debug ("Unable to register client: already registered");
+
+                        new_error = g_error_new (GSM_MANAGER_ERROR,
+                                                 GSM_MANAGER_ERROR_ALREADY_REGISTERED,
+                                                 "Unable to register client");
+                        dbus_g_method_return_error (context, new_error);
+                        g_error_free (new_error);
+                        return FALSE;
+                }
+
+                new_startup_id = g_strdup (startup_id);
+        }
+
+        g_debug ("GsmManager: Adding new client %s to session", new_startup_id);
+
+        if (app == NULL && !IS_STRING_EMPTY (startup_id)) {
+                app = find_app_for_startup_id (manager, startup_id);
+        }
+        if (app == NULL && !IS_STRING_EMPTY (app_id)) {
+                /* try to associate this app id with a known app */
+                app = find_app_for_app_id (manager, app_id);
+        }
+
+        sender = dbus_g_method_get_sender (context);
+        client = gsm_dbus_client_new (new_startup_id, sender);
+        g_free (sender);
+        if (client == NULL) {
+                GError *new_error;
+
+                g_debug ("Unable to create client");
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_GENERAL,
+                                         "Unable to register client");
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        gsm_store_add (priv->clients, gsm_client_peek_id (client), G_OBJECT (client));
+        /* the store will own the ref */
+        g_object_unref (client);
+
+        if (app != NULL) {
+                gsm_client_set_app_id (client, gsm_app_peek_app_id (app));
+                gsm_app_registered (app);
+        } else {
+                /* if an app id is specified store it in the client
+                   so we can save it later */
+                gsm_client_set_app_id (client, app_id);
+        }
+
+        gsm_client_set_status (client, GSM_CLIENT_REGISTERED);
+
+        g_assert (new_startup_id != NULL);
+        g_free (new_startup_id);
+
+        dbus_g_method_return (context, gsm_client_peek_id (client));
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_unregister_client (GsmManager            *manager,
+                               const char            *client_id,
+                               DBusGMethodInvocation *context)
+{
+        GsmClient *client;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        g_debug ("GsmManager: UnregisterClient %s", client_id);
+
+        priv = gsm_manager_get_instance_private (manager);
+        client = (GsmClient *)gsm_store_lookup (priv->clients, client_id);
+        if (client == NULL) {
+                GError *new_error;
+
+                g_debug ("Unable to unregister client: not registered");
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_NOT_REGISTERED,
+                                         "Unable to unregister client");
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        /* don't disconnect client here, only change the status.
+           Wait until it leaves the bus before disconnecting it */
+        gsm_client_set_status (client, GSM_CLIENT_UNREGISTERED);
+
+        dbus_g_method_return (context);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_inhibit (GsmManager            *manager,
+                     const char            *app_id,
+                     guint                  toplevel_xid,
+                     const char            *reason,
+                     guint                  flags,
+                     DBusGMethodInvocation *context)
+{
+        GsmInhibitor *inhibitor;
+        guint         cookie;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        g_debug ("GsmManager: Inhibit xid=%u app_id=%s reason=%s flags=%u",
+                 toplevel_xid,
+                 app_id,
+                 reason,
+                 flags);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->logout_mode == GSM_MANAGER_LOGOUT_MODE_FORCE) {
+                GError *new_error;
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_GENERAL,
+                                         "Forced logout cannot be inhibited");
+                g_debug ("GsmManager: Unable to inhibit: %s", new_error->message);
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        if (IS_STRING_EMPTY (app_id)) {
+                GError *new_error;
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_GENERAL,
+                                         "Application ID not specified");
+                g_debug ("GsmManager: Unable to inhibit: %s", new_error->message);
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        if (IS_STRING_EMPTY (reason)) {
+                GError *new_error;
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_GENERAL,
+                                         "Reason not specified");
+                g_debug ("GsmManager: Unable to inhibit: %s", new_error->message);
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        if (flags == 0) {
+                GError *new_error;
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_GENERAL,
+                                         "Invalid inhibit flags");
+                g_debug ("GsmManager: Unable to inhibit: %s", new_error->message);
+                dbus_g_method_return_error (context, new_error);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        cookie = _generate_unique_cookie (manager);
+        inhibitor = gsm_inhibitor_new (app_id,
+                                       toplevel_xid,
+                                       flags,
+                                       reason,
+                                       dbus_g_method_get_sender (context),
+                                       cookie);
+        gsm_store_add (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor), G_OBJECT (inhibitor));
+        g_object_unref (inhibitor);
+
+        dbus_g_method_return (context, cookie);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_uninhibit (GsmManager            *manager,
+                       guint                  cookie,
+                       DBusGMethodInvocation *context)
+{
+        GsmInhibitor *inhibitor;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        g_debug ("GsmManager: Uninhibit %u", cookie);
+
+        priv = gsm_manager_get_instance_private (manager);
+        inhibitor = (GsmInhibitor *)gsm_store_find (priv->inhibitors,
+                                                    (GsmStoreFunc)_find_by_cookie,
+                                                    &cookie);
+        if (inhibitor == NULL) {
+                GError *new_error;
+
+                new_error = g_error_new (GSM_MANAGER_ERROR,
+                                         GSM_MANAGER_ERROR_GENERAL,
+                                         "Unable to uninhibit: Invalid cookie");
+                dbus_g_method_return_error (context, new_error);
+                g_debug ("Unable to uninhibit: %s", new_error->message);
+                g_error_free (new_error);
+                return FALSE;
+        }
+
+        g_debug ("GsmManager: removing inhibitor %s %u reason '%s' %u connection %s",
+                 gsm_inhibitor_peek_app_id (inhibitor),
+                 gsm_inhibitor_peek_toplevel_xid (inhibitor),
+                 gsm_inhibitor_peek_reason (inhibitor),
+                 gsm_inhibitor_peek_flags (inhibitor),
+                 gsm_inhibitor_peek_bus_name (inhibitor));
+
+        gsm_store_remove (priv->inhibitors, gsm_inhibitor_peek_id (inhibitor));
+
+        dbus_g_method_return (context);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_is_inhibited (GsmManager *manager,
+                          guint       flags,
+                          gboolean   *is_inhibited,
+                          GError     *error)
+{
+        GsmInhibitor *inhibitor;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        if (priv->inhibitors == NULL
+            || gsm_store_size (priv->inhibitors) == 0) {
+                *is_inhibited = FALSE;
+                return TRUE;
+        }
+
+        inhibitor = (GsmInhibitor *) gsm_store_find (priv->inhibitors,
+                                                     (GsmStoreFunc)inhibitor_has_flag,
+                                                     GUINT_TO_POINTER (flags));
+        if (inhibitor == NULL) {
+                *is_inhibited = FALSE;
+        } else {
+                *is_inhibited = TRUE;
+        }
+
+        return TRUE;
+
+}
+
+static gboolean
+listify_store_ids (char       *id,
+                   GObject    *object,
+                   GPtrArray **array)
+{
+        g_ptr_array_add (*array, g_strdup (id));
+        return FALSE;
+}
+
+gboolean
+gsm_manager_get_clients (GsmManager *manager,
+                         GPtrArray **clients,
+                         GError    **error)
+{
+        GsmManagerPrivate *priv;
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        if (clients == NULL) {
+                return FALSE;
+        }
+
+        *clients = g_ptr_array_new ();
+        priv = gsm_manager_get_instance_private (manager);
+        gsm_store_foreach (priv->clients, (GsmStoreFunc)listify_store_ids, clients);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_get_inhibitors (GsmManager *manager,
+                            GPtrArray **inhibitors,
+                            GError    **error)
+{
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        if (inhibitors == NULL) {
+                return FALSE;
+        }
+
+        *inhibitors = g_ptr_array_new ();
+        priv = gsm_manager_get_instance_private (manager);
+        gsm_store_foreach (priv->inhibitors,
+                           (GsmStoreFunc) listify_store_ids,
+                           inhibitors);
+
+        return TRUE;
+}
+
+static gboolean
+_app_has_autostart_condition (const char *id,
+                              GsmApp     *app,
+                              const char *condition)
+{
+        gboolean has;
+        gboolean disabled;
+
+        has = gsm_app_has_autostart_condition (app, condition);
+        disabled = gsm_app_peek_is_disabled (app);
+
+        return has && !disabled;
+}
+
+gboolean
+gsm_manager_is_autostart_condition_handled (GsmManager *manager,
+                                            const char *condition,
+                                            gboolean   *handled,
+                                            GError    **error)
+{
+        GsmApp *app;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        app = (GsmApp *) gsm_store_find (priv->apps,(
+                                         GsmStoreFunc) _app_has_autostart_condition,
+                                         (char *)condition);
+
+        if (app != NULL) {
+                *handled = TRUE;
+        } else {
+                *handled = FALSE;
+        }
+
+        return TRUE;
+}
+
+static void
+append_app (GsmManager *manager,
+            GsmApp     *app)
+{
+        const char *id;
+        const char *app_id;
+        GsmApp     *dup;
+        GsmManagerPrivate *priv;
+
+        id = gsm_app_peek_id (app);
+        if (IS_STRING_EMPTY (id)) {
+                g_debug ("GsmManager: not adding app: no id");
+                return;
+        }
+
+        priv = gsm_manager_get_instance_private (manager);
+        dup = (GsmApp *)gsm_store_lookup (priv->apps, id);
+        if (dup != NULL) {
+                g_debug ("GsmManager: not adding app: already added");
+                return;
+        }
+
+        app_id = gsm_app_peek_app_id (app);
+        if (IS_STRING_EMPTY (app_id)) {
+                g_debug ("GsmManager: not adding app: no app-id");
+                return;
+        }
+
+        dup = find_app_for_app_id (manager, app_id);
+        if (dup != NULL) {
+                g_debug ("GsmManager: not adding app: app-id already exists");
+                return;
+        }
+
+        gsm_store_add (priv->apps, id, G_OBJECT (app));
+}
+
+gboolean
+gsm_manager_add_autostart_app (GsmManager *manager,
+                               const char *path,
+                               const char *provides)
+{
+        GsmApp *app;
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+        g_return_val_if_fail (path != NULL, FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        /* first check to see if service is already provided */
+        if (provides != NULL) {
+                GsmApp *dup;
+
+                dup = (GsmApp *)gsm_store_find (priv->apps,
+                                                (GsmStoreFunc)_find_app_provides,
+                                                (char *)provides);
+                if (dup != NULL) {
+                        g_debug ("GsmManager: service '%s' is already provided", provides);
+                        return FALSE;
+                }
+        }
+
+        app = gsm_autostart_app_new (path);
+        if (app == NULL) {
+                g_warning ("could not read %s", path);
+                return FALSE;
+        }
+
+        g_debug ("GsmManager: read %s", path);
+        append_app (manager, app);
+        g_object_unref (app);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_add_autostart_apps_from_dir (GsmManager *manager,
+                                         const char *path)
+{
+        GDir       *dir;
+        const char *name;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+        g_return_val_if_fail (path != NULL, FALSE);
+
+        g_debug ("GsmManager: *** Adding autostart apps for %s", path);
+
+        dir = g_dir_open (path, 0, NULL);
+        if (dir == NULL) {
+                return FALSE;
+        }
+
+        while ((name = g_dir_read_name (dir))) {
+                char *desktop_file;
+
+                if (!g_str_has_suffix (name, ".desktop")) {
+                        continue;
+                }
+
+                desktop_file = g_build_filename (path, name, NULL);
+                gsm_manager_add_autostart_app (manager, desktop_file, NULL);
+                g_free (desktop_file);
+        }
+
+        g_dir_close (dir);
+
+        return TRUE;
+}
+
+gboolean
+gsm_manager_is_session_running (GsmManager *manager,
+                                gboolean *running,
+                                GError **error)
+{
+        GsmManagerPrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        priv = gsm_manager_get_instance_private (manager);
+        *running = (priv->phase == GSM_MANAGER_PHASE_RUNNING);
+        return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/4.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/4.html new file mode 100644 index 0000000..aa04abc --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/4.html @@ -0,0 +1,277 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
#ifndef __MSM_DESKTOP_APP_DIALOG_H
+#define __MSM_DESKTOP_APP_DIALOG_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gdesktopappinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "gsp-app-manager.h"
+
+G_BEGIN_DECLS
+
+#define MSM_TYPE_DESKTOP_APP_DIALOG              (msm_desktop_app_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (MsmDesktopAppDialog, msm_desktop_app_dialog, MSM, DESKTOP_APP_DIALOG, GtkDialog)
+
+GtkWidget    *msm_desktop_app_dialog_new         (GspAppManager       *manager);
+
+const char   *msm_dektop_app_dialog_get_selected (MsmDesktopAppDialog *dialog);
+
+G_END_DECLS
+
+#endif /* __GSM_APP_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/40.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/40.html new file mode 100644 index 0000000..d3a2b1c --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/40.html @@ -0,0 +1,1419 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER (GClosure     *closure,
+                                                     GValue       *return_value,
+                                                     guint         n_param_values,
+                                                     const GValue *param_values,
+                                                     gpointer      invocation_hint,
+                                                     gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER (GClosure     *closure,
+                                                GValue       *return_value,
+                                                guint         n_param_values,
+                                                const GValue *param_values,
+                                                gpointer      invocation_hint G_GNUC_UNUSED,
+                                                gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+                                                     gpointer arg1,
+                                                     gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 2);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                             GValue       *return_value,
+                                                             guint         n_param_values,
+                                                             const GValue *param_values,
+                                                             gpointer      invocation_hint,
+                                                             gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER_POINTER (GClosure     *closure,
+                                                        GValue       *return_value,
+                                                        guint         n_param_values,
+                                                        const GValue *param_values,
+                                                        gpointer      invocation_hint G_GNUC_UNUSED,
+                                                        gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER_POINTER) (gpointer data1,
+                                                             gpointer arg1,
+                                                             gpointer arg2,
+                                                             gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_VOID__BOXED_POINTER (GClosure     *closure,
+                                                        GValue       *return_value,
+                                                        guint         n_param_values,
+                                                        const GValue *param_values,
+                                                        gpointer      invocation_hint,
+                                                        gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_VOID__BOXED_POINTER (GClosure     *closure,
+                                                   GValue       *return_value G_GNUC_UNUSED,
+                                                   guint         n_param_values,
+                                                   const GValue *param_values,
+                                                   gpointer      invocation_hint G_GNUC_UNUSED,
+                                                   gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__BOXED_POINTER) (gpointer data1,
+                                                    gpointer arg1,
+                                                    gpointer arg2,
+                                                    gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__BOXED_POINTER callback;
+
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__BOXED_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_boxed (param_values + 1),
+            g_marshal_value_peek_pointer (param_values + 2),
+            data2);
+}
+
+#define dbus_glib_marshal_gsm_manager_NONE__BOXED_POINTER	dbus_glib_marshal_gsm_manager_VOID__BOXED_POINTER
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                          GValue       *return_value,
+                                                          guint         n_param_values,
+                                                          const GValue *param_values,
+                                                          gpointer      invocation_hint,
+                                                          gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                     GValue       *return_value,
+                                                     guint         n_param_values,
+                                                     const GValue *param_values,
+                                                     gpointer      invocation_hint G_GNUC_UNUSED,
+                                                     gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER) (gpointer data1,
+                                                          guint arg1,
+                                                          gpointer arg2,
+                                                          gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__UINT_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_uint (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_VOID__STRING_UINT_STRING_UINT_POINTER (GClosure     *closure,
+                                                                          GValue       *return_value,
+                                                                          guint         n_param_values,
+                                                                          const GValue *param_values,
+                                                                          gpointer      invocation_hint,
+                                                                          gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_VOID__STRING_UINT_STRING_UINT_POINTER (GClosure     *closure,
+                                                                     GValue       *return_value G_GNUC_UNUSED,
+                                                                     guint         n_param_values,
+                                                                     const GValue *param_values,
+                                                                     gpointer      invocation_hint G_GNUC_UNUSED,
+                                                                     gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_UINT_STRING_UINT_POINTER) (gpointer data1,
+                                                                      gpointer arg1,
+                                                                      guint arg2,
+                                                                      gpointer arg3,
+                                                                      guint arg4,
+                                                                      gpointer arg5,
+                                                                      gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_UINT_STRING_UINT_POINTER callback;
+
+  g_return_if_fail (n_param_values == 6);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_UINT_STRING_UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_uint (param_values + 2),
+            g_marshal_value_peek_string (param_values + 3),
+            g_marshal_value_peek_uint (param_values + 4),
+            g_marshal_value_peek_pointer (param_values + 5),
+            data2);
+}
+
+#define dbus_glib_marshal_gsm_manager_NONE__STRING_UINT_STRING_UINT_POINTER	dbus_glib_marshal_gsm_manager_VOID__STRING_UINT_STRING_UINT_POINTER
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__UINT_POINTER_POINTER (GClosure     *closure,
+                                                                  GValue       *return_value,
+                                                                  guint         n_param_values,
+                                                                  const GValue *param_values,
+                                                                  gpointer      invocation_hint,
+                                                                  gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__UINT_POINTER_POINTER (GClosure     *closure,
+                                                             GValue       *return_value,
+                                                             guint         n_param_values,
+                                                             const GValue *param_values,
+                                                             gpointer      invocation_hint G_GNUC_UNUSED,
+                                                             gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER_POINTER) (gpointer data1,
+                                                                  guint arg1,
+                                                                  gpointer arg2,
+                                                                  gpointer arg3,
+                                                                  gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__UINT_POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__UINT_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_uint (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       g_marshal_value_peek_pointer (param_values + 3),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_POINTER_POINTER (GClosure     *closure,
+                                                                    GValue       *return_value,
+                                                                    guint         n_param_values,
+                                                                    const GValue *param_values,
+                                                                    gpointer      invocation_hint,
+                                                                    gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_POINTER_POINTER (GClosure     *closure,
+                                                               GValue       *return_value,
+                                                               guint         n_param_values,
+                                                               const GValue *param_values,
+                                                               gpointer      invocation_hint G_GNUC_UNUSED,
+                                                               gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER) (gpointer data1,
+                                                                    gpointer arg1,
+                                                                    gpointer arg2,
+                                                                    gpointer arg3,
+                                                                    gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__STRING_POINTER_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_string (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       g_marshal_value_peek_pointer (param_values + 3),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_BOOLEAN_POINTER (GClosure     *closure,
+                                                                    GValue       *return_value,
+                                                                    guint         n_param_values,
+                                                                    const GValue *param_values,
+                                                                    gpointer      invocation_hint,
+                                                                    gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_BOOLEAN_POINTER (GClosure     *closure,
+                                                               GValue       *return_value,
+                                                               guint         n_param_values,
+                                                               const GValue *param_values,
+                                                               gpointer      invocation_hint G_GNUC_UNUSED,
+                                                               gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_BOOLEAN_POINTER) (gpointer data1,
+                                                                    gpointer arg1,
+                                                                    gboolean arg2,
+                                                                    gpointer arg3,
+                                                                    gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__STRING_BOOLEAN_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__STRING_BOOLEAN_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_string (param_values + 1),
+                       g_marshal_value_peek_boolean (param_values + 2),
+                       g_marshal_value_peek_pointer (param_values + 3),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#define dbus_glib_marshal_gsm_manager_VOID__UINT_POINTER	g_cclosure_marshal_VOID__UINT_POINTER
+
+#define dbus_glib_marshal_gsm_manager_NONE__UINT_POINTER	dbus_glib_marshal_gsm_manager_VOID__UINT_POINTER
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_STRING_POINTER (GClosure     *closure,
+                                                                   GValue       *return_value,
+                                                                   guint         n_param_values,
+                                                                   const GValue *param_values,
+                                                                   gpointer      invocation_hint,
+                                                                   gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_STRING_POINTER (GClosure     *closure,
+                                                              GValue       *return_value,
+                                                              guint         n_param_values,
+                                                              const GValue *param_values,
+                                                              gpointer      invocation_hint G_GNUC_UNUSED,
+                                                              gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_STRING_POINTER) (gpointer data1,
+                                                                   gpointer arg1,
+                                                                   gpointer arg2,
+                                                                   gpointer arg3,
+                                                                   gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__STRING_STRING_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__STRING_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_string (param_values + 1),
+                       g_marshal_value_peek_string (param_values + 2),
+                       g_marshal_value_peek_pointer (param_values + 3),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_manager_VOID__STRING_STRING_POINTER (GClosure     *closure,
+                                                                GValue       *return_value,
+                                                                guint         n_param_values,
+                                                                const GValue *param_values,
+                                                                gpointer      invocation_hint,
+                                                                gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_manager_VOID__STRING_STRING_POINTER (GClosure     *closure,
+                                                           GValue       *return_value G_GNUC_UNUSED,
+                                                           guint         n_param_values,
+                                                           const GValue *param_values,
+                                                           gpointer      invocation_hint G_GNUC_UNUSED,
+                                                           gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__STRING_STRING_POINTER) (gpointer data1,
+                                                            gpointer arg1,
+                                                            gpointer arg2,
+                                                            gpointer arg3,
+                                                            gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__STRING_STRING_POINTER callback;
+
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__STRING_STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_string (param_values + 1),
+            g_marshal_value_peek_string (param_values + 2),
+            g_marshal_value_peek_pointer (param_values + 3),
+            data2);
+}
+
+#define dbus_glib_marshal_gsm_manager_NONE__STRING_STRING_POINTER	dbus_glib_marshal_gsm_manager_VOID__STRING_STRING_POINTER
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gsm_manager_methods[] = {
+  { (GCallback) gsm_manager_setenv, dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_STRING_POINTER, 0 },
+  { (GCallback) gsm_manager_initialization_error, dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_BOOLEAN_POINTER, 58 },
+  { (GCallback) gsm_manager_register_client, dbus_glib_marshal_gsm_manager_NONE__STRING_STRING_POINTER, 128 },
+  { (GCallback) gsm_manager_unregister_client, dbus_glib_marshal_gsm_manager_NONE__BOXED_POINTER, 222 },
+  { (GCallback) gsm_manager_inhibit, dbus_glib_marshal_gsm_manager_NONE__STRING_UINT_STRING_UINT_POINTER, 281 },
+  { (GCallback) gsm_manager_uninhibit, dbus_glib_marshal_gsm_manager_NONE__UINT_POINTER, 389 },
+  { (GCallback) gsm_manager_is_inhibited, dbus_glib_marshal_gsm_manager_BOOLEAN__UINT_POINTER_POINTER, 446 },
+  { (GCallback) gsm_manager_get_clients, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER_POINTER, 517 },
+  { (GCallback) gsm_manager_get_inhibitors, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER_POINTER, 573 },
+  { (GCallback) gsm_manager_is_autostart_condition_handled, dbus_glib_marshal_gsm_manager_BOOLEAN__STRING_POINTER_POINTER, 635 },
+  { (GCallback) gsm_manager_shutdown, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER, 721 },
+  { (GCallback) gsm_manager_can_shutdown, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER_POINTER, 758 },
+  { (GCallback) gsm_manager_logout, dbus_glib_marshal_gsm_manager_BOOLEAN__UINT_POINTER, 819 },
+  { (GCallback) gsm_manager_request_shutdown, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER, 863 },
+  { (GCallback) gsm_manager_request_reboot, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER, 907 },
+  { (GCallback) gsm_manager_is_session_running, dbus_glib_marshal_gsm_manager_BOOLEAN__POINTER_POINTER, 949 },
+};
+
+const DBusGObjectInfo dbus_glib_gsm_manager_object_info = {  1,
+  dbus_glib_gsm_manager_methods,
+  16,
+"org.gnome.SessionManager\0Setenv\0S\0variable\0I\0s\0value\0I\0s\0\0org.gnome.SessionManager\0InitializationError\0S\0message\0I\0s\0fatal\0I\0b\0\0org.gnome.SessionManager\0RegisterClient\0A\0app_id\0I\0s\0client_startup_id\0I\0s\0client_id\0O\0F\0N\0o\0\0org.gnome.SessionManager\0UnregisterClient\0A\0client_id\0I\0o\0\0org.gnome.SessionManager\0Inhibit\0A\0app_id\0I\0s\0toplevel_xid\0I\0u\0reason\0I\0s\0flags\0I\0u\0inhibit_cookie\0O\0F\0N\0u\0\0org.gnome.SessionManager\0Uninhibit\0A\0inhibit_cookie\0I\0u\0\0org.gnome.SessionManager\0IsInhibited\0S\0flags\0I\0u\0is_inhibited\0O\0F\0N\0b\0\0org.gnome.SessionManager\0GetClients\0S\0clients\0O\0F\0N\0ao\0\0org.gnome.SessionManager\0GetInhibitors\0S\0inhibitors\0O\0F\0N\0ao\0\0org.gnome.SessionManager\0IsAutostartConditionHandled\0S\0condition\0I\0s\0handled\0O\0F\0N\0b\0\0org.gnome.SessionManager\0Shutdown\0S\0\0org.gnome.SessionManager\0CanShutdown\0S\0is_available\0O\0F\0N\0b\0\0org.gnome.SessionManager\0Logout\0S\0mode\0I\0u\0\0org.gnome.SessionManager\0RequestShutdown\0S\0\0org.gnome.SessionManager\0RequestReboot\0S\0\0org.gnome.SessionManager\0IsSessionRunning\0S\0running\0O\0F\0N\0b\0\0\0",
+"org.gnome.SessionManager\0ClientAdded\0org.gnome.SessionManager\0ClientRemoved\0org.gnome.SessionManager\0InhibitorAdded\0org.gnome.SessionManager\0InhibitorRemoved\0org.gnome.SessionManager\0SessionRunning\0org.gnome.SessionManager\0SessionOver\0\0",
+"org.gnome.SessionManager\0Renderer\0renderer\0read\0\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/41.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/41.html new file mode 100644 index 0000000..45f1d17 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/41.html @@ -0,0 +1,397 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_PRESENCE_H__
+#define __GSM_PRESENCE_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_PRESENCE            (gsm_presence_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GsmPresence, gsm_presence, GSM, PRESENCE, GObject)
+
+struct _GsmPresenceClass
+{
+        GObjectClass parent_class;
+
+        void          (* status_changed)        (GsmPresence     *presence,
+                                                 guint            status);
+        void          (* status_text_changed)   (GsmPresence     *presence,
+                                                 const char      *status_text);
+
+};
+
+typedef enum {
+        GSM_PRESENCE_STATUS_AVAILABLE = 0,
+        GSM_PRESENCE_STATUS_INVISIBLE,
+        GSM_PRESENCE_STATUS_BUSY,
+        GSM_PRESENCE_STATUS_IDLE,
+} GsmPresenceStatus;
+
+typedef enum
+{
+        GSM_PRESENCE_ERROR_GENERAL = 0,
+        GSM_PRESENCE_NUM_ERRORS
+} GsmPresenceError;
+
+#define GSM_PRESENCE_ERROR gsm_presence_error_quark ()
+GType          gsm_presence_error_get_type       (void);
+#define GSM_PRESENCE_TYPE_ERROR (gsm_presence_error_get_type ())
+
+GQuark         gsm_presence_error_quark          (void);
+
+GsmPresence *  gsm_presence_new                  (void);
+
+void           gsm_presence_set_idle_enabled     (GsmPresence  *presence,
+                                                  gboolean      enabled);
+void           gsm_presence_set_idle_timeout     (GsmPresence  *presence,
+                                                  guint         n_seconds);
+
+/* exported to bus */
+gboolean       gsm_presence_set_status           (GsmPresence  *presence,
+                                                  guint         status,
+                                                  GError      **error);
+gboolean       gsm_presence_set_status_text      (GsmPresence  *presence,
+                                                  const char   *status_text,
+                                                  GError      **error);
+
+G_END_DECLS
+
+#endif /* __GSM_PRESENCE_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/42.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/42.html new file mode 100644 index 0000000..8ae92fb --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/42.html @@ -0,0 +1,381 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_XSMP_CLIENT_H__
+#define __GSM_XSMP_CLIENT_H__
+
+#include "gsm-client.h"
+
+#include <X11/SM/SMlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_XSMP_CLIENT              (gsm_xsmp_client_get_type ())
+G_DECLARE_DERIVABLE_TYPE                  (GsmXSMPClient, gsm_xsmp_client, GSM, XSMP_CLIENT, GsmClient)
+
+struct _GsmXSMPClientClass
+{
+        GsmClientClass parent_class;
+
+        /* signals */
+        gboolean (*register_request)     (GsmXSMPClient  *client,
+                                          char          **client_id);
+        gboolean (*logout_request)       (GsmXSMPClient  *client,
+                                          gboolean        prompt);
+
+        void     (*saved_state)          (GsmXSMPClient  *client);
+
+        void     (*request_phase2)       (GsmXSMPClient  *client);
+
+        void     (*request_interaction)  (GsmXSMPClient  *client);
+        void     (*interaction_done)     (GsmXSMPClient  *client,
+                                          gboolean        cancel_shutdown);
+
+        void     (*save_yourself_done)   (GsmXSMPClient  *client);
+
+};
+
+GsmClient  *gsm_xsmp_client_new                  (IceConn         ice_conn);
+
+void        gsm_xsmp_client_connect              (GsmXSMPClient  *client,
+                                                  SmsConn         conn,
+                                                  unsigned long  *mask_ret,
+                                                  SmsCallbacks   *callbacks_ret);
+
+void        gsm_xsmp_client_save_state           (GsmXSMPClient  *client);
+void        gsm_xsmp_client_save_yourself        (GsmXSMPClient  *client,
+                                                  gboolean        save_state);
+void        gsm_xsmp_client_save_yourself_phase2 (GsmXSMPClient  *client);
+void        gsm_xsmp_client_interact             (GsmXSMPClient  *client);
+void        gsm_xsmp_client_shutdown_cancelled   (GsmXSMPClient  *client);
+
+G_END_DECLS
+
+#endif /* __GSM_XSMP_CLIENT_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/43.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/43.html new file mode 100644 index 0000000..b984a1c --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/43.html @@ -0,0 +1,315 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* gsm-session-save.h
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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_SESSION_SAVE_H__
+#define __GSM_SESSION_SAVE_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-store.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void      gsm_session_save                 (GsmStore  *client_store,
+                                            GError   **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GSM_SESSION_SAVE_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/44.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/44.html new file mode 100644 index 0000000..3d8cbe3 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/44.html @@ -0,0 +1,575 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
#include "gsm-marshal.h"
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* BOOLEAN:POINTER (gsm-marshal.list:1) */
+void
+gsm_marshal_BOOLEAN__POINTER (GClosure     *closure,
+                              GValue       *return_value,
+                              guint         n_param_values,
+                              const GValue *param_values,
+                              gpointer      invocation_hint G_GNUC_UNUSED,
+                              gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer data1,
+                                                     gpointer arg1,
+                                                     gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 2);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_pointer (param_values + 1),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* VOID:BOOLEAN,BOOLEAN,BOOLEAN,STRING (gsm-marshal.list:2) */
+void
+gsm_marshal_VOID__BOOLEAN_BOOLEAN_BOOLEAN_STRING (GClosure     *closure,
+                                                  GValue       *return_value G_GNUC_UNUSED,
+                                                  guint         n_param_values,
+                                                  const GValue *param_values,
+                                                  gpointer      invocation_hint G_GNUC_UNUSED,
+                                                  gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__BOOLEAN_BOOLEAN_BOOLEAN_STRING) (gpointer data1,
+                                                                     gboolean arg1,
+                                                                     gboolean arg2,
+                                                                     gboolean arg3,
+                                                                     gpointer arg4,
+                                                                     gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__BOOLEAN_BOOLEAN_BOOLEAN_STRING callback;
+
+  g_return_if_fail (n_param_values == 5);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__BOOLEAN_BOOLEAN_BOOLEAN_STRING) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_boolean (param_values + 1),
+            g_marshal_value_peek_boolean (param_values + 2),
+            g_marshal_value_peek_boolean (param_values + 3),
+            g_marshal_value_peek_string (param_values + 4),
+            data2);
+}
+
+/* VOID:BOOLEAN,BOOLEAN,POINTER (gsm-marshal.list:3) */
+void
+gsm_marshal_VOID__BOOLEAN_BOOLEAN_POINTER (GClosure     *closure,
+                                           GValue       *return_value G_GNUC_UNUSED,
+                                           guint         n_param_values,
+                                           const GValue *param_values,
+                                           gpointer      invocation_hint G_GNUC_UNUSED,
+                                           gpointer      marshal_data)
+{
+  typedef void (*GMarshalFunc_VOID__BOOLEAN_BOOLEAN_POINTER) (gpointer data1,
+                                                              gboolean arg1,
+                                                              gboolean arg2,
+                                                              gpointer arg3,
+                                                              gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_VOID__BOOLEAN_BOOLEAN_POINTER callback;
+
+  g_return_if_fail (n_param_values == 4);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_VOID__BOOLEAN_BOOLEAN_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  callback (data1,
+            g_marshal_value_peek_boolean (param_values + 1),
+            g_marshal_value_peek_boolean (param_values + 2),
+            g_marshal_value_peek_pointer (param_values + 3),
+            data2);
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/45.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/45.html new file mode 100644 index 0000000..2091ff5 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/45.html @@ -0,0 +1,1407 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gs-idle-monitor.h"
+
+#include "gsm-presence.h"
+#include "gsm-presence-glue.h"
+
+#define GSM_PRESENCE_DBUS_PATH "/org/gnome/SessionManager/Presence"
+
+#define GS_NAME      "org.mate.ScreenSaver"
+#define GS_PATH      "/org/mate/ScreenSaver"
+#define GS_INTERFACE "org.mate.ScreenSaver"
+
+#define MAX_STATUS_TEXT 140
+
+typedef struct {
+        guint            status;
+        guint            saved_status;
+        char            *status_text;
+        gboolean         idle_enabled;
+        GSIdleMonitor   *idle_monitor;
+        guint            idle_watch_id;
+        guint            idle_timeout;
+        gboolean         screensaver_active;
+        DBusGConnection *bus_connection;
+        DBusGProxy      *bus_proxy;
+        DBusGProxy      *screensaver_proxy;
+} GsmPresencePrivate;
+
+enum {
+        PROP_0,
+        PROP_STATUS,
+        PROP_STATUS_TEXT,
+        PROP_IDLE_ENABLED,
+        PROP_IDLE_TIMEOUT,
+};
+
+enum {
+        STATUS_CHANGED,
+        STATUS_TEXT_CHANGED,
+        LAST_SIGNAL
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmPresence, gsm_presence, G_TYPE_OBJECT);
+
+GQuark
+gsm_presence_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_presence_error");
+        }
+
+        return ret;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType
+gsm_presence_error_get_type (void)
+{
+        static GType etype = 0;
+
+        if (etype == 0) {
+                static const GEnumValue values[] = {
+                        ENUM_ENTRY (GSM_PRESENCE_ERROR_GENERAL, "GeneralError"),
+                        { 0, 0, 0 }
+                };
+
+                g_assert (GSM_PRESENCE_NUM_ERRORS == G_N_ELEMENTS (values) - 1);
+
+                etype = g_enum_register_static ("GsmPresenceError", values);
+        }
+
+        return etype;
+}
+
+static void
+set_session_idle (GsmPresence   *presence,
+                  gboolean       is_idle)
+{
+        GsmPresencePrivate *priv;
+
+        g_debug ("GsmPresence: setting idle: %d", is_idle);
+        priv = gsm_presence_get_instance_private (presence);
+
+        if (is_idle) {
+                if (priv->status == GSM_PRESENCE_STATUS_IDLE) {
+                        g_debug ("GsmPresence: already idle, ignoring");
+                        return;
+                }
+
+                /* save current status */
+                priv->saved_status = priv->status;
+                gsm_presence_set_status (presence, GSM_PRESENCE_STATUS_IDLE, NULL);
+        } else {
+                if (priv->status != GSM_PRESENCE_STATUS_IDLE) {
+                        g_debug ("GsmPresence: already not idle, ignoring");
+                        return;
+                }
+
+                /* restore saved status */
+                gsm_presence_set_status (presence, priv->saved_status, NULL);
+                priv->saved_status = GSM_PRESENCE_STATUS_AVAILABLE;
+        }
+}
+
+static gboolean
+on_idle_timeout (GSIdleMonitor *monitor,
+                 guint          id,
+                 gboolean       condition,
+                 GsmPresence   *presence)
+{
+        gboolean handled;
+
+        handled = TRUE;
+        set_session_idle (presence, condition);
+
+        return handled;
+}
+
+static void
+reset_idle_watch (GsmPresence  *presence)
+{
+        GsmPresencePrivate *priv;
+
+        priv = gsm_presence_get_instance_private (presence);
+        if (priv->idle_monitor == NULL) {
+                return;
+        }
+
+        if (priv->idle_watch_id > 0) {
+                g_debug ("GsmPresence: removing idle watch");
+                gs_idle_monitor_remove_watch (priv->idle_monitor,
+                                              priv->idle_watch_id);
+                priv->idle_watch_id = 0;
+        }
+
+        if (! priv->screensaver_active
+            && priv->idle_enabled
+            && priv->idle_timeout > 0) {
+                g_debug ("GsmPresence: adding idle watch");
+
+                priv->idle_watch_id = gs_idle_monitor_add_watch (priv->idle_monitor,
+                                                                 priv->idle_timeout,
+                                                                 (GSIdleMonitorWatchFunc)on_idle_timeout,
+                                                                 presence);
+        }
+}
+
+static void
+on_screensaver_active_changed (DBusGProxy  *proxy,
+                               gboolean     is_active,
+                               GsmPresence *presence)
+{
+        GsmPresencePrivate *priv;
+
+        g_debug ("screensaver status changed: %d", is_active);
+        priv = gsm_presence_get_instance_private (presence);
+        if (priv->screensaver_active != is_active) {
+                priv->screensaver_active = is_active;
+                reset_idle_watch (presence);
+                set_session_idle (presence, is_active);
+        }
+}
+
+static void
+on_screensaver_proxy_destroy (GObject     *proxy,
+                              GsmPresence *presence)
+{
+        GsmPresencePrivate *priv;
+
+        g_warning ("Detected that screensaver has left the bus");
+        priv = gsm_presence_get_instance_private (presence);
+
+        priv->screensaver_proxy = NULL;
+        priv->screensaver_active = FALSE;
+        set_session_idle (presence, FALSE);
+        reset_idle_watch (presence);
+}
+
+static void
+on_bus_name_owner_changed (DBusGProxy  *bus_proxy,
+                           const char  *service_name,
+                           const char  *old_service_name,
+                           const char  *new_service_name,
+                           GsmPresence *presence)
+{
+        GError *error;
+        GsmPresencePrivate *priv;
+
+        priv = gsm_presence_get_instance_private (presence);
+
+        if (service_name == NULL
+            || strcmp (service_name, GS_NAME) != 0) {
+                /* ignore */
+                return;
+        }
+
+        if (strlen (new_service_name) == 0
+            && strlen (old_service_name) > 0) {
+                /* service removed */
+                /* let destroy signal handle this? */
+        } else if (strlen (old_service_name) == 0
+                   && strlen (new_service_name) > 0) {
+                /* service added */
+                error = NULL;
+                priv->screensaver_proxy = dbus_g_proxy_new_for_name_owner (priv->bus_connection,
+                                                                           GS_NAME,
+                                                                           GS_PATH,
+                                                                           GS_INTERFACE,
+                                                                           &error);
+                if (priv->screensaver_proxy != NULL) {
+                        g_signal_connect (priv->screensaver_proxy,
+                                          "destroy",
+                                          G_CALLBACK (on_screensaver_proxy_destroy),
+                                          presence);
+                        dbus_g_proxy_add_signal (priv->screensaver_proxy,
+                                                 "ActiveChanged",
+                                                 G_TYPE_BOOLEAN,
+                                                 G_TYPE_INVALID);
+                        dbus_g_proxy_connect_signal (priv->screensaver_proxy,
+                                                     "ActiveChanged",
+                                                     G_CALLBACK (on_screensaver_active_changed),
+                                                     presence,
+                                                     NULL);
+                } else {
+                        g_warning ("Unable to get screensaver proxy: %s", error->message);
+                        g_error_free (error);
+                }
+        }
+}
+
+static gboolean
+register_presence (GsmPresence *presence)
+{
+        GError *error;
+        GsmPresencePrivate *priv;
+
+        error = NULL;
+
+        priv = gsm_presence_get_instance_private (presence);
+        priv->bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+        if (priv->bus_connection == NULL) {
+                if (error != NULL) {
+                        g_critical ("error getting session bus: %s", error->message);
+                        g_error_free (error);
+                }
+                return FALSE;
+        }
+
+        dbus_g_connection_register_g_object (priv->bus_connection, GSM_PRESENCE_DBUS_PATH, G_OBJECT (presence));
+
+        return TRUE;
+}
+
+static GObject *
+gsm_presence_constructor (GType                  type,
+                          guint                  n_construct_properties,
+                          GObjectConstructParam *construct_properties)
+{
+        GsmPresence *presence;
+        gboolean     res;
+        GsmPresencePrivate *priv;
+
+        presence = GSM_PRESENCE (G_OBJECT_CLASS (gsm_presence_parent_class)->constructor (type,
+                                                                                          n_construct_properties,
+                                                                                          construct_properties));
+        priv = gsm_presence_get_instance_private (presence);
+
+        res = register_presence (presence);
+        if (! res) {
+                g_warning ("Unable to register presence with session bus");
+        }
+
+        priv->bus_proxy = dbus_g_proxy_new_for_name (priv->bus_connection,
+                                                     DBUS_SERVICE_DBUS,
+                                                     DBUS_PATH_DBUS,
+                                                     DBUS_INTERFACE_DBUS);
+        if (priv->bus_proxy != NULL) {
+                dbus_g_proxy_add_signal (priv->bus_proxy,
+                                         "NameOwnerChanged",
+                                         G_TYPE_STRING,
+                                         G_TYPE_STRING,
+                                         G_TYPE_STRING,
+                                         G_TYPE_INVALID);
+                dbus_g_proxy_connect_signal (priv->bus_proxy,
+                                             "NameOwnerChanged",
+                                             G_CALLBACK (on_bus_name_owner_changed),
+                                             presence,
+                                             NULL);
+        }
+
+        return G_OBJECT (presence);
+}
+
+static void
+gsm_presence_init (GsmPresence *presence)
+{
+        GsmPresencePrivate *priv;
+
+        priv = gsm_presence_get_instance_private (presence);
+
+        priv->idle_monitor = gs_idle_monitor_new ();
+}
+
+void
+gsm_presence_set_idle_enabled (GsmPresence  *presence,
+                               gboolean      enabled)
+{
+        g_return_if_fail (GSM_IS_PRESENCE (presence));
+        GsmPresencePrivate *priv;
+
+        priv = gsm_presence_get_instance_private (presence);
+
+        if (priv->idle_enabled != enabled) {
+                priv->idle_enabled = enabled;
+                reset_idle_watch (presence);
+                g_object_notify (G_OBJECT (presence), "idle-enabled");
+
+        }
+}
+
+gboolean
+gsm_presence_set_status_text (GsmPresence  *presence,
+                              const char   *status_text,
+                              GError      **error)
+{
+        GsmPresencePrivate *priv;
+        g_return_val_if_fail (GSM_IS_PRESENCE (presence), FALSE);
+
+        priv = gsm_presence_get_instance_private (presence);
+
+        g_free (priv->status_text);
+
+        /* check length */
+        if (status_text != NULL && strlen (status_text) > MAX_STATUS_TEXT) {
+                g_set_error (error,
+                             GSM_PRESENCE_ERROR,
+                             GSM_PRESENCE_ERROR_GENERAL,
+                             "Status text too long");
+                return FALSE;
+        }
+
+        if (status_text != NULL) {
+                priv->status_text = g_strdup (status_text);
+        } else {
+                priv->status_text = g_strdup ("");
+        }
+        g_object_notify (G_OBJECT (presence), "status-text");
+        g_signal_emit (presence, signals[STATUS_TEXT_CHANGED], 0, priv->status_text);
+        return TRUE;
+}
+
+gboolean
+gsm_presence_set_status (GsmPresence  *presence,
+                         guint         status,
+                         GError      **error)
+{
+        GsmPresencePrivate *priv;
+
+        g_return_val_if_fail (GSM_IS_PRESENCE (presence), FALSE);
+        priv = gsm_presence_get_instance_private (presence);
+
+        if (status != priv->status) {
+                priv->status = status;
+                g_object_notify (G_OBJECT (presence), "status");
+                g_signal_emit (presence, signals[STATUS_CHANGED], 0, priv->status);
+        }
+        return TRUE;
+}
+
+void
+gsm_presence_set_idle_timeout (GsmPresence  *presence,
+                               guint         timeout)
+{
+        GsmPresencePrivate *priv;
+
+        g_return_if_fail (GSM_IS_PRESENCE (presence));
+        priv = gsm_presence_get_instance_private (presence);
+
+        if (timeout != priv->idle_timeout) {
+                priv->idle_timeout = timeout;
+                reset_idle_watch (presence);
+                g_object_notify (G_OBJECT (presence), "idle-timeout");
+        }
+}
+
+static void
+gsm_presence_set_property (GObject       *object,
+                           guint          prop_id,
+                           const GValue  *value,
+                           GParamSpec    *pspec)
+{
+        GsmPresence *self;
+
+        self = GSM_PRESENCE (object);
+
+        switch (prop_id) {
+        case PROP_STATUS:
+                gsm_presence_set_status (self, g_value_get_uint (value), NULL);
+                break;
+        case PROP_STATUS_TEXT:
+                gsm_presence_set_status_text (self, g_value_get_string (value), NULL);
+                break;
+        case PROP_IDLE_ENABLED:
+                gsm_presence_set_idle_enabled (self, g_value_get_boolean (value));
+                break;
+        case PROP_IDLE_TIMEOUT:
+                gsm_presence_set_idle_timeout (self, g_value_get_uint (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_presence_get_property (GObject    *object,
+                           guint       prop_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
+{
+        GsmPresence *self;
+        GsmPresencePrivate *priv;
+
+        self = GSM_PRESENCE (object);
+
+        priv = gsm_presence_get_instance_private (self);
+
+        switch (prop_id) {
+        case PROP_STATUS:
+                g_value_set_uint (value, priv->status);
+                break;
+        case PROP_STATUS_TEXT:
+                g_value_set_string (value, priv->status_text);
+                break;
+        case PROP_IDLE_ENABLED:
+                g_value_set_boolean (value, priv->idle_enabled);
+                break;
+        case PROP_IDLE_TIMEOUT:
+                g_value_set_uint (value, priv->idle_timeout);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_presence_finalize (GObject *object)
+{
+        GsmPresence *presence = (GsmPresence *) object;
+        GsmPresencePrivate *priv;
+
+        priv = gsm_presence_get_instance_private (presence);
+
+        if (priv->idle_watch_id > 0) {
+                gs_idle_monitor_remove_watch (priv->idle_monitor,
+                                              priv->idle_watch_id);
+                priv->idle_watch_id = 0;
+        }
+
+        if (priv->status_text != NULL) {
+                g_free (priv->status_text);
+                priv->status_text = NULL;
+        }
+
+        if (priv->idle_monitor != NULL) {
+                g_object_unref (priv->idle_monitor);
+                priv->idle_monitor = NULL;
+        }
+
+        G_OBJECT_CLASS (gsm_presence_parent_class)->finalize (object);
+}
+
+static void
+gsm_presence_class_init (GsmPresenceClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize             = gsm_presence_finalize;
+        object_class->constructor          = gsm_presence_constructor;
+        object_class->get_property         = gsm_presence_get_property;
+        object_class->set_property         = gsm_presence_set_property;
+
+        signals [STATUS_CHANGED] =
+                g_signal_new ("status-changed",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmPresenceClass, status_changed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__UINT,
+                              G_TYPE_NONE,
+                              1, G_TYPE_UINT);
+        signals [STATUS_TEXT_CHANGED] =
+                g_signal_new ("status-text-changed",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmPresenceClass, status_text_changed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+
+        g_object_class_install_property (object_class,
+                                         PROP_STATUS,
+                                         g_param_spec_uint ("status",
+                                                            "status",
+                                                            "status",
+                                                            0,
+                                                            G_MAXINT,
+                                                            0,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_STATUS_TEXT,
+                                         g_param_spec_string ("status-text",
+                                                              "status text",
+                                                              "status text",
+                                                              "",
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_IDLE_ENABLED,
+                                         g_param_spec_boolean ("idle-enabled",
+                                                               NULL,
+                                                               NULL,
+                                                               FALSE,
+                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+        g_object_class_install_property (object_class,
+                                         PROP_IDLE_TIMEOUT,
+                                         g_param_spec_uint ("idle-timeout",
+                                                            "idle timeout",
+                                                            "idle timeout",
+                                                            0,
+                                                            G_MAXINT,
+                                                            300000,
+                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+        dbus_g_object_type_install_info (GSM_TYPE_PRESENCE, &dbus_glib_gsm_presence_object_info);
+        dbus_g_error_domain_register (GSM_PRESENCE_ERROR, NULL, GSM_PRESENCE_TYPE_ERROR);
+}
+
+GsmPresence *
+gsm_presence_new (void)
+{
+        GsmPresence *presence;
+
+        presence = g_object_new (GSM_TYPE_PRESENCE,
+                                 NULL);
+
+        return presence;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/46.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/46.html new file mode 100644 index 0000000..8b7d5fb --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/46.html @@ -0,0 +1,567 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
/* Generated by dbus-binding-tool; do not edit! */
+
+/* This file is generated by glib-genmarshal, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v)     g_value_get_schar (v)
+#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v)      g_value_get_int (v)
+#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
+#define g_marshal_value_peek_long(v)     g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
+#define g_marshal_value_peek_float(v)    g_value_get_float (v)
+#define g_marshal_value_peek_double(v)   g_value_get_double (v)
+#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v)    g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v)   g_value_get_object (v)
+#define g_marshal_value_peek_variant(v)  g_value_get_variant (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ *          Do not access GValues directly in your code. Instead, use the
+ *          g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
+#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
+#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
+#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
+#define g_marshal_value_peek_variant(v)  (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_presence_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                           GValue       *return_value,
+                                                           guint         n_param_values,
+                                                           const GValue *param_values,
+                                                           gpointer      invocation_hint,
+                                                           gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_presence_BOOLEAN__UINT_POINTER (GClosure     *closure,
+                                                      GValue       *return_value,
+                                                      guint         n_param_values,
+                                                      const GValue *param_values,
+                                                      gpointer      invocation_hint G_GNUC_UNUSED,
+                                                      gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__UINT_POINTER) (gpointer data1,
+                                                          guint arg1,
+                                                          gpointer arg2,
+                                                          gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__UINT_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__UINT_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_uint (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+/* Prototype for -Wmissing-prototypes */
+G_BEGIN_DECLS
+extern
+void dbus_glib_marshal_gsm_presence_BOOLEAN__STRING_POINTER (GClosure     *closure,
+                                                             GValue       *return_value,
+                                                             guint         n_param_values,
+                                                             const GValue *param_values,
+                                                             gpointer      invocation_hint,
+                                                             gpointer      marshal_data);
+G_END_DECLS
+void
+dbus_glib_marshal_gsm_presence_BOOLEAN__STRING_POINTER (GClosure     *closure,
+                                                        GValue       *return_value,
+                                                        guint         n_param_values,
+                                                        const GValue *param_values,
+                                                        gpointer      invocation_hint G_GNUC_UNUSED,
+                                                        gpointer      marshal_data)
+{
+  typedef gboolean (*GMarshalFunc_BOOLEAN__STRING_POINTER) (gpointer data1,
+                                                            gpointer arg1,
+                                                            gpointer arg2,
+                                                            gpointer data2);
+  GCClosure *cc = (GCClosure *) closure;
+  gpointer data1, data2;
+  GMarshalFunc_BOOLEAN__STRING_POINTER callback;
+  gboolean v_return;
+
+  g_return_if_fail (return_value != NULL);
+  g_return_if_fail (n_param_values == 3);
+
+  if (G_CCLOSURE_SWAP_DATA (closure))
+    {
+      data1 = closure->data;
+      data2 = g_value_peek_pointer (param_values + 0);
+    }
+  else
+    {
+      data1 = g_value_peek_pointer (param_values + 0);
+      data2 = closure->data;
+    }
+  callback = (GMarshalFunc_BOOLEAN__STRING_POINTER) (marshal_data ? marshal_data : cc->callback);
+
+  v_return = callback (data1,
+                       g_marshal_value_peek_string (param_values + 1),
+                       g_marshal_value_peek_pointer (param_values + 2),
+                       data2);
+
+  g_value_set_boolean (return_value, v_return);
+}
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+static const DBusGMethodInfo dbus_glib_gsm_presence_methods[] = {
+  { (GCallback) gsm_presence_set_status, dbus_glib_marshal_gsm_presence_BOOLEAN__UINT_POINTER, 0 },
+  { (GCallback) gsm_presence_set_status_text, dbus_glib_marshal_gsm_presence_BOOLEAN__STRING_POINTER, 58 },
+};
+
+const DBusGObjectInfo dbus_glib_gsm_presence_object_info = {  1,
+  dbus_glib_gsm_presence_methods,
+  2,
+"org.gnome.SessionManager.Presence\0SetStatus\0S\0status\0I\0u\0\0org.gnome.SessionManager.Presence\0SetStatusText\0S\0status_text\0I\0s\0\0\0",
+"org.gnome.SessionManager.Presence\0StatusChanged\0org.gnome.SessionManager.Presence\0StatusTextChanged\0\0",
+"org.gnome.SessionManager.Presence\0status\0status\0readwrite\0org.gnome.SessionManager.Presence\0status-text\0status-text\0readwrite\0\0"
+};
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/47.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/47.html new file mode 100644 index 0000000..07853a3 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/47.html @@ -0,0 +1,747 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * gsm-session-save.c
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-util.h"
+#include "gsm-autostart-app.h"
+#include "gsm-client.h"
+
+#include "gsm-session-save.h"
+
+static gboolean gsm_session_clear_saved_session (const char *directory,
+                                                 GHashTable *discard_hash);
+
+typedef struct {
+        char        *dir;
+        GHashTable  *discard_hash;
+        GError     **error;
+} SessionSaveData;
+
+static gboolean
+save_one_client (char            *id,
+                 GObject         *object,
+                 SessionSaveData *data)
+{
+        GsmClient  *client;
+        GKeyFile   *keyfile;
+        char       *path = NULL;
+        char       *filename = NULL;
+        char       *contents = NULL;
+        gsize       length = 0;
+        char       *discard_exec;
+        GError     *local_error;
+
+        client = GSM_CLIENT (object);
+
+        local_error = NULL;
+
+        keyfile = gsm_client_save (client, &local_error);
+
+        if (keyfile == NULL || local_error) {
+                goto out;
+        }
+
+        contents = g_key_file_to_data (keyfile, &length, &local_error);
+
+        if (local_error) {
+                goto out;
+        }
+
+        filename = g_strdup_printf ("%s.desktop",
+                                    gsm_client_peek_startup_id (client));
+
+        path = g_build_filename (data->dir, filename, NULL);
+
+        g_file_set_contents (path,
+                             contents,
+                             length,
+                             &local_error);
+
+        if (local_error) {
+                goto out;
+        }
+
+        discard_exec = g_key_file_get_string (keyfile,
+                                              G_KEY_FILE_DESKTOP_GROUP,
+                                              GSM_AUTOSTART_APP_DISCARD_KEY,
+                                              NULL);
+        if (discard_exec) {
+                g_hash_table_insert (data->discard_hash,
+                                     discard_exec, discard_exec);
+        }
+
+        g_debug ("GsmSessionSave: saved client %s to %s", id, filename);
+
+out:
+        if (keyfile != NULL) {
+                g_key_file_free (keyfile);
+        }
+
+        g_free (contents);
+        g_free (filename);
+        g_free (path);
+
+        /* in case of any error, stop saving session */
+        if (local_error) {
+                g_propagate_error (data->error, local_error);
+                g_error_free (local_error);
+
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+void
+gsm_session_save (GsmStore  *client_store,
+                  GError   **error)
+{
+        const char      *save_dir;
+        char            *tmp_dir;
+        SessionSaveData  data;
+
+        g_debug ("GsmSessionSave: Saving session");
+
+        save_dir = gsm_util_get_saved_session_dir ();
+        if (save_dir == NULL) {
+                g_warning ("GsmSessionSave: cannot create saved session directory");
+                return;
+        }
+
+        tmp_dir = gsm_util_get_empty_tmp_session_dir ();
+        if (tmp_dir == NULL) {
+                g_warning ("GsmSessionSave: cannot create new saved session directory");
+                return;
+        }
+
+        /* save the session in a temp directory, and remember the discard
+         * commands */
+        data.dir = tmp_dir;
+        data.discard_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                                   g_free, NULL);
+        data.error = error;
+
+        gsm_store_foreach (client_store,
+                           (GsmStoreFunc) save_one_client,
+                           &data);
+
+        if (!*error) {
+                /* remove the old saved session */
+                gsm_session_clear_saved_session (save_dir, data.discard_hash);
+
+                /* rename the temp session dir */
+                if (g_file_test (save_dir, G_FILE_TEST_IS_DIR))
+                        g_rmdir (save_dir);
+                g_rename (tmp_dir, save_dir);
+        } else {
+                g_warning ("GsmSessionSave: error saving session: %s", (*error)->message);
+                /* FIXME: we should create a hash table filled with the discard
+                 * commands that are in desktop files from save_dir. */
+                gsm_session_clear_saved_session (tmp_dir, NULL);
+                g_rmdir (tmp_dir);
+        }
+
+        g_hash_table_destroy (data.discard_hash);
+        g_free (tmp_dir);
+}
+
+static gboolean
+gsm_session_clear_one_client (const char *filename,
+                              GHashTable *discard_hash)
+{
+        gboolean  result = TRUE;
+        GKeyFile *key_file = NULL;
+        char     *discard_exec = NULL;
+
+        g_debug ("GsmSessionSave: removing '%s' from saved session", filename);
+
+        key_file = g_key_file_new ();
+        if (g_key_file_load_from_file (key_file, filename,
+                                       G_KEY_FILE_NONE, NULL)) {
+                char **argv;
+                int    argc;
+
+                discard_exec = g_key_file_get_string (key_file,
+                                                      G_KEY_FILE_DESKTOP_GROUP,
+                                                      GSM_AUTOSTART_APP_DISCARD_KEY,
+                                                      NULL);
+                if (!discard_exec)
+                        goto out;
+
+                if (g_hash_table_lookup (discard_hash, discard_exec))
+                        goto out;
+
+                if (!g_shell_parse_argv (discard_exec, &argc, &argv, NULL))
+                        goto out;
+
+                result = g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
+                                        NULL, NULL, NULL, NULL) && result;
+
+                g_strfreev (argv);
+        } else {
+                result = FALSE;
+        }
+
+out:
+        if (key_file)
+                g_key_file_free (key_file);
+        if (discard_exec)
+                g_free (discard_exec);
+
+        result = (g_unlink (filename) == 0) && result;
+
+        return result;
+}
+
+static gboolean
+gsm_session_clear_saved_session (const char *directory,
+                                 GHashTable *discard_hash)
+{
+        GDir       *dir;
+        const char *filename;
+        gboolean    result = TRUE;
+        GError     *error;
+
+        g_debug ("GsmSessionSave: clearing currently saved session at %s",
+                 directory);
+
+        if (directory == NULL) {
+                return FALSE;
+        }
+
+        error = NULL;
+        dir = g_dir_open (directory, 0, &error);
+        if (error) {
+                g_warning ("GsmSessionSave: error loading saved session directory: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        while ((filename = g_dir_read_name (dir))) {
+                char *path = g_build_filename (directory,
+                                               filename, NULL);
+
+                result = gsm_session_clear_one_client (path, discard_hash)
+                         && result;
+
+                g_free (path);
+        }
+
+        g_dir_close (dir);
+
+        return result;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/48.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/48.html new file mode 100644 index 0000000..1dc2bd5 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/48.html @@ -0,0 +1,1097 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007-2008 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-store.h"
+
+typedef struct
+{
+        GHashTable *objects;
+        gboolean    locked;
+} GsmStorePrivate;
+
+enum {
+        ADDED,
+        REMOVED,
+        LAST_SIGNAL
+};
+
+enum {
+        PROP_0,
+        PROP_LOCKED
+};
+
+static guint signals [LAST_SIGNAL] = { 0 };
+
+static void     gsm_store_finalize      (GObject       *object);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmStore, gsm_store, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+GQuark
+gsm_store_error_quark (void)
+{
+        static GQuark ret = 0;
+        if (ret == 0) {
+                ret = g_quark_from_static_string ("gsm_store_error");
+        }
+
+        return ret;
+}
+
+guint
+gsm_store_size (GsmStore    *store)
+{
+        GsmStorePrivate *priv;
+        priv = gsm_store_get_instance_private (store);
+        return g_hash_table_size (priv->objects);
+}
+
+gboolean
+gsm_store_remove (GsmStore   *store,
+                  const char *id)
+{
+        GObject *found;
+        gboolean removed;
+        char    *id_copy;
+        GsmStorePrivate *priv;
+
+        g_return_val_if_fail (store != NULL, FALSE);
+
+        priv = gsm_store_get_instance_private (store);
+        found = g_hash_table_lookup (priv->objects, id);
+        if (found == NULL) {
+                return FALSE;
+        }
+
+        id_copy = g_strdup (id);
+
+        g_object_ref (found);
+
+        removed = g_hash_table_remove (priv->objects, id_copy);
+        g_assert (removed);
+
+        g_signal_emit (store, signals [REMOVED], 0, id_copy);
+
+        g_object_unref (found);
+        g_free (id_copy);
+
+        return TRUE;
+}
+
+void
+gsm_store_foreach (GsmStore    *store,
+                   GsmStoreFunc func,
+                   gpointer     user_data)
+{
+        g_return_if_fail (store != NULL);
+        g_return_if_fail (func != NULL);
+        GsmStorePrivate *priv;
+        priv = gsm_store_get_instance_private (store);
+
+        g_hash_table_find (priv->objects,
+                           (GHRFunc)func,
+                           user_data);
+}
+
+GObject *
+gsm_store_find (GsmStore    *store,
+                GsmStoreFunc predicate,
+                gpointer     user_data)
+{
+        GObject *object;
+        GsmStorePrivate *priv;
+
+        g_return_val_if_fail (store != NULL, NULL);
+        g_return_val_if_fail (predicate != NULL, NULL);
+        priv = gsm_store_get_instance_private (store);
+
+        object = g_hash_table_find (priv->objects,
+                                    (GHRFunc)predicate,
+                                    user_data);
+        return object;
+}
+
+GObject *
+gsm_store_lookup (GsmStore   *store,
+                  const char *id)
+{
+        GObject *object;
+        GsmStorePrivate *priv;
+
+        g_return_val_if_fail (store != NULL, NULL);
+        g_return_val_if_fail (id != NULL, NULL);
+        priv = gsm_store_get_instance_private (store);
+
+        object = g_hash_table_lookup (priv->objects, id);
+
+        return object;
+}
+
+typedef struct
+{
+        GsmStoreFunc func;
+        gpointer     user_data;
+        GsmStore    *store;
+        GList       *removed;
+} WrapperData;
+
+static gboolean
+foreach_remove_wrapper (const char  *id,
+                        GObject     *object,
+                        WrapperData *data)
+{
+        gboolean res;
+
+        res = (data->func) (id, object, data->user_data);
+        if (res) {
+                data->removed = g_list_prepend (data->removed, g_strdup (id));
+        }
+
+        return res;
+}
+
+guint
+gsm_store_foreach_remove (GsmStore    *store,
+                          GsmStoreFunc func,
+                          gpointer     user_data)
+{
+        guint       ret;
+        WrapperData data;
+        GsmStorePrivate *priv;
+
+        g_return_val_if_fail (store != NULL, 0);
+        g_return_val_if_fail (func != NULL, 0);
+        priv = gsm_store_get_instance_private (store);
+
+        data.store = store;
+        data.user_data = user_data;
+        data.func = func;
+        data.removed = NULL;
+
+        ret = g_hash_table_foreach_remove (priv->objects,
+                                           (GHRFunc)foreach_remove_wrapper,
+                                           &data);
+
+        while (data.removed != NULL) {
+                char *id;
+                id = data.removed->data;
+                g_debug ("GsmStore: emitting removed for %s", id);
+                g_signal_emit (store, signals [REMOVED], 0, id);
+                g_free (data.removed->data);
+                data.removed->data = NULL;
+                data.removed = g_list_delete_link (data.removed, data.removed);
+        }
+
+        return ret;
+}
+
+static gboolean
+_remove_all (const char *id,
+             GObject    *object,
+             gpointer    data)
+{
+        return TRUE;
+}
+
+void
+gsm_store_clear (GsmStore *store)
+{
+        g_return_if_fail (store != NULL);
+
+        g_debug ("GsmStore: Clearing object store");
+
+        gsm_store_foreach_remove (store,
+                                  _remove_all,
+                                  NULL);
+}
+
+gboolean
+gsm_store_add (GsmStore   *store,
+               const char *id,
+               GObject    *object)
+{
+        GsmStorePrivate *priv;
+        g_return_val_if_fail (store != NULL, FALSE);
+        g_return_val_if_fail (id != NULL, FALSE);
+        g_return_val_if_fail (object != NULL, FALSE);
+
+        priv = gsm_store_get_instance_private (store);
+
+        /* If we're locked, we don't accept any new session
+           objects. */
+        if (priv->locked) {
+                return FALSE;
+        }
+
+        g_debug ("GsmStore: Adding object id %s to store", id);
+
+        g_hash_table_insert (priv->objects,
+                             g_strdup (id),
+                             g_object_ref (object));
+
+        g_signal_emit (store, signals [ADDED], 0, id);
+
+        return TRUE;
+}
+
+void
+gsm_store_set_locked (GsmStore *store,
+                      gboolean  locked)
+{
+        GsmStorePrivate *priv;
+        g_return_if_fail (GSM_IS_STORE (store));
+        priv = gsm_store_get_instance_private (store);
+
+        priv->locked = locked;
+}
+
+gboolean
+gsm_store_get_locked (GsmStore *store)
+{
+        GsmStorePrivate *priv;
+        g_return_val_if_fail (GSM_IS_STORE (store), FALSE);
+        priv = gsm_store_get_instance_private (store);
+
+        return priv->locked;
+}
+
+static void
+gsm_store_set_property (GObject      *object,
+                        guint         prop_id,
+                        const GValue *value,
+                        GParamSpec   *pspec)
+{
+        GsmStore *self;
+
+        self = GSM_STORE (object);
+
+        switch (prop_id) {
+        case PROP_LOCKED:
+                gsm_store_set_locked (self, g_value_get_boolean (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_store_get_property (GObject    *object,
+                        guint       prop_id,
+                        GValue     *value,
+                        GParamSpec *pspec)
+{
+        GsmStore *self;
+        GsmStorePrivate *priv;
+
+        self = GSM_STORE (object);
+        priv = gsm_store_get_instance_private (self);
+
+        switch (prop_id) {
+        case PROP_LOCKED:
+                g_value_set_boolean (value, priv->locked);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_store_dispose (GObject *object)
+{
+        GsmStore *store;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_STORE (object));
+
+        store = GSM_STORE (object);
+
+        gsm_store_clear (store);
+
+        G_OBJECT_CLASS (gsm_store_parent_class)->dispose (object);
+}
+
+static void
+gsm_store_class_init (GsmStoreClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsm_store_get_property;
+        object_class->set_property = gsm_store_set_property;
+        object_class->finalize = gsm_store_finalize;
+        object_class->dispose = gsm_store_dispose;
+
+        signals [ADDED] =
+                g_signal_new ("added",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmStoreClass, added),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+        signals [REMOVED] =
+                g_signal_new ("removed",
+                              G_TYPE_FROM_CLASS (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmStoreClass, removed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__STRING,
+                              G_TYPE_NONE,
+                              1, G_TYPE_STRING);
+        g_object_class_install_property (object_class,
+                                         PROP_LOCKED,
+                                         g_param_spec_boolean ("locked",
+                                                               NULL,
+                                                               NULL,
+                                                               FALSE,
+                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+static void
+_destroy_object (GObject *object)
+{
+        g_debug ("GsmStore: Unreffing object: %p", object);
+        g_object_unref (object);
+}
+
+static void
+gsm_store_init (GsmStore *store)
+{
+        GsmStorePrivate *priv;
+        priv = gsm_store_get_instance_private (store);
+
+        priv->objects = g_hash_table_new_full (g_str_hash,
+                                               g_str_equal,
+                                               g_free,
+                                               (GDestroyNotify) _destroy_object);
+}
+
+static void
+gsm_store_finalize (GObject *object)
+{
+        GsmStore *store;
+        GsmStorePrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_STORE (object));
+
+        store = GSM_STORE (object);
+        priv = gsm_store_get_instance_private (store);
+
+        g_return_if_fail (priv != NULL);
+
+        g_hash_table_destroy (priv->objects);
+
+        G_OBJECT_CLASS (gsm_store_parent_class)->finalize (object);
+}
+
+GsmStore *
+gsm_store_new (void)
+{
+        GObject *object;
+
+        object = g_object_new (GSM_TYPE_STORE,
+                               NULL);
+
+        return GSM_STORE (object);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/49.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/49.html new file mode 100644 index 0000000..9c9f7eb --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/49.html @@ -0,0 +1,2279 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
/*
+ * Copyright (C) 2013 Stefano Karapetsas <stefano@karapetsas.com>
+ * Copyright (C) 2013-2021 MATE Developers
+ *
+ * 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, 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 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-login.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "gsm-marshal.h"
+#include "gsm-systemd.h"
+
+#define SD_NAME              "org.freedesktop.login1"
+#define SD_PATH              "/org/freedesktop/login1"
+#define SD_INTERFACE         "org.freedesktop.login1.Manager"
+#define SD_SEAT_INTERFACE    "org.freedesktop.login1.Seat"
+#define SD_SESSION_INTERFACE "org.freedesktop.login1.Session"
+
+typedef struct
+{
+    DBusGConnection *dbus_connection;
+    DBusGProxy      *bus_proxy;
+    DBusGProxy      *sd_proxy;
+    guint32          is_connected : 1;
+} GsmSystemdPrivate;
+
+enum {
+    PROP_0,
+    PROP_IS_CONNECTED
+};
+
+enum {
+    REQUEST_COMPLETED = 0,
+    PRIVILEGES_COMPLETED,
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void     gsm_systemd_finalize     (GObject         *object);
+
+static void     gsm_systemd_free_dbus    (GsmSystemd      *manager);
+
+static DBusHandlerResult gsm_systemd_dbus_filter (DBusConnection *connection,
+                                                     DBusMessage    *message,
+                                                     void           *user_data);
+
+static void     gsm_systemd_on_name_owner_changed (DBusGProxy       *bus_proxy,
+                                                   const char       *name,
+                                                   const char       *prev_owner,
+                                                   const char       *new_owner,
+                                                   GsmSystemd       *manager);
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmSystemd, gsm_systemd, G_TYPE_OBJECT);
+
+static void
+gsm_systemd_get_property (GObject    *object,
+                          guint       prop_id,
+                          GValue     *value,
+                          GParamSpec *pspec)
+{
+    GsmSystemdPrivate *priv;
+    GsmSystemd *manager = GSM_SYSTEMD (object);
+
+    priv = gsm_systemd_get_instance_private (manager);
+
+    switch (prop_id) {
+    case PROP_IS_CONNECTED:
+        g_value_set_boolean (value,
+                             priv->is_connected);
+        break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                               prop_id,
+                                               pspec);
+    }
+}
+
+static void
+gsm_systemd_class_init (GsmSystemdClass *manager_class)
+{
+    GObjectClass *object_class;
+    GParamSpec   *param_spec;
+
+    object_class = G_OBJECT_CLASS (manager_class);
+
+    object_class->finalize = gsm_systemd_finalize;
+    object_class->get_property = gsm_systemd_get_property;
+
+    param_spec = g_param_spec_boolean ("is-connected",
+                                       "Is connected",
+                                       "Whether the session is connected to Systemd",
+                                       FALSE,
+                                       G_PARAM_READABLE);
+
+    g_object_class_install_property (object_class, PROP_IS_CONNECTED,
+                                     param_spec);
+
+    signals [REQUEST_COMPLETED] =
+            g_signal_new ("request-completed",
+                          G_OBJECT_CLASS_TYPE (object_class),
+                          G_SIGNAL_RUN_LAST,
+                          G_STRUCT_OFFSET (GsmSystemdClass, request_completed),
+                          NULL,
+                          NULL,
+                          g_cclosure_marshal_VOID__POINTER,
+                          G_TYPE_NONE,
+                          1, G_TYPE_POINTER);
+
+    signals [PRIVILEGES_COMPLETED] =
+            g_signal_new ("privileges-completed",
+                          G_OBJECT_CLASS_TYPE (object_class),
+                          G_SIGNAL_RUN_LAST,
+                          G_STRUCT_OFFSET (GsmSystemdClass, privileges_completed),
+                          NULL,
+                          NULL,
+                          gsm_marshal_VOID__BOOLEAN_BOOLEAN_POINTER,
+                          G_TYPE_NONE,
+                          3, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_POINTER);
+}
+
+static DBusHandlerResult
+gsm_systemd_dbus_filter (DBusConnection *connection,
+                         DBusMessage    *message,
+                         void           *user_data)
+{
+    GsmSystemd *manager;
+
+    manager = GSM_SYSTEMD (user_data);
+
+    if (dbus_message_is_signal (message,
+                                DBUS_INTERFACE_LOCAL, "Disconnected") &&
+        strcmp (dbus_message_get_path (message), DBUS_PATH_LOCAL) == 0) {
+            gsm_systemd_free_dbus (manager);
+            return DBUS_HANDLER_RESULT_HANDLED;
+    }
+
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static gboolean
+gsm_systemd_ensure_sd_connection (GsmSystemd  *manager,
+                                  GError     **error)
+{
+    GError  *connection_error;
+    gboolean is_connected;
+    GsmSystemdPrivate *priv;
+
+    connection_error = NULL;
+
+    priv = gsm_systemd_get_instance_private (manager);
+
+    if (priv->dbus_connection == NULL) {
+        DBusConnection *connection;
+
+        priv->dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM,
+                                                &connection_error);
+
+        if (priv->dbus_connection == NULL) {
+            g_propagate_error (error, connection_error);
+            is_connected = FALSE;
+            goto out;
+        }
+
+        connection = dbus_g_connection_get_connection (priv->dbus_connection);
+        dbus_connection_set_exit_on_disconnect (connection, FALSE);
+        dbus_connection_add_filter (connection,
+                                    gsm_systemd_dbus_filter,
+                                    manager, NULL);
+    }
+
+    if (priv->bus_proxy == NULL) {
+        priv->bus_proxy =
+            dbus_g_proxy_new_for_name_owner (priv->dbus_connection,
+                                             DBUS_SERVICE_DBUS,
+                                             DBUS_PATH_DBUS,
+                                             DBUS_INTERFACE_DBUS,
+                                             &connection_error);
+
+        if (priv->bus_proxy == NULL) {
+            g_propagate_error (error, connection_error);
+            is_connected = FALSE;
+            goto out;
+        }
+
+        dbus_g_proxy_add_signal (priv->bus_proxy,
+                                 "NameOwnerChanged",
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_STRING,
+                                 G_TYPE_INVALID);
+
+        dbus_g_proxy_connect_signal (priv->bus_proxy,
+                                     "NameOwnerChanged",
+                                     G_CALLBACK (gsm_systemd_on_name_owner_changed),
+                                     manager, NULL);
+    }
+
+    if (priv->sd_proxy == NULL) {
+        priv->sd_proxy =
+                dbus_g_proxy_new_for_name_owner (priv->dbus_connection,
+                                                 SD_NAME,
+                                                 SD_PATH,
+                                                 SD_INTERFACE,
+                                                 &connection_error);
+
+        if (priv->sd_proxy == NULL) {
+            g_propagate_error (error, connection_error);
+            is_connected = FALSE;
+            goto out;
+        }
+    }
+
+    is_connected = TRUE;
+
+out:
+    if (priv->is_connected != is_connected) {
+        priv->is_connected = (is_connected != FALSE);
+        g_object_notify (G_OBJECT (manager), "is-connected");
+    }
+
+    if (!is_connected) {
+        if (priv->dbus_connection == NULL) {
+            if (priv->bus_proxy != NULL) {
+                g_object_unref (priv->bus_proxy);
+                priv->bus_proxy = NULL;
+            }
+
+            if (priv->sd_proxy != NULL) {
+                g_object_unref (priv->sd_proxy);
+                priv->sd_proxy = NULL;
+            }
+        } else if (priv->bus_proxy == NULL) {
+            if (priv->sd_proxy != NULL) {
+                g_object_unref (priv->sd_proxy);
+                priv->sd_proxy = NULL;
+            }
+        }
+    }
+
+    return is_connected;
+}
+
+static void
+gsm_systemd_on_name_owner_changed (DBusGProxy    *bus_proxy,
+                                   const char    *name,
+                                   const char    *prev_owner,
+                                   const char    *new_owner,
+                                   GsmSystemd    *manager)
+{
+    GsmSystemdPrivate *priv;
+
+    priv = gsm_systemd_get_instance_private (manager);
+    if (name != NULL && g_strcmp0 (name, SD_NAME) != 0) {
+        return;
+    }
+
+    if (priv->sd_proxy != NULL) {
+        g_object_unref (priv->sd_proxy);
+        priv->sd_proxy = NULL;
+    }
+
+    gsm_systemd_ensure_sd_connection (manager, NULL);
+}
+
+static void
+gsm_systemd_init (GsmSystemd *manager)
+{
+    GError *error;
+
+    error = NULL;
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        g_error_free (error);
+    }
+}
+
+static void
+gsm_systemd_free_dbus (GsmSystemd *manager)
+{
+    GsmSystemdPrivate *priv;
+
+    priv = gsm_systemd_get_instance_private (manager);
+    if (priv->bus_proxy != NULL) {
+        g_object_unref (priv->bus_proxy);
+        priv->bus_proxy = NULL;
+    }
+
+    if (priv->sd_proxy != NULL) {
+        g_object_unref (priv->sd_proxy);
+        priv->sd_proxy = NULL;
+    }
+
+    if (priv->dbus_connection != NULL) {
+        DBusConnection *connection;
+        connection = dbus_g_connection_get_connection (priv->dbus_connection);
+        dbus_connection_remove_filter (connection,
+                                       gsm_systemd_dbus_filter,
+                                       manager);
+
+        dbus_g_connection_unref (priv->dbus_connection);
+        priv->dbus_connection = NULL;
+    }
+}
+
+static void
+gsm_systemd_finalize (GObject *object)
+{
+    GsmSystemd *manager;
+    GObjectClass  *parent_class;
+
+    manager = GSM_SYSTEMD (object);
+
+    parent_class = G_OBJECT_CLASS (gsm_systemd_parent_class);
+
+    gsm_systemd_free_dbus (manager);
+
+    if (parent_class->finalize != NULL) {
+        parent_class->finalize (object);
+    }
+}
+
+GQuark
+gsm_systemd_error_quark (void)
+{
+    static GQuark error_quark = 0;
+
+    if (error_quark == 0) {
+        error_quark = g_quark_from_static_string ("gsm-systemd-error");
+    }
+
+    return error_quark;
+}
+
+GsmSystemd *
+gsm_systemd_new (void)
+{
+    GsmSystemd *manager;
+
+    manager = g_object_new (GSM_TYPE_SYSTEMD, NULL);
+
+    return manager;
+}
+
+static void
+emit_restart_complete (GsmSystemd *manager,
+                       GError     *error)
+{
+    GError *call_error;
+
+    call_error = NULL;
+
+    if (error != NULL) {
+        call_error = g_error_new_literal (GSM_SYSTEMD_ERROR,
+                                          GSM_SYSTEMD_ERROR_RESTARTING,
+                                          error->message);
+    }
+
+    g_signal_emit (G_OBJECT (manager),
+                   signals [REQUEST_COMPLETED],
+                   0, call_error);
+
+    if (call_error != NULL) {
+        g_error_free (call_error);
+    }
+}
+
+static void
+emit_stop_complete (GsmSystemd *manager,
+                    GError     *error)
+{
+    GError *call_error;
+
+    call_error = NULL;
+
+    if (error != NULL) {
+        call_error = g_error_new_literal (GSM_SYSTEMD_ERROR,
+                                          GSM_SYSTEMD_ERROR_STOPPING,
+                                          error->message);
+    }
+
+    g_signal_emit (G_OBJECT (manager),
+                   signals [REQUEST_COMPLETED],
+                   0, call_error);
+
+    if (call_error != NULL) {
+        g_error_free (call_error);
+    }
+}
+
+gboolean
+gsm_systemd_is_last_session_for_user (GsmSystemd *manager)
+{
+        char **sessions = NULL;
+        char *session = NULL;
+        gboolean is_last_session;
+        int ret, i;
+
+#ifdef HAVE_SYSTEMD
+        ret = sd_pid_get_session (getpid (), &session);
+#endif
+
+        if (session == NULL) {
+                return FALSE;
+        }
+
+        if (ret != 0) {
+                free (session);
+                return FALSE;
+        }
+
+#ifdef HAVE_SYSTEMD
+        ret = sd_uid_get_sessions (getuid (), FALSE, &sessions);
+#endif
+
+        if (sessions == NULL) {
+                free (session);
+                return FALSE;
+        }
+
+        if (ret <= 0) {
+                free (session);
+                free (sessions);
+                return FALSE;
+        }
+
+        is_last_session = TRUE;
+        for (i = 0; sessions[i]; i++) {
+                char *state = NULL;
+                char *type = NULL;
+
+                if (g_strcmp0 (sessions[i], session) == 0)
+                        continue;
+
+#ifdef HAVE_SYSTEMD
+                ret = sd_session_get_state (sessions[i], &state);
+#endif
+
+                if (ret != 0)
+                        continue;
+
+                if (g_strcmp0 (state, "closing") == 0) {
+                        free (state);
+                        continue;
+                }
+                free (state);
+
+#ifdef HAVE_SYSTEMD
+                ret = sd_session_get_type (sessions[i], &type);
+#endif
+
+                if (ret != 0)
+                        continue;
+
+                if (g_strcmp0 (type, "x11") != 0 &&
+                    g_strcmp0 (type, "wayland") != 0) {
+                        free (type);
+                        continue;
+                }
+                free (type);
+
+                is_last_session = FALSE;
+
+                break;
+        }
+
+        for (i = 0; sessions[i]; i++)
+                free (sessions[i]);
+        free (sessions);
+        free (session);
+
+        return is_last_session;
+}
+
+void
+gsm_systemd_attempt_restart (GsmSystemd *manager)
+{
+    gboolean res;
+    GError  *error;
+    GsmSystemdPrivate *priv;
+
+    error = NULL;
+    priv = gsm_systemd_get_instance_private (manager);
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        emit_restart_complete (manager, error);
+        g_error_free (error);
+        return;
+    }
+
+    res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                          "Reboot",
+                                          INT_MAX,
+                                          &error,
+                                          G_TYPE_BOOLEAN, TRUE, /* interactive */
+                                          G_TYPE_INVALID,
+                                          G_TYPE_INVALID);
+
+    if (!res) {
+        g_warning ("Unable to restart system: %s", error->message);
+        emit_restart_complete (manager, error);
+        g_error_free (error);
+    } else {
+        emit_restart_complete (manager, NULL);
+    }
+}
+
+void
+gsm_systemd_attempt_stop (GsmSystemd *manager)
+{
+    gboolean res;
+    GError  *error;
+    GsmSystemdPrivate *priv;
+
+    error = NULL;
+    priv = gsm_systemd_get_instance_private (manager);
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        emit_stop_complete (manager, error);
+        g_error_free (error);
+        return;
+    }
+
+    res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                          "PowerOff",
+                                          INT_MAX,
+                                          &error,
+                                          G_TYPE_BOOLEAN, TRUE, /* interactive */
+                                          G_TYPE_INVALID,
+                                          G_TYPE_INVALID);
+
+    if (!res) {
+        g_warning ("Unable to stop system: %s", error->message);
+        emit_stop_complete (manager, error);
+        g_error_free (error);
+    } else {
+        emit_stop_complete (manager, NULL);
+    }
+}
+
+static void
+gsm_systemd_get_session_path (DBusConnection  *connection,
+                              char           **session_path)
+{
+    DBusError       local_error;
+    DBusMessage    *message;
+    DBusMessage    *reply;
+    DBusMessageIter iter;
+    gchar          *session_id = NULL;
+
+#ifdef HAVE_SYSTEMD
+    sd_pid_get_session (getpid (), &session_id);
+#endif
+
+    if (session_id == NULL)
+        return;
+
+    reply = NULL;
+
+    dbus_error_init (&local_error);
+    message = dbus_message_new_method_call (SD_NAME,
+                                            SD_PATH,
+                                            SD_INTERFACE,
+                                            "GetSession");
+    if (message == NULL) {
+            goto out;
+    }
+
+    dbus_message_iter_init_append (message, &iter);
+    dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &session_id);
+
+    dbus_error_init (&local_error);
+    reply = dbus_connection_send_with_reply_and_block (connection,
+                                                       message,
+                                                       -1,
+                                                       &local_error);
+    if (reply == NULL) {
+        if (dbus_error_is_set (&local_error)) {
+            g_warning ("Unable to get session path: %s", local_error.message);
+            dbus_error_free (&local_error);
+            goto out;
+        }
+    }
+
+    dbus_message_iter_init (reply, &iter);
+    dbus_message_iter_get_basic (&iter, session_path);
+
+out:
+    if (message != NULL) {
+        dbus_message_unref (message);
+    }
+    if (reply != NULL) {
+        dbus_message_unref (reply);
+    }
+    if (session_id != NULL) {
+        g_free (session_id);
+    }
+}
+
+void
+gsm_systemd_set_session_idle (GsmSystemd *manager,
+                              gboolean       is_idle)
+{
+    GError         *error;
+    char           *session_path = NULL;
+    DBusMessage    *message;
+    DBusMessage    *reply;
+    DBusError       dbus_error;
+    DBusMessageIter iter;
+    GsmSystemdPrivate *priv;
+
+    error = NULL;
+    priv = gsm_systemd_get_instance_private (manager);
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        g_error_free (error);
+        return;
+    }
+
+    gsm_systemd_get_session_path (dbus_g_connection_get_connection (priv->dbus_connection), &session_path);
+
+    g_return_if_fail (session_path != NULL);
+
+    g_debug ("Updating Systemd idle status: %d", is_idle);
+    message = dbus_message_new_method_call (SD_NAME,
+                                            session_path,
+                                            SD_SESSION_INTERFACE,
+                                            "SetIdleHint");
+    if (message == NULL) {
+            g_debug ("Couldn't allocate the D-Bus message");
+            return;
+    }
+
+    dbus_message_iter_init_append (message, &iter);
+    dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN, &is_idle);
+
+    /* FIXME: use async? */
+    dbus_error_init (&dbus_error);
+    reply = dbus_connection_send_with_reply_and_block (dbus_g_connection_get_connection (priv->dbus_connection),
+                                                       message,
+                                                       -1,
+                                                       &dbus_error);
+    dbus_message_unref (message);
+
+    if (reply != NULL) {
+        dbus_message_unref (reply);
+    }
+
+    if (dbus_error_is_set (&dbus_error)) {
+        g_debug ("%s raised:\n %s\n\n", dbus_error.name, dbus_error.message);
+        dbus_error_free (&dbus_error);
+    }
+}
+
+gboolean
+gsm_systemd_can_switch_user (GsmSystemd *manager)
+{
+    GError  *error;
+    char    *session_id = NULL;
+#ifdef HAVE_SYSTEMD
+    char    *seat_id = NULL;
+#endif
+    int      ret = 0;
+
+    error = NULL;
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+#ifdef HAVE_SYSTEMD
+    sd_pid_get_session (getpid (), &session_id);
+#endif
+
+    if (session_id == NULL)
+        return FALSE;
+
+#ifdef HAVE_SYSTEMD
+    sd_session_get_seat (session_id, &seat_id);
+    ret = sd_seat_can_multi_session (seat_id);
+
+    g_free (session_id);
+    g_free (seat_id);
+#endif
+
+    return ret > 0;
+}
+
+gboolean
+gsm_systemd_get_restart_privileges (GsmSystemd *manager)
+{
+    g_signal_emit (G_OBJECT (manager),
+                   signals [PRIVILEGES_COMPLETED],
+                   0, TRUE, TRUE, NULL);
+
+    return TRUE;
+}
+
+gboolean
+gsm_systemd_get_stop_privileges (GsmSystemd *manager)
+{
+    g_signal_emit (G_OBJECT (manager),
+                   signals [PRIVILEGES_COMPLETED],
+                   0, TRUE, TRUE, NULL);
+
+    return TRUE;
+}
+
+gboolean
+gsm_systemd_can_restart (GsmSystemd *manager)
+{
+    gboolean res;
+    gchar   *value;
+    gboolean can_restart;
+    GError  *error;
+    GsmSystemdPrivate *priv;
+
+    error = NULL;
+    priv = gsm_systemd_get_instance_private (manager);
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                          "CanReboot",
+                                          INT_MAX,
+                                          &error,
+                                          G_TYPE_INVALID,
+                                          G_TYPE_STRING, &value,
+                                          G_TYPE_INVALID);
+    if (res == FALSE) {
+        g_warning ("Could not make DBUS call: %s",
+                   error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    can_restart = g_strcmp0 (value, "yes") == 0 ||
+                  g_strcmp0 (value, "challenge") == 0;
+    g_free (value);
+    return can_restart;
+}
+
+gboolean
+gsm_systemd_can_stop (GsmSystemd *manager)
+{
+    gboolean res;
+    gchar   *value;
+    gboolean can_stop;
+    GError  *error;
+    GsmSystemdPrivate *priv;
+
+    error = NULL;
+    priv = gsm_systemd_get_instance_private (manager);
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                          "CanPowerOff",
+                                          INT_MAX,
+                                          &error,
+                                          G_TYPE_INVALID,
+                                          G_TYPE_STRING, &value,
+                                          G_TYPE_INVALID);
+
+    if (res == FALSE) {
+        g_warning ("Could not make DBUS call: %s",
+                   error->message);
+        g_error_free (error);
+        return FALSE;
+    }
+
+    can_stop = g_strcmp0 (value, "yes") == 0 ||
+               g_strcmp0 (value, "challenge") == 0;
+    g_free (value);
+    return can_stop;
+}
+
+gboolean
+gsm_systemd_can_hibernate (GsmSystemd *manager)
+{
+  gboolean res;
+  gchar   *value;
+  gboolean can_hibernate;
+  GError  *error;
+  GsmSystemdPrivate *priv;
+
+  error = NULL;
+  priv = gsm_systemd_get_instance_private (manager);
+
+  if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+    g_warning ("Could not connect to Systemd: %s",
+               error->message);
+    g_error_free (error);
+    return FALSE;
+  }
+
+  res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                        "CanHibernate",
+                                        INT_MAX,
+                                        &error,
+                                        G_TYPE_INVALID,
+                                        G_TYPE_STRING, &value,
+                                        G_TYPE_INVALID);
+  if (res == FALSE) {
+    g_warning ("Could not make DBUS call: %s",
+               error->message);
+    g_error_free (error);
+    return FALSE;
+  }
+
+  can_hibernate = g_strcmp0 (value, "yes") == 0 ||
+  g_strcmp0 (value, "challenge") == 0;
+  g_free (value);
+  return can_hibernate;
+}
+
+gboolean
+gsm_systemd_can_suspend (GsmSystemd *manager)
+{
+  gboolean res;
+  gchar   *value;
+  gboolean can_suspend;
+  GError  *error;
+  GsmSystemdPrivate *priv;
+
+  error = NULL;
+  priv = gsm_systemd_get_instance_private (manager);
+
+  if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+    g_warning ("Could not connect to Systemd: %s",
+               error->message);
+    g_error_free (error);
+    return FALSE;
+  }
+
+  res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                        "CanSuspend",
+                                        INT_MAX,
+                                        &error,
+                                        G_TYPE_INVALID,
+                                        G_TYPE_STRING, &value,
+                                        G_TYPE_INVALID);
+  if (res == FALSE) {
+    g_warning ("Could not make DBUS call: %s",
+               error->message);
+    g_error_free (error);
+    return FALSE;
+  }
+
+  can_suspend = g_strcmp0 (value, "yes") == 0 ||
+  g_strcmp0 (value, "challenge") == 0;
+  g_free (value);
+  return can_suspend;
+}
+
+void
+gsm_systemd_attempt_hibernate (GsmSystemd *manager)
+{
+  gboolean res;
+  GError  *error;
+  GsmSystemdPrivate *priv;
+
+  error = NULL;
+  priv = gsm_systemd_get_instance_private (manager);
+
+  if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+    g_warning ("Could not connect to Systemd: %s",
+               error->message);
+    g_error_free (error);
+    return;
+  }
+
+  res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                        "Hibernate",
+                                        INT_MAX,
+                                        &error,
+                                        G_TYPE_BOOLEAN, TRUE, /* interactive */
+                                        G_TYPE_INVALID,
+                                        G_TYPE_INVALID);
+  if (res == FALSE) {
+    g_warning ("Could not make DBUS call: %s",
+               error->message);
+    g_error_free (error);
+    return;
+  }
+
+}
+
+void
+gsm_systemd_attempt_suspend (GsmSystemd *manager)
+{
+  gboolean res;
+  GError  *error;
+  GsmSystemdPrivate *priv;
+
+  error = NULL;
+  priv = gsm_systemd_get_instance_private (manager);
+
+  if (!gsm_systemd_ensure_sd_connection (manager, &error)) {
+    g_warning ("Could not connect to Systemd: %s",
+               error->message);
+    g_error_free (error);
+    return;
+  }
+
+  res = dbus_g_proxy_call_with_timeout (priv->sd_proxy,
+                                        "Suspend",
+                                        INT_MAX,
+                                        &error,
+                                        G_TYPE_BOOLEAN, TRUE, /* interactive */
+                                        G_TYPE_INVALID,
+                                        G_TYPE_INVALID);
+  if (res == FALSE) {
+    g_warning ("Could not make DBUS call: %s",
+               error->message);
+    g_error_free (error);
+    return;
+  }
+}
+
+gchar *
+gsm_systemd_get_current_session_type (GsmSystemd *manager)
+{
+    GError   *gerror;
+    gchar    *session_id = NULL;
+    gchar    *session_class = NULL;
+#ifdef HAVE_SYSTEMD
+    int       res;
+#endif
+
+    gerror = NULL;
+
+    if (!gsm_systemd_ensure_sd_connection (manager, &gerror)) {
+        g_warning ("Could not connect to Systemd: %s",
+                   gerror->message);
+        g_error_free (gerror);
+        return NULL;
+    }
+
+#ifdef HAVE_SYSTEMD
+    sd_pid_get_session (getpid (), &session_id);
+#endif
+
+    if (session_id == NULL)
+        return NULL;
+
+#ifdef HAVE_SYSTEMD
+    res = sd_session_get_class (session_id, &session_class);
+    if (res < 0) {
+        g_warning ("Could not get Systemd session class!");
+        return NULL;
+    }
+
+    g_free (session_id);
+#endif
+
+    return session_class;
+}
+
+GsmSystemd *
+gsm_get_systemd (void)
+{
+    static GsmSystemd *manager = NULL;
+
+    if (manager == NULL) {
+        manager = gsm_systemd_new ();
+    }
+
+    return g_object_ref (manager);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/5.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/5.html new file mode 100644 index 0000000..88d7bea --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/5.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ * Copyright (C) 2007, 2009 Vincent Untz.
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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 __GSP_APP_MANAGER_H
+#define __GSP_APP_MANAGER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gsp-app.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSP_TYPE_APP_MANAGER            (gsp_app_manager_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GspAppManager, gsp_app_manager, GSP, APP_MANAGER, GObject)
+
+struct _GspAppManagerClass
+{
+        GObjectClass parent_class;
+
+        void (* added)   (GspAppManager *manager,
+                          GspApp        *app);
+        void (* removed) (GspAppManager *manager,
+                          GspApp        *app);
+};
+
+GspAppManager  *gsp_app_manager_get                    (void);
+
+void            gsp_app_manager_fill                   (GspAppManager *manager);
+
+GSList         *gsp_app_manager_get_apps               (GspAppManager *manager);
+
+GspApp         *gsp_app_manager_find_app_with_basename (GspAppManager *manager,
+                                                        const char    *basename);
+
+const char     *gsp_app_manager_get_dir                (GspAppManager *manager,
+                                                        unsigned int   index);
+
+void            gsp_app_manager_add                    (GspAppManager *manager,
+                                                        GspApp        *app);
+
+G_END_DECLS
+
+#endif /* __GSP_APP_MANAGER_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/50.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/50.html new file mode 100644 index 0000000..bea1ae3 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/50.html @@ -0,0 +1,1723 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * gsm-util.c
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-util.h"
+
+static gchar *_saved_session_dir = NULL;
+
+gchar **
+gsm_get_screen_locker_command (void)
+{
+        const char *screen_locker_command[] = {
+                "mate-screensaver-command --lock",
+                "xscreensaver-command -lock",
+                NULL
+        };
+        gchar **screen_locker_argv = NULL;
+        gsize   i;
+
+        for (i = 0; screen_locker_command[i] != NULL && screen_locker_argv == NULL; i++) {
+                gchar **argv;
+                char   *path;
+
+                argv = g_strsplit (screen_locker_command [i], " ", -1);
+                path = g_find_program_in_path (argv[0]);
+                if (path)
+                        screen_locker_argv = g_strdupv (argv);
+
+                g_free (path);
+                g_strfreev (argv);
+        }
+
+        return screen_locker_argv;
+}
+
+char *
+gsm_util_find_desktop_file_for_app_name (const char *name,
+                                         char      **autostart_dirs)
+{
+        char     *app_path;
+        char    **app_dirs;
+        GKeyFile *key_file;
+        char     *desktop_file;
+        int       i;
+
+        app_path = NULL;
+
+        app_dirs = gsm_util_get_app_dirs ();
+
+        key_file = g_key_file_new ();
+
+        desktop_file = g_strdup_printf ("%s.desktop", name);
+
+        g_debug ("GsmUtil: Looking for file '%s'", desktop_file);
+
+        for (i = 0; app_dirs[i] != NULL; i++) {
+                g_debug ("GsmUtil: Looking in '%s'", app_dirs[i]);
+        }
+
+        g_key_file_load_from_dirs (key_file,
+                                   desktop_file,
+                                   (const char **) app_dirs,
+                                   &app_path,
+                                   G_KEY_FILE_NONE,
+                                   NULL);
+
+        if (app_path != NULL) {
+                g_debug ("GsmUtil: found in XDG app dirs: '%s'", app_path);
+        }
+
+        if (app_path == NULL && autostart_dirs != NULL) {
+                g_key_file_load_from_dirs (key_file,
+                                           desktop_file,
+                                           (const char **) autostart_dirs,
+                                           &app_path,
+                                           G_KEY_FILE_NONE,
+                                           NULL);
+                if (app_path != NULL) {
+                        g_debug ("GsmUtil: found in autostart dirs: '%s'", app_path);
+                }
+
+        }
+
+        /* look for mate vender prefix */
+        if (app_path == NULL) {
+                g_free (desktop_file);
+                desktop_file = g_strdup_printf ("mate-%s.desktop", name);
+
+                g_key_file_load_from_dirs (key_file,
+                                           desktop_file,
+                                           (const char **) app_dirs,
+                                           &app_path,
+                                           G_KEY_FILE_NONE,
+                                           NULL);
+                if (app_path != NULL) {
+                        g_debug ("GsmUtil: found in XDG app dirs: '%s'", app_path);
+                }
+        }
+
+        if (app_path == NULL && autostart_dirs != NULL) {
+                g_key_file_load_from_dirs (key_file,
+                                           desktop_file,
+                                           (const char **) autostart_dirs,
+                                           &app_path,
+                                           G_KEY_FILE_NONE,
+                                           NULL);
+                if (app_path != NULL) {
+                        g_debug ("GsmUtil: found in autostart dirs: '%s'", app_path);
+                }
+        }
+
+        g_free (desktop_file);
+        g_key_file_free (key_file);
+
+        g_strfreev (app_dirs);
+
+        return app_path;
+}
+
+static gboolean
+ensure_dir_exists (const char *dir)
+{
+        if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+                return TRUE;
+
+        if (g_mkdir_with_parents (dir, 0755) == 0)
+                return TRUE;
+
+        if (errno == EEXIST)
+                return g_file_test (dir, G_FILE_TEST_IS_DIR);
+
+        g_warning ("GsmSessionSave: Failed to create directory %s: %s", dir, strerror (errno));
+
+        return FALSE;
+}
+
+gchar *
+gsm_util_get_empty_tmp_session_dir (void)
+{
+        char *tmp;
+        gboolean exists;
+
+        tmp = g_build_filename (g_get_user_config_dir (),
+                                "mate-session",
+                                "saved-session.new",
+                                NULL);
+
+        exists = ensure_dir_exists (tmp);
+
+        if (G_UNLIKELY (!exists)) {
+                g_warning ("GsmSessionSave: could not create directory for saved session: %s", tmp);
+                g_free (tmp);
+                return NULL;
+        } else {
+                /* make sure it's empty */
+                GDir       *dir;
+                const char *filename;
+
+                dir = g_dir_open (tmp, 0, NULL);
+                if (dir) {
+                        while ((filename = g_dir_read_name (dir))) {
+                                gchar *path = g_build_filename (tmp, filename,
+                                                               NULL);
+                                g_unlink (path);
+                                g_free (path);
+                        }
+                        g_dir_close (dir);
+                }
+        }
+
+        return tmp;
+}
+
+const gchar *
+gsm_util_get_saved_session_dir (void)
+{
+        if (_saved_session_dir == NULL) {
+                gboolean exists;
+
+                _saved_session_dir =
+                        g_build_filename (g_get_user_config_dir (),
+                                          "mate-session",
+                                          "saved-session",
+                                          NULL);
+
+                exists = ensure_dir_exists (_saved_session_dir);
+
+                if (G_UNLIKELY (!exists)) {
+                        static gboolean printed_warning = FALSE;
+
+                        if (!printed_warning) {
+                                g_warning ("GsmSessionSave: could not create directory for saved session: %s", _saved_session_dir);
+                                printed_warning = TRUE;
+                        }
+
+                        _saved_session_dir = NULL;
+
+                        return NULL;
+                }
+        }
+
+        return _saved_session_dir;
+}
+
+char **
+gsm_util_get_autostart_dirs ()
+{
+        GPtrArray          *dirs;
+        const char * const *system_config_dirs;
+        const char * const *system_data_dirs;
+        int                 i;
+
+        dirs = g_ptr_array_new ();
+
+        g_ptr_array_add (dirs,
+                         g_build_filename (g_get_user_config_dir (),
+                                           "autostart", NULL));
+
+        system_data_dirs = g_get_system_data_dirs ();
+        for (i = 0; system_data_dirs[i]; i++) {
+                g_ptr_array_add (dirs,
+                                 g_build_filename (system_data_dirs[i],
+                                                   "mate", "autostart", NULL));
+        }
+
+        system_config_dirs = g_get_system_config_dirs ();
+        for (i = 0; system_config_dirs[i]; i++) {
+                g_ptr_array_add (dirs,
+                                 g_build_filename (system_config_dirs[i],
+                                                   "autostart", NULL));
+        }
+
+        g_ptr_array_add (dirs, NULL);
+
+        return (char **) g_ptr_array_free (dirs, FALSE);
+}
+
+char **
+gsm_util_get_app_dirs ()
+{
+        GPtrArray          *dirs;
+        const char * const *system_data_dirs;
+        int                 i;
+
+        dirs = g_ptr_array_new ();
+
+        g_ptr_array_add (dirs,
+			 g_build_filename (g_get_user_data_dir (),
+					   "applications",
+					   NULL));
+
+        system_data_dirs = g_get_system_data_dirs ();
+        for (i = 0; system_data_dirs[i]; i++) {
+                g_ptr_array_add (dirs,
+                                 g_build_filename (system_data_dirs[i],
+                                                   "applications",
+                                                   NULL));
+        }
+
+        g_ptr_array_add (dirs, NULL);
+
+        return (char **) g_ptr_array_free (dirs, FALSE);
+}
+
+char **
+gsm_util_get_desktop_dirs ()
+{
+	char **apps;
+	char **autostart;
+	char **result;
+	int    size;
+	int    i;
+
+	apps = gsm_util_get_app_dirs ();
+	autostart = gsm_util_get_autostart_dirs ();
+
+	size = 0;
+	for (i = 0; apps[i] != NULL; i++) { size++; }
+	for (i = 0; autostart[i] != NULL; i++) { size++; }
+	size += 2; /* saved session + last NULL */
+
+	result = g_new (char *, size + 1);
+
+	for (i = 0; apps[i] != NULL; i++) {
+		result[i] = apps[i];
+	}
+	g_free (apps);
+	size = i;
+
+	for (i = 0; autostart[i] != NULL; i++) {
+		result[size + i] = autostart[i];
+	}
+	g_free (autostart);
+	size = size + i;
+
+	result[size] = g_strdup (gsm_util_get_saved_session_dir ());
+	result[size + 1] = NULL;
+
+	return result;
+}
+
+gboolean
+gsm_util_text_is_blank (const char *str)
+{
+        if (str == NULL) {
+                return TRUE;
+        }
+
+        while (*str) {
+                if (!isspace(*str)) {
+                        return FALSE;
+                }
+
+                str++;
+        }
+
+        return TRUE;
+}
+
+/**
+ * gsm_util_init_error:
+ * @fatal: whether or not the error is fatal to the login session
+ * @format: printf-style error message format
+ * @...: error message args
+ *
+ * Displays the error message to the user. If @fatal is %TRUE, gsm
+ * will exit after displaying the message.
+ *
+ * This should be called for major errors that occur before the
+ * session is up and running. (Notably, it positions the dialog box
+ * itself, since no window manager will be running yet.)
+ **/
+void
+gsm_util_init_error (gboolean    fatal,
+                     const char *format, ...)
+{
+        GtkWidget *dialog;
+        char      *msg;
+        va_list    args;
+
+        va_start (args, format);
+        msg = g_strdup_vprintf (format, args);
+        va_end (args);
+
+        /* If option parsing failed, Gtk won't have been initialized... */
+        if (!gdk_display_get_default ()) {
+                if (!gtk_init_check (NULL, NULL)) {
+                        /* Oh well, no X for you! */
+                        g_printerr (_("Unable to start login session (and unable to connect to the X server)"));
+                        g_printerr ("%s", msg);
+                        exit (1);
+                }
+        }
+
+        dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+                                         GTK_BUTTONS_CLOSE, "%s", msg);
+
+        g_free (msg);
+
+        gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
+        gtk_dialog_run (GTK_DIALOG (dialog));
+
+        gtk_widget_destroy (dialog);
+
+        if (fatal) {
+                gtk_main_quit ();
+        }
+}
+
+/**
+ * gsm_util_generate_startup_id:
+ *
+ * Generates a new SM client ID.
+ *
+ * Return value: an SM client ID.
+ **/
+char *
+gsm_util_generate_startup_id (void)
+{
+        static int     sequence = -1;
+        static guint   rand1 = 0;
+        static guint   rand2 = 0;
+        static pid_t   pid = 0;
+        struct timeval tv;
+
+        /* The XSMP spec defines the ID as:
+         *
+         * Version: "1"
+         * Address type and address:
+         *   "1" + an IPv4 address as 8 hex digits
+         *   "2" + a DECNET address as 12 hex digits
+         *   "6" + an IPv6 address as 32 hex digits
+         * Time stamp: milliseconds since UNIX epoch as 13 decimal digits
+         * Process-ID type and process-ID:
+         *   "1" + POSIX PID as 10 decimal digits
+         * Sequence number as 4 decimal digits
+         *
+         * XSMP client IDs are supposed to be globally unique: if
+         * SmsGenerateClientID() is unable to determine a network
+         * address for the machine, it gives up and returns %NULL.
+         * MATE and KDE have traditionally used a fourth address
+         * format in this case:
+         *   "0" + 16 random hex digits
+         *
+         * We don't even bother trying SmsGenerateClientID(), since the
+         * user's IP address is probably "192.168.1.*" anyway, so a random
+         * number is actually more likely to be globally unique.
+         */
+
+        if (!rand1) {
+                rand1 = g_random_int ();
+                rand2 = g_random_int ();
+                pid = getpid ();
+        }
+
+        sequence = (sequence + 1) % 10000;
+        gettimeofday (&tv, NULL);
+        return g_strdup_printf ("10%.04x%.04x%.10lu%.3u%.10lu%.4d",
+                                rand1,
+                                rand2,
+                                (unsigned long) tv.tv_sec,
+                                (unsigned) tv.tv_usec,
+                                (unsigned long) pid,
+                                sequence);
+}
+
+static gboolean
+gsm_util_update_activation_environment (const char  *variable,
+                                        const char  *value,
+                                        GError     **error)
+{
+        GDBusConnection *connection;
+        gboolean         environment_updated;
+        GVariantBuilder  builder;
+        GVariant        *reply;
+        GError          *bus_error = NULL;
+
+        environment_updated = FALSE;
+        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+
+        if (connection == NULL) {
+                return FALSE;
+        }
+
+        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
+        g_variant_builder_add (&builder, "{ss}", variable, value);
+
+        reply = g_dbus_connection_call_sync (connection,
+                                             "org.freedesktop.DBus",
+                                             "/org/freedesktop/DBus",
+                                             "org.freedesktop.DBus",
+                                             "UpdateActivationEnvironment",
+                                             g_variant_new ("(@a{ss})",
+                                                            g_variant_builder_end (&builder)),
+                                             NULL,
+                                             G_DBUS_CALL_FLAGS_NONE,
+                                             -1, NULL, &bus_error);
+
+        if (bus_error != NULL) {
+                g_propagate_error (error, bus_error);
+        } else {
+                environment_updated = TRUE;
+                g_variant_unref (reply);
+        }
+
+        g_clear_object (&connection);
+
+        return environment_updated;
+}
+
+gboolean
+gsm_util_export_activation_environment (GError     **error)
+{
+        GDBusConnection *connection;
+        gboolean         environment_updated = FALSE;
+        char           **entry_names;
+        int              i = 0;
+        GVariantBuilder  builder;
+        GRegex          *name_regex, *value_regex;
+        GVariant        *reply;
+        GError          *bus_error = NULL;
+
+        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+
+        if (connection == NULL) {
+                return FALSE;
+        }
+
+        name_regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*$", G_REGEX_OPTIMIZE, 0, error);
+
+        if (name_regex == NULL) {
+                return FALSE;
+        }
+
+        value_regex = g_regex_new ("^([[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
+
+        if (value_regex == NULL) {
+                return FALSE;
+        }
+
+        g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{ss}"));
+        for (entry_names = g_listenv (); entry_names[i] != NULL; i++) {
+                const char *entry_name = entry_names[i];
+                const char *entry_value = g_getenv (entry_name);
+
+                if (!g_utf8_validate (entry_name, -1, NULL))
+                    continue;
+
+                if (!g_regex_match (name_regex, entry_name, 0, NULL))
+                    continue;
+
+                if (!g_utf8_validate (entry_value, -1, NULL))
+                    continue;
+
+                if (!g_regex_match (value_regex, entry_value, 0, NULL))
+                    continue;
+
+                g_variant_builder_add (&builder, "{ss}", entry_name, entry_value);
+        }
+        g_regex_unref (name_regex);
+        g_regex_unref (value_regex);
+
+        g_strfreev (entry_names);
+
+        reply = g_dbus_connection_call_sync (connection,
+                                             "org.freedesktop.DBus",
+                                             "/org/freedesktop/DBus",
+                                             "org.freedesktop.DBus",
+                                             "UpdateActivationEnvironment",
+                                             g_variant_new ("(@a{ss})",
+                                                            g_variant_builder_end (&builder)),
+                                             NULL,
+                                             G_DBUS_CALL_FLAGS_NONE,
+                                             -1, NULL, &bus_error);
+
+        if (bus_error != NULL) {
+                g_propagate_error (error, bus_error);
+        } else {
+                environment_updated = TRUE;
+                g_variant_unref (reply);
+        }
+
+        g_clear_object (&connection);
+
+        return environment_updated;
+}
+
+#ifdef HAVE_SYSTEMD
+gboolean
+gsm_util_export_user_environment (GError     **error)
+{
+        GDBusConnection *connection;
+        gboolean         environment_updated = FALSE;
+        char           **entries;
+        int              i = 0;
+        GVariantBuilder  builder;
+        GRegex          *regex;
+        GVariant        *reply;
+        GError          *bus_error = NULL;
+
+        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+
+        if (connection == NULL) {
+                return FALSE;
+        }
+
+        regex = g_regex_new ("^[a-zA-Z_][a-zA-Z0-9_]*=([[:blank:]]|[^[:cntrl:]])*$", G_REGEX_OPTIMIZE, 0, error);
+
+        if (regex == NULL) {
+                return FALSE;
+        }
+
+        g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+        for (entries = g_get_environ (); entries[i] != NULL; i++) {
+                const char *entry = entries[i];
+
+                if (!g_utf8_validate (entry, -1, NULL))
+                    continue;
+
+                if (!g_regex_match (regex, entry, 0, NULL))
+                    continue;
+
+                g_variant_builder_add (&builder, "s", entry);
+        }
+        g_regex_unref (regex);
+
+        g_strfreev (entries);
+
+        reply = g_dbus_connection_call_sync (connection,
+                                             "org.freedesktop.systemd1",
+                                             "/org/freedesktop/systemd1",
+                                             "org.freedesktop.systemd1.Manager",
+                                             "SetEnvironment",
+                                             g_variant_new ("(@as)",
+                                                            g_variant_builder_end (&builder)),
+                                             NULL,
+                                             G_DBUS_CALL_FLAGS_NONE,
+                                             -1, NULL, &bus_error);
+
+        if (bus_error != NULL) {
+                g_propagate_error (error, bus_error);
+        } else {
+                environment_updated = TRUE;
+                g_variant_unref (reply);
+        }
+
+        g_clear_object (&connection);
+
+        return environment_updated;
+}
+
+static gboolean
+gsm_util_update_user_environment (const char  *variable,
+                                  const char  *value,
+                                  GError     **error)
+{
+        GDBusConnection *connection;
+        gboolean         environment_updated;
+        char            *entry;
+        GVariantBuilder  builder;
+        GVariant        *reply;
+        GError          *bus_error = NULL;
+
+        environment_updated = FALSE;
+        connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, error);
+
+        if (connection == NULL) {
+                return FALSE;
+        }
+
+        g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+        entry = g_strdup_printf ("%s=%s", variable, value);
+        g_variant_builder_add (&builder, "s", entry);
+        g_free (entry);
+
+        reply = g_dbus_connection_call_sync (connection,
+                                             "org.freedesktop.systemd1",
+                                             "/org/freedesktop/systemd1",
+                                             "org.freedesktop.systemd1.Manager",
+                                             "SetEnvironment",
+                                             g_variant_new ("(@as)",
+                                                            g_variant_builder_end (&builder)),
+                                             NULL,
+                                             G_DBUS_CALL_FLAGS_NONE,
+                                             -1, NULL, &bus_error);
+
+        if (bus_error != NULL) {
+                g_propagate_error (error, bus_error);
+        } else {
+                environment_updated = TRUE;
+                g_variant_unref (reply);
+        }
+
+        g_clear_object (&connection);
+
+        return environment_updated;
+}
+#endif
+
+void
+gsm_util_setenv (const char *variable,
+                 const char *value)
+{
+        GError *error = NULL;
+
+        g_setenv (variable, value, TRUE);
+
+        /* If this fails it isn't fatal, it means some things like session
+         * management and keyring won't work in activated clients.
+         */
+        if (!gsm_util_update_activation_environment (variable, value, &error)) {
+                g_warning ("Could not make bus activated clients aware of %s=%s environment variable: %s", variable, value, error->message);
+                g_clear_error (&error);
+        }
+
+#ifdef HAVE_SYSTEMD
+        /* If this fails, the system user session won't get the updated environment
+         */
+        if (!gsm_util_update_user_environment (variable, value, &error)) {
+                g_debug ("Could not make systemd aware of %s=%s environment variable: %s", variable, value, error->message);
+                g_clear_error (&error);
+        }
+#endif
+}
+
+GtkWidget*
+gsm_util_dialog_add_button (GtkDialog   *dialog,
+                            const gchar *button_text,
+                            const gchar *icon_name,
+                            gint         response_id)
+{
+	GtkWidget *button;
+
+	button = gtk_button_new_with_mnemonic (button_text);
+	gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+	gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+	gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+	gtk_widget_set_can_default (button, TRUE);
+	gtk_widget_show (button);
+	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+	return button;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/51.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/51.html new file mode 100644 index 0000000..f314ff4 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/51.html @@ -0,0 +1,3063 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-xsmp-client.h"
+#include "gsm-marshal.h"
+
+#include "gsm-util.h"
+#include "gsm-autostart-app.h"
+#include "gsm-manager.h"
+
+#define GsmDesktopFile "_GSM_DesktopFile"
+
+typedef struct {
+        GsmClient  parent;
+        SmsConn    conn;
+        IceConn    ice_connection;
+
+        guint      watch_id;
+
+        char      *description;
+        GPtrArray *props;
+
+        /* SaveYourself state */
+        int        current_save_yourself;
+        int        next_save_yourself;
+        guint      next_save_yourself_allow_interact : 1;
+} GsmXSMPClientPrivate;
+
+enum {
+        PROP_0,
+        PROP_ICE_CONNECTION
+};
+
+enum {
+        REGISTER_REQUEST,
+        LOGOUT_REQUEST,
+        LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GsmXSMPClient, gsm_xsmp_client, GSM_TYPE_CLIENT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static gboolean
+client_iochannel_watch (GIOChannel    *channel,
+                        GIOCondition   condition,
+                        GsmXSMPClient *client)
+{
+        gboolean keep_going;
+        GsmXSMPClientPrivate *priv;
+
+        g_object_ref (client);
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        switch (IceProcessMessages (priv->ice_connection, NULL, NULL)) {
+        case IceProcessMessagesSuccess:
+                keep_going = TRUE;
+                break;
+
+        case IceProcessMessagesIOError:
+                g_debug ("GsmXSMPClient: IceProcessMessagesIOError on '%s'", priv->description);
+                gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FAILED);
+                /* Emitting "disconnected" will eventually cause
+                 * IceCloseConnection() to be called.
+                 */
+                gsm_client_disconnected (GSM_CLIENT (client));
+                keep_going = FALSE;
+                break;
+
+        case IceProcessMessagesConnectionClosed:
+                g_debug ("GsmXSMPClient: IceProcessMessagesConnectionClosed on '%s'",
+                         priv->description);
+                priv->ice_connection = NULL;
+                keep_going = FALSE;
+                break;
+
+        default:
+                g_assert_not_reached ();
+        }
+        g_object_unref (client);
+
+        return keep_going;
+}
+
+static SmProp *
+find_property (GsmXSMPClient *client,
+               const char    *name,
+               int           *index)
+{
+        SmProp *prop;
+        int i;
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        for (i = 0; i < priv->props->len; i++) {
+                prop = priv->props->pdata[i];
+
+                if (!strcmp (prop->name, name)) {
+                        if (index) {
+                                *index = i;
+                        }
+                        return prop;
+                }
+        }
+
+        return NULL;
+}
+
+static void
+set_description (GsmXSMPClient *client)
+{
+        SmProp     *prop;
+        const char *id;
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+        prop = find_property (client, SmProgram, NULL);
+        id = gsm_client_peek_startup_id (GSM_CLIENT (client));
+
+        g_free (priv->description);
+        if (prop) {
+                priv->description = g_strdup_printf ("%p [%.*s %s]",
+                                                     client,
+                                                     prop->vals[0].length,
+                                                     (char *)prop->vals[0].value,
+                                                     id);
+        } else if (id != NULL) {
+                priv->description = g_strdup_printf ("%p [%s]", client, id);
+        } else {
+                priv->description = g_strdup_printf ("%p", client);
+        }
+}
+
+static void
+setup_connection (GsmXSMPClient *client)
+{
+        GIOChannel    *channel;
+        int            fd;
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+        g_debug ("GsmXSMPClient: Setting up new connection");
+
+        fd = IceConnectionNumber (priv->ice_connection);
+        fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+        channel = g_io_channel_unix_new (fd);
+        priv->watch_id = g_io_add_watch (channel,
+                                         G_IO_IN | G_IO_ERR,
+                                         (GIOFunc)client_iochannel_watch,
+                                         client);
+        g_io_channel_unref (channel);
+
+        set_description (client);
+
+        g_debug ("GsmXSMPClient: New client '%s'", priv->description);
+}
+
+static GObject *
+gsm_xsmp_client_constructor (GType                  type,
+                             guint                  n_construct_properties,
+                             GObjectConstructParam *construct_properties)
+{
+        GsmXSMPClient *client;
+
+        client = GSM_XSMP_CLIENT (G_OBJECT_CLASS (gsm_xsmp_client_parent_class)->constructor (type,
+                                                                                              n_construct_properties,
+                                                                                              construct_properties));
+        setup_connection (client);
+
+        return G_OBJECT (client);
+}
+
+static void
+gsm_xsmp_client_init (GsmXSMPClient *client)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        priv->props = g_ptr_array_new ();
+        priv->current_save_yourself = -1;
+        priv->next_save_yourself = -1;
+        priv->next_save_yourself_allow_interact = FALSE;
+}
+
+static void
+delete_property (GsmXSMPClient *client,
+                 const char    *name)
+{
+        int     index;
+        SmProp *prop;
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        prop = find_property (client, name, &index);
+        if (!prop) {
+                return;
+        }
+
+#if 0
+        /* This is wrong anyway; we can't unconditionally run the current
+         * discard command; if this client corresponds to a GsmAppResumed,
+         * and the current discard command is identical to the app's
+         * discard_command, then we don't run the discard command now,
+         * because that would delete a saved state we may want to resume
+         * again later.
+         */
+        if (!strcmp (name, SmDiscardCommand)) {
+                gsm_client_run_discard (GSM_CLIENT (client));
+        }
+#endif
+
+        g_ptr_array_remove_index_fast (priv->props, index);
+        SmFreeProperty (prop);
+}
+
+static void
+debug_print_property (SmProp *prop)
+{
+        GString *tmp;
+        int      i;
+
+        switch (prop->type[0]) {
+        case 'C': /* CARD8 */
+                g_debug ("GsmXSMPClient:   %s = %d", prop->name, *(unsigned char *)prop->vals[0].value);
+                break;
+
+        case 'A': /* ARRAY8 */
+                g_debug ("GsmXSMPClient:   %s = '%s'", prop->name, (char *)prop->vals[0].value);
+                break;
+
+        case 'L': /* LISTofARRAY8 */
+                tmp = g_string_new (NULL);
+                for (i = 0; i < prop->num_vals; i++) {
+                        g_string_append_printf (tmp, "'%.*s' ", prop->vals[i].length,
+                                                (char *)prop->vals[i].value);
+                }
+                g_debug ("GsmXSMPClient:   %s = %s", prop->name, tmp->str);
+                g_string_free (tmp, TRUE);
+                break;
+
+        default:
+                g_debug ("GsmXSMPClient:   %s = ??? (%s)", prop->name, prop->type);
+                break;
+        }
+}
+
+static void
+set_properties_callback (SmsConn     conn,
+                         SmPointer   manager_data,
+                         int         num_props,
+                         SmProp    **props)
+{
+        int            i;
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Set properties from client '%s'", priv->description);
+
+        for (i = 0; i < num_props; i++) {
+                delete_property (client, props[i]->name);
+                g_ptr_array_add (priv->props, props[i]);
+
+                debug_print_property (props[i]);
+
+                if (!strcmp (props[i]->name, SmProgram))
+                        set_description (client);
+        }
+
+        free (props);
+
+}
+
+static void
+delete_properties_callback (SmsConn     conn,
+                            SmPointer   manager_data,
+                            int         num_props,
+                            char      **prop_names)
+{
+        int i;
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Delete properties from '%s'", priv->description);
+
+        for (i = 0; i < num_props; i++) {
+                delete_property (client, prop_names[i]);
+
+                g_debug ("  %s", prop_names[i]);
+        }
+
+        free (prop_names);
+}
+
+static void
+get_properties_callback (SmsConn   conn,
+                         SmPointer manager_data)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Get properties request from '%s'", priv->description);
+
+        SmsReturnProperties (conn,
+                             priv->props->len,
+                             (SmProp **)priv->props->pdata);
+}
+
+static char *
+prop_to_command (SmProp *prop)
+{
+        GString *str;
+        int i, j;
+        gboolean need_quotes;
+
+        str = g_string_new (NULL);
+        for (i = 0; i < prop->num_vals; i++) {
+                char *val = prop->vals[i].value;
+
+                need_quotes = FALSE;
+                for (j = 0; j < prop->vals[i].length; j++) {
+                        if (!g_ascii_isalnum (val[j]) && !strchr ("-_=:./", val[j])) {
+                                need_quotes = TRUE;
+                                break;
+                        }
+                }
+
+                if (i > 0) {
+                        g_string_append_c (str, ' ');
+                }
+
+                if (!need_quotes) {
+                        g_string_append_printf (str,
+                                                "%.*s",
+                                                prop->vals[i].length,
+                                                (char *)prop->vals[i].value);
+                } else {
+                        g_string_append_c (str, '\'');
+                        while (val < (char *)prop->vals[i].value + prop->vals[i].length) {
+                                if (*val == '\'') {
+                                        g_string_append (str, "'\''");
+                                } else {
+                                        g_string_append_c (str, *val);
+                                }
+                                val++;
+                        }
+                        g_string_append_c (str, '\'');
+                }
+        }
+
+        return g_string_free (str, FALSE);
+}
+
+static char *
+xsmp_get_restart_command (GsmClient *client)
+{
+        SmProp *prop;
+
+        prop = find_property (GSM_XSMP_CLIENT (client), SmRestartCommand, NULL);
+
+        if (!prop || strcmp (prop->type, SmLISTofARRAY8) != 0) {
+                return NULL;
+        }
+
+        return prop_to_command (prop);
+}
+
+static char *
+xsmp_get_discard_command (GsmClient *client)
+{
+        SmProp *prop;
+
+        prop = find_property (GSM_XSMP_CLIENT (client), SmDiscardCommand, NULL);
+
+        if (!prop || strcmp (prop->type, SmLISTofARRAY8) != 0) {
+                return NULL;
+        }
+
+        return prop_to_command (prop);
+}
+
+static void
+do_save_yourself (GsmXSMPClient *client,
+                  int            save_type,
+                  gboolean       allow_interact)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+        g_assert (priv->conn != NULL);
+
+        if (priv->next_save_yourself != -1) {
+                /* Either we're currently doing a shutdown and there's a checkpoint
+                 * queued after it, or vice versa. Either way, the new SaveYourself
+                 * is redundant.
+                 */
+                g_debug ("GsmXSMPClient:   skipping redundant SaveYourself for '%s'",
+                         priv->description);
+        } else if (priv->current_save_yourself != -1) {
+                g_debug ("GsmXSMPClient:   queuing new SaveYourself for '%s'",
+                         priv->description);
+                priv->next_save_yourself = save_type;
+                priv->next_save_yourself_allow_interact = (allow_interact != FALSE);
+        } else {
+                priv->current_save_yourself = save_type;
+                /* make sure we don't have anything queued */
+                priv->next_save_yourself = -1;
+                priv->next_save_yourself_allow_interact = FALSE;
+
+                switch (save_type) {
+                case SmSaveLocal:
+                        /* Save state */
+                        SmsSaveYourself (priv->conn,
+                                         SmSaveLocal,
+                                         FALSE,
+                                         SmInteractStyleNone,
+                                         FALSE);
+                        break;
+
+                default:
+                        /* Logout */
+                        if (!allow_interact) {
+                                SmsSaveYourself (priv->conn,
+                                                 save_type, /* save type */
+                                                 TRUE, /* shutdown */
+                                                 SmInteractStyleNone, /* interact style */
+                                                 TRUE); /* fast */
+                        } else {
+                                SmsSaveYourself (priv->conn,
+                                                 save_type, /* save type */
+                                                 TRUE, /* shutdown */
+                                                 SmInteractStyleAny, /* interact style */
+                                                 FALSE /* fast */);
+                        }
+                        break;
+                }
+        }
+}
+
+static void
+xsmp_save_yourself_phase2 (GsmClient *client)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client));
+
+        g_debug ("GsmXSMPClient: xsmp_save_yourself_phase2 ('%s')", priv->description);
+
+        SmsSaveYourselfPhase2 (priv->conn);
+}
+
+static void
+xsmp_interact (GsmClient *client)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client));
+
+        g_debug ("GsmXSMPClient: xsmp_interact ('%s')", priv->description);
+
+        SmsInteract (priv->conn);
+}
+
+static gboolean
+xsmp_cancel_end_session (GsmClient *client,
+                         GError   **error)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client));
+
+        g_debug ("GsmXSMPClient: xsmp_cancel_end_session ('%s')", priv->description);
+
+        if (priv->conn == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Client is not registered");
+                return FALSE;
+        }
+
+        SmsShutdownCancelled (priv->conn);
+
+        /* reset the state */
+        priv->current_save_yourself = -1;
+        priv->next_save_yourself = -1;
+        priv->next_save_yourself_allow_interact = FALSE;
+
+        return TRUE;
+}
+
+static char *
+get_desktop_file_path (GsmXSMPClient *client)
+{
+        SmProp     *prop;
+        char       *desktop_file_path = NULL;
+        char      **dirs;
+        const char *program_name;
+
+        /* XSMP clients using eggsmclient defines a special property
+         * pointing to their respective desktop entry file */
+        prop = find_property (client, GsmDesktopFile, NULL);
+
+        if (prop) {
+                GFile *file = g_file_new_for_uri (prop->vals[0].value);
+                desktop_file_path = g_file_get_path (file);
+                g_object_unref (file);
+                goto out;
+        }
+
+        /* If we can't get desktop file from GsmDesktopFile then we
+         * try to find the desktop file from its program name */
+        prop = find_property (client, SmProgram, NULL);
+
+        if (!prop) {
+                goto out;
+        }
+
+        program_name = prop->vals[0].value;
+
+        dirs = gsm_util_get_autostart_dirs ();
+
+        desktop_file_path =
+                gsm_util_find_desktop_file_for_app_name (program_name,
+                                                         dirs);
+
+        g_strfreev (dirs);
+
+out:
+        g_debug ("GsmXSMPClient: desktop file for client %s is %s",
+                 gsm_client_peek_id (GSM_CLIENT (client)),
+                 desktop_file_path ? desktop_file_path : "(null)");
+
+        return desktop_file_path;
+}
+
+static void
+set_desktop_file_keys_from_client (GsmClient *client,
+                                   GKeyFile  *keyfile)
+{
+        SmProp       *prop;
+        const char   *name;
+        char         *comment;
+
+        prop = find_property (GSM_XSMP_CLIENT (client), SmProgram, NULL);
+
+        if (prop) {
+                name = prop->vals[0].value;
+        } else {
+            /* It'd be really surprising to reach this code: if we're here,
+             * then the XSMP client already has set several XSMP
+             * properties. But it could still be that SmProgram is not set.
+             */
+            name = _("Remembered Application");
+        }
+
+        comment = g_strdup_printf ("Client %s which was automatically saved",
+                                   gsm_client_peek_startup_id (client));
+
+        g_key_file_set_string (keyfile,
+                               G_KEY_FILE_DESKTOP_GROUP,
+                               G_KEY_FILE_DESKTOP_KEY_NAME,
+                               name);
+
+        g_key_file_set_string (keyfile,
+                               G_KEY_FILE_DESKTOP_GROUP,
+                               G_KEY_FILE_DESKTOP_KEY_COMMENT,
+                               comment);
+
+        g_key_file_set_string (keyfile,
+                               G_KEY_FILE_DESKTOP_GROUP,
+                               G_KEY_FILE_DESKTOP_KEY_ICON,
+                               "system-run");
+
+        g_key_file_set_string (keyfile,
+                               G_KEY_FILE_DESKTOP_GROUP,
+                               G_KEY_FILE_DESKTOP_KEY_TYPE,
+                               "Application");
+
+        g_key_file_set_boolean (keyfile,
+                                G_KEY_FILE_DESKTOP_GROUP,
+                                G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY,
+                                TRUE);
+
+        g_free (comment);
+}
+
+static GKeyFile *
+create_client_key_file (GsmClient   *client,
+                        const char  *desktop_file_path,
+                        GError     **error) {
+        GKeyFile *keyfile;
+
+        keyfile = g_key_file_new ();
+
+        if (desktop_file_path != NULL) {
+                g_key_file_load_from_file (keyfile,
+                                           desktop_file_path,
+                                           G_KEY_FILE_KEEP_COMMENTS |
+                                           G_KEY_FILE_KEEP_TRANSLATIONS,
+                                           error);
+        } else {
+                set_desktop_file_keys_from_client (client, keyfile);
+        }
+
+        return keyfile;
+}
+
+static GsmClientRestartStyle
+xsmp_get_restart_style_hint (GsmClient *client);
+
+static GKeyFile *
+xsmp_save (GsmClient *client,
+           GError   **error)
+{
+        GsmClientRestartStyle restart_style;
+
+        GKeyFile *keyfile = NULL;
+        char     *desktop_file_path = NULL;
+        char     *exec_program = NULL;
+        char     *exec_discard = NULL;
+        char     *startup_id = NULL;
+        GError   *local_error;
+
+        g_debug ("GsmXSMPClient: saving client with id %s",
+                 gsm_client_peek_id (client));
+
+        local_error = NULL;
+
+        restart_style = xsmp_get_restart_style_hint (client);
+        if (restart_style == GSM_CLIENT_RESTART_NEVER) {
+                goto out;
+        }
+
+        exec_program = xsmp_get_restart_command (client);
+        if (!exec_program) {
+                goto out;
+        }
+
+        desktop_file_path = get_desktop_file_path (GSM_XSMP_CLIENT (client));
+
+        /* this can accept desktop_file_path == NULL */
+        keyfile = create_client_key_file (client,
+                                          desktop_file_path,
+                                          &local_error);
+
+        if (local_error) {
+                goto out;
+        }
+
+        g_object_get (client,
+                      "startup-id", &startup_id,
+                      NULL);
+
+        g_key_file_set_string (keyfile,
+                               G_KEY_FILE_DESKTOP_GROUP,
+                               GSM_AUTOSTART_APP_STARTUP_ID_KEY,
+                               startup_id);
+
+        g_key_file_set_string (keyfile,
+                               G_KEY_FILE_DESKTOP_GROUP,
+                               G_KEY_FILE_DESKTOP_KEY_EXEC,
+                               exec_program);
+
+        exec_discard = xsmp_get_discard_command (client);
+        if (exec_discard)
+                g_key_file_set_string (keyfile,
+                                       G_KEY_FILE_DESKTOP_GROUP,
+                                       GSM_AUTOSTART_APP_DISCARD_KEY,
+                                       exec_discard);
+
+out:
+        g_free (desktop_file_path);
+        g_free (exec_program);
+        g_free (exec_discard);
+        g_free (startup_id);
+
+        if (local_error != NULL) {
+                g_propagate_error (error, local_error);
+                g_key_file_free (keyfile);
+
+                return NULL;
+        }
+
+        return keyfile;
+}
+
+static gboolean
+xsmp_stop (GsmClient *client,
+           GError   **error)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client));
+
+        g_debug ("GsmXSMPClient: xsmp_stop ('%s')", priv->description);
+
+        if (priv->conn == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Client is not registered");
+                return FALSE;
+        }
+
+        SmsDie (priv->conn);
+
+        return TRUE;
+}
+
+static gboolean
+xsmp_query_end_session (GsmClient *client,
+                        guint      flags,
+                        GError   **error)
+{
+        gboolean allow_interact;
+        int      save_type;
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client));
+
+        if (priv->conn == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Client is not registered");
+                return FALSE;
+        }
+
+        allow_interact = !(flags & GSM_CLIENT_END_SESSION_FLAG_FORCEFUL);
+
+        /* we don't want to save the session state, but we just want to know if
+         * there's user data the client has to save and we want to give the
+         * client a chance to tell the user about it. This is consistent with
+         * the manager not setting GSM_CLIENT_END_SESSION_FLAG_SAVE for this
+         * phase. */
+        save_type = SmSaveGlobal;
+
+        do_save_yourself (GSM_XSMP_CLIENT (client), save_type, allow_interact);
+        return TRUE;
+}
+
+static gboolean
+xsmp_end_session (GsmClient *client,
+                  guint      flags,
+                  GError   **error)
+{
+        gboolean phase2;
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(client));
+
+        if (priv->conn == NULL) {
+                g_set_error (error,
+                             GSM_CLIENT_ERROR,
+                             GSM_CLIENT_ERROR_NOT_REGISTERED,
+                             "Client is not registered");
+                return FALSE;
+        }
+
+        phase2 = (flags & GSM_CLIENT_END_SESSION_FLAG_LAST);
+
+        if (phase2) {
+                xsmp_save_yourself_phase2 (client);
+        } else {
+                gboolean allow_interact;
+                int      save_type;
+
+                /* we gave a chance to interact to the app during
+                 * xsmp_query_end_session(), now it's too late to interact */
+                allow_interact = FALSE;
+
+                if (flags & GSM_CLIENT_END_SESSION_FLAG_SAVE) {
+                        save_type = SmSaveBoth;
+                } else {
+                        save_type = SmSaveGlobal;
+                }
+
+                do_save_yourself (GSM_XSMP_CLIENT (client),
+                                  save_type, allow_interact);
+        }
+
+        return TRUE;
+}
+
+static char *
+xsmp_get_app_name (GsmClient *client)
+{
+        SmProp *prop;
+        char   *name = NULL;
+
+        prop = find_property (GSM_XSMP_CLIENT (client), SmProgram, NULL);
+        if (prop) {
+                name = prop_to_command (prop);
+        }
+
+        return name;
+}
+
+static void
+gsm_client_set_ice_connection (GsmXSMPClient *client,
+                               gpointer       conn)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+        priv->ice_connection = conn;
+}
+
+static void
+gsm_xsmp_client_set_property (GObject       *object,
+                              guint          prop_id,
+                              const GValue  *value,
+                              GParamSpec    *pspec)
+{
+        GsmXSMPClient *self;
+
+        self = GSM_XSMP_CLIENT (object);
+
+        switch (prop_id) {
+        case PROP_ICE_CONNECTION:
+                gsm_client_set_ice_connection (self, g_value_get_pointer (value));
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_xsmp_client_get_property (GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (GSM_XSMP_CLIENT(object));
+
+        switch (prop_id) {
+        case PROP_ICE_CONNECTION:
+                g_value_set_pointer (value, priv->ice_connection);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_xsmp_client_disconnect (GsmXSMPClient *client)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+        if (priv->watch_id > 0) {
+                g_source_remove (priv->watch_id);
+        }
+
+        if (priv->conn != NULL) {
+                SmsCleanUp (priv->conn);
+        }
+
+        if (priv->ice_connection != NULL) {
+                IceSetShutdownNegotiation (priv->ice_connection, FALSE);
+                IceCloseConnection (priv->ice_connection);
+        }
+}
+
+static void
+gsm_xsmp_client_finalize (GObject *object)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client;
+
+        client = GSM_XSMP_CLIENT(object);
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: xsmp_finalize (%s)", priv->description);
+        gsm_xsmp_client_disconnect (client);
+
+        g_free (priv->description);
+        g_ptr_array_foreach (priv->props, (GFunc)SmFreeProperty, NULL);
+        g_ptr_array_free (priv->props, TRUE);
+
+        G_OBJECT_CLASS (gsm_xsmp_client_parent_class)->finalize (object);
+}
+
+static gboolean
+_boolean_handled_accumulator (GSignalInvocationHint *ihint,
+                              GValue                *return_accu,
+                              const GValue          *handler_return,
+                              gpointer               dummy)
+{
+        gboolean    continue_emission;
+        gboolean    signal_handled;
+
+        signal_handled = g_value_get_boolean (handler_return);
+        g_value_set_boolean (return_accu, signal_handled);
+        continue_emission = !signal_handled;
+
+        return continue_emission;
+}
+
+static GsmClientRestartStyle
+xsmp_get_restart_style_hint (GsmClient *client)
+{
+        SmProp               *prop;
+        GsmClientRestartStyle hint;
+
+        g_debug ("GsmXSMPClient: getting restart style");
+        hint = GSM_CLIENT_RESTART_IF_RUNNING;
+
+        prop = find_property (GSM_XSMP_CLIENT (client), SmRestartStyleHint, NULL);
+
+        if (!prop || strcmp (prop->type, SmCARD8) != 0) {
+                return GSM_CLIENT_RESTART_IF_RUNNING;
+        }
+
+        switch (((unsigned char *)prop->vals[0].value)[0]) {
+        case SmRestartIfRunning:
+                hint = GSM_CLIENT_RESTART_IF_RUNNING;
+                break;
+        case SmRestartAnyway:
+                hint = GSM_CLIENT_RESTART_ANYWAY;
+                break;
+        case SmRestartImmediately:
+                hint = GSM_CLIENT_RESTART_IMMEDIATELY;
+                break;
+        case SmRestartNever:
+                hint = GSM_CLIENT_RESTART_NEVER;
+                break;
+        default:
+                break;
+        }
+
+        return hint;
+}
+
+static gboolean
+_parse_value_as_uint (const char *value,
+                      guint      *uintval)
+{
+        char  *end_of_valid_uint;
+        gulong ulong_value;
+        guint  uint_value;
+
+        errno = 0;
+        ulong_value = strtoul (value, &end_of_valid_uint, 10);
+
+        if (*value == '\0' || *end_of_valid_uint != '\0') {
+                return FALSE;
+        }
+
+        uint_value = ulong_value;
+        if (uint_value != ulong_value || errno == ERANGE) {
+                return FALSE;
+        }
+
+        *uintval = uint_value;
+
+        return TRUE;
+}
+
+static guint
+xsmp_get_unix_process_id (GsmClient *client)
+{
+        SmProp  *prop;
+        guint    pid;
+        gboolean res;
+
+        g_debug ("GsmXSMPClient: getting pid");
+
+        prop = find_property (GSM_XSMP_CLIENT (client), SmProcessID, NULL);
+
+        if (!prop || strcmp (prop->type, SmARRAY8) != 0) {
+                return 0;
+        }
+
+        pid = 0;
+        res = _parse_value_as_uint ((char *)prop->vals[0].value, &pid);
+        if (! res) {
+                pid = 0;
+        }
+
+        return pid;
+}
+
+static void
+gsm_xsmp_client_class_init (GsmXSMPClientClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+        GsmClientClass *client_class = GSM_CLIENT_CLASS (klass);
+
+        object_class->finalize             = gsm_xsmp_client_finalize;
+        object_class->constructor          = gsm_xsmp_client_constructor;
+        object_class->get_property         = gsm_xsmp_client_get_property;
+        object_class->set_property         = gsm_xsmp_client_set_property;
+
+        client_class->impl_save                   = xsmp_save;
+        client_class->impl_stop                   = xsmp_stop;
+        client_class->impl_query_end_session      = xsmp_query_end_session;
+        client_class->impl_end_session            = xsmp_end_session;
+        client_class->impl_cancel_end_session     = xsmp_cancel_end_session;
+        client_class->impl_get_app_name           = xsmp_get_app_name;
+        client_class->impl_get_restart_style_hint = xsmp_get_restart_style_hint;
+        client_class->impl_get_unix_process_id    = xsmp_get_unix_process_id;
+
+        signals[REGISTER_REQUEST] =
+                g_signal_new ("register-request",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmXSMPClientClass, register_request),
+                              _boolean_handled_accumulator,
+                              NULL,
+                              gsm_marshal_BOOLEAN__POINTER,
+                              G_TYPE_BOOLEAN,
+                              1, G_TYPE_POINTER);
+        signals[LOGOUT_REQUEST] =
+                g_signal_new ("logout-request",
+                              G_OBJECT_CLASS_TYPE (object_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GsmXSMPClientClass, logout_request),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__BOOLEAN,
+                              G_TYPE_NONE,
+                              1, G_TYPE_BOOLEAN);
+
+        g_object_class_install_property (object_class,
+                                         PROP_ICE_CONNECTION,
+                                         g_param_spec_pointer ("ice-connection",
+                                                               "ice-connection",
+                                                               "ice-connection",
+                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+GsmClient *
+gsm_xsmp_client_new (IceConn ice_conn)
+{
+        GsmXSMPClient *xsmp;
+
+        xsmp = g_object_new (GSM_TYPE_XSMP_CLIENT,
+                             "ice-connection", ice_conn,
+                             NULL);
+
+        return GSM_CLIENT (xsmp);
+}
+
+static Status
+register_client_callback (SmsConn    conn,
+                          SmPointer  manager_data,
+                          char      *previous_id)
+{
+        gboolean       handled;
+        char          *id;
+        GsmXSMPClientPrivate *priv;
+
+        GsmXSMPClient *client = manager_data;
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Client '%s' received RegisterClient(%s)",
+                 priv->description,
+                 previous_id ? previous_id : "NULL");
+
+        /* There are three cases:
+         * 1. id is NULL - we'll use a new one
+         * 2. id is known - we'll use known one
+         * 3. id is unknown - this is an error
+         */
+        id = g_strdup (previous_id);
+
+        handled = FALSE;
+        g_signal_emit (client, signals[REGISTER_REQUEST], 0, &id, &handled);
+        if (! handled) {
+                g_debug ("GsmXSMPClient:  RegisterClient not handled!");
+                g_free (id);
+                free (previous_id);
+                g_assert_not_reached ();
+                return FALSE;
+        }
+
+        if (IS_STRING_EMPTY (id)) {
+                g_debug ("GsmXSMPClient:   rejected: invalid previous_id");
+                free (previous_id);
+                return FALSE;
+        }
+
+        g_object_set (client, "startup-id", id, NULL);
+
+        set_description (client);
+
+        g_debug ("GsmXSMPClient: Sending RegisterClientReply to '%s'", priv->description);
+
+        SmsRegisterClientReply (conn, id);
+
+        if (IS_STRING_EMPTY (previous_id)) {
+                /* Send the initial SaveYourself. */
+                g_debug ("GsmXSMPClient: Sending initial SaveYourself");
+                SmsSaveYourself (conn, SmSaveLocal, False, SmInteractStyleNone, False);
+                priv->current_save_yourself = SmSaveLocal;
+        }
+
+        gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_REGISTERED);
+
+        g_free (id);
+        free (previous_id);
+
+        return TRUE;
+}
+
+static void
+save_yourself_request_callback (SmsConn   conn,
+                                SmPointer manager_data,
+                                int       save_type,
+                                Bool      shutdown,
+                                int       interact_style,
+                                Bool      fast,
+                                Bool      global)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfRequest(%s, %s, %s, %s, %s)",
+                 priv->description,
+                 save_type == SmSaveLocal ? "SmSaveLocal" :
+                 save_type == SmSaveGlobal ? "SmSaveGlobal" : "SmSaveBoth",
+                 shutdown ? "Shutdown" : "!Shutdown",
+                 interact_style == SmInteractStyleAny ? "SmInteractStyleAny" :
+                 interact_style == SmInteractStyleErrors ? "SmInteractStyleErrors" :
+                 "SmInteractStyleNone", fast ? "Fast" : "!Fast",
+                 global ? "Global" : "!Global");
+
+        /* Examining the g_debug above, you can see that there are a total
+         * of 72 different combinations of options that this could have been
+         * called with. However, most of them are stupid.
+         *
+         * If @shutdown and @global are both TRUE, that means the caller is
+         * requesting that a logout message be sent to all clients, so we do
+         * that. We use @fast to decide whether or not to show a
+         * confirmation dialog. (This isn't really what @fast is for, but
+         * the old mate-session and ksmserver both interpret it that way,
+         * so we do too.) We ignore @save_type because we pick the correct
+         * save_type ourselves later based on user prefs, dialog choices,
+         * etc, and we ignore @interact_style, because clients have not used
+         * it correctly consistently enough to make it worth honoring.
+         *
+         * If @shutdown is TRUE and @global is FALSE, the caller is
+         * confused, so we ignore the request.
+         *
+         * If @shutdown is FALSE and @save_type is SmSaveGlobal or
+         * SmSaveBoth, then the client wants us to ask some or all open
+         * applications to save open files to disk, but NOT quit. This is
+         * silly and so we ignore the request.
+         *
+         * If @shutdown is FALSE and @save_type is SmSaveLocal, then the
+         * client wants us to ask some or all open applications to update
+         * their current saved state, but not log out. At the moment, the
+         * code only supports this for the !global case (ie, a client
+         * requesting that it be allowed to update *its own* saved state,
+         * but not having everyone else update their saved state).
+         */
+
+        if (shutdown && global) {
+                g_debug ("GsmXSMPClient:   initiating shutdown");
+                g_signal_emit (client, signals[LOGOUT_REQUEST], 0, !fast);
+        } else if (!shutdown && !global) {
+                g_debug ("GsmXSMPClient:   initiating checkpoint");
+                do_save_yourself (client, SmSaveLocal, TRUE);
+        } else {
+                g_debug ("GsmXSMPClient:   ignoring");
+        }
+}
+
+static void
+save_yourself_phase2_request_callback (SmsConn   conn,
+                                       SmPointer manager_data)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfPhase2Request",
+                 priv->description);
+
+        priv->current_save_yourself = -1;
+
+        /* this is a valid response to SaveYourself and therefore
+           may be a response to a QES or ES */
+        gsm_client_end_session_response (GSM_CLIENT (client),
+                                         TRUE, TRUE, FALSE,
+                                         NULL);
+}
+
+static void
+interact_request_callback (SmsConn   conn,
+                           SmPointer manager_data,
+                           int       dialog_type)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+#if 0
+        gboolean       res;
+        GError        *error;
+#endif
+
+        g_debug ("GsmXSMPClient: Client '%s' received InteractRequest(%s)",
+                 priv->description,
+                 dialog_type == SmDialogNormal ? "Dialog" : "Errors");
+
+        gsm_client_end_session_response (GSM_CLIENT (client),
+                                         FALSE, FALSE, FALSE,
+                                         _("This program is blocking logout."));
+
+#if 0
+        /* Can't just call back with Interact because session client
+           grabs the keyboard!  So, we try to get it to release
+           grabs by telling it we've cancelled the shutdown.
+           This grabbing is clearly bullshit and is not supported by
+           the client spec or protocol spec.
+        */
+        res = xsmp_cancel_end_session (GSM_CLIENT (client), &error);
+        if (! res) {
+                g_warning ("Unable to cancel end session: %s", error->message);
+                g_error_free (error);
+        }
+#endif
+        xsmp_interact (GSM_CLIENT (client));
+}
+
+static void
+interact_done_callback (SmsConn   conn,
+                        SmPointer manager_data,
+                        Bool      cancel_shutdown)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Client '%s' received InteractDone(cancel_shutdown = %s)",
+                 priv->description,
+                 cancel_shutdown ? "True" : "False");
+
+        gsm_client_end_session_response (GSM_CLIENT (client),
+                                         TRUE, FALSE, cancel_shutdown,
+                                         NULL);
+}
+
+static void
+save_yourself_done_callback (SmsConn   conn,
+                             SmPointer manager_data,
+                             Bool      success)
+{
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Client '%s' received SaveYourselfDone(success = %s)",
+                 priv->description,
+                 success ? "True" : "False");
+
+        if (priv->current_save_yourself != -1) {
+                SmsSaveComplete (priv->conn);
+                priv->current_save_yourself = -1;
+        }
+
+        /* If success is false then the application couldn't save data. Nothing
+         * the session manager can do about, though. FIXME: we could display a
+         * dialog about this, I guess. */
+        gsm_client_end_session_response (GSM_CLIENT (client),
+                                         TRUE, FALSE, FALSE,
+                                         NULL);
+
+        if (priv->next_save_yourself) {
+                int      save_type = priv->next_save_yourself;
+                gboolean allow_interact = priv->next_save_yourself_allow_interact;
+
+                priv->next_save_yourself = -1;
+                priv->next_save_yourself_allow_interact = -1;
+                do_save_yourself (client, save_type, allow_interact);
+        }
+}
+
+static void
+close_connection_callback (SmsConn     conn,
+                           SmPointer   manager_data,
+                           int         count,
+                           char      **reason_msgs)
+{
+        int            i;
+        GsmXSMPClientPrivate *priv;
+        GsmXSMPClient *client = manager_data;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+
+        g_debug ("GsmXSMPClient: Client '%s' received CloseConnection", priv->description);
+        for (i = 0; i < count; i++) {
+                g_debug ("GsmXSMPClient:  close reason: '%s'", reason_msgs[i]);
+        }
+        SmFreeReasons (count, reason_msgs);
+
+        gsm_client_set_status (GSM_CLIENT (client), GSM_CLIENT_FINISHED);
+        gsm_client_disconnected (GSM_CLIENT (client));
+}
+
+void
+gsm_xsmp_client_connect (GsmXSMPClient *client,
+                         SmsConn        conn,
+                         unsigned long *mask_ret,
+                         SmsCallbacks  *callbacks_ret)
+{
+        GsmXSMPClientPrivate *priv;
+
+        priv = gsm_xsmp_client_get_instance_private (client);
+        priv->conn = conn;
+
+        g_debug ("GsmXSMPClient: Initializing client %s", priv->description);
+
+        *mask_ret = 0;
+
+        *mask_ret |= SmsRegisterClientProcMask;
+        callbacks_ret->register_client.callback = register_client_callback;
+        callbacks_ret->register_client.manager_data  = client;
+
+        *mask_ret |= SmsInteractRequestProcMask;
+        callbacks_ret->interact_request.callback = interact_request_callback;
+        callbacks_ret->interact_request.manager_data = client;
+
+        *mask_ret |= SmsInteractDoneProcMask;
+        callbacks_ret->interact_done.callback = interact_done_callback;
+        callbacks_ret->interact_done.manager_data = client;
+
+        *mask_ret |= SmsSaveYourselfRequestProcMask;
+        callbacks_ret->save_yourself_request.callback = save_yourself_request_callback;
+        callbacks_ret->save_yourself_request.manager_data = client;
+
+        *mask_ret |= SmsSaveYourselfP2RequestProcMask;
+        callbacks_ret->save_yourself_phase2_request.callback = save_yourself_phase2_request_callback;
+        callbacks_ret->save_yourself_phase2_request.manager_data = client;
+
+        *mask_ret |= SmsSaveYourselfDoneProcMask;
+        callbacks_ret->save_yourself_done.callback = save_yourself_done_callback;
+        callbacks_ret->save_yourself_done.manager_data = client;
+
+        *mask_ret |= SmsCloseConnectionProcMask;
+        callbacks_ret->close_connection.callback = close_connection_callback;
+        callbacks_ret->close_connection.manager_data  = client;
+
+        *mask_ret |= SmsSetPropertiesProcMask;
+        callbacks_ret->set_properties.callback = set_properties_callback;
+        callbacks_ret->set_properties.manager_data = client;
+
+        *mask_ret |= SmsDeletePropertiesProcMask;
+        callbacks_ret->delete_properties.callback = delete_properties_callback;
+        callbacks_ret->delete_properties.manager_data = client;
+
+        *mask_ret |= SmsGetPropertiesProcMask;
+        callbacks_ret->get_properties.callback = get_properties_callback;
+        callbacks_ret->get_properties.manager_data = client;
+}
+
+void
+gsm_xsmp_client_save_state (GsmXSMPClient *client)
+{
+        g_return_if_fail (GSM_IS_XSMP_CLIENT (client));
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/52.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/52.html new file mode 100644 index 0000000..c6e305c --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/52.html @@ -0,0 +1,1683 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/ICE/ICElib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/ICE/ICEutil.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/ICE/ICEconn.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/SM/SMlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if HAVE_XTRANS
+/* Get the proto for _IceTransNoListen */
+#define ICE_t
+#define TRANS_SERVER
+#include <X11/Xtrans/Xtrans.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#undef  ICE_t
+#undef TRANS_SERVER
+#endif /* HAVE_XTRANS */
+
+#include "gsm-xsmp-server.h"
+#include "gsm-xsmp-client.h"
+#include "gsm-util.h"
+
+/* ICEauthority stuff */
+/* Various magic numbers stolen from iceauth.c */
+#define GSM_ICE_AUTH_RETRIES      10
+#define GSM_ICE_AUTH_INTERVAL     2   /* 2 seconds */
+#define GSM_ICE_AUTH_LOCK_TIMEOUT 600 /* 10 minutes */
+
+#define GSM_ICE_MAGIC_COOKIE_AUTH_NAME "MIT-MAGIC-COOKIE-1"
+#define GSM_ICE_MAGIC_COOKIE_LEN       16
+
+struct _GsmXsmpServer
+{
+        GObject         parent;
+        GsmStore       *client_store;
+
+        IceListenObj   *xsmp_sockets;
+        int             num_xsmp_sockets;
+        int             num_local_xsmp_sockets;
+
+};
+
+enum {
+        PROP_0,
+        PROP_CLIENT_STORE
+};
+
+static void     gsm_xsmp_server_finalize    (GObject         *object);
+
+static gpointer xsmp_server_object = NULL;
+
+G_DEFINE_TYPE (GsmXsmpServer, gsm_xsmp_server, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+typedef struct {
+        GsmXsmpServer *server;
+        IceListenObj   listener;
+} GsmIceConnectionData;
+
+typedef struct {
+        guint watch_id;
+        guint protocol_timeout;
+} GsmIceConnectionWatch;
+
+static void
+disconnect_ice_connection (IceConn ice_conn)
+{
+        IceSetShutdownNegotiation (ice_conn, FALSE);
+        IceCloseConnection (ice_conn);
+}
+
+static void
+free_ice_connection_watch (GsmIceConnectionWatch *data)
+{
+        if (data->watch_id) {
+                g_source_remove (data->watch_id);
+                data->watch_id = 0;
+        }
+
+        if (data->protocol_timeout) {
+                g_source_remove (data->protocol_timeout);
+                data->protocol_timeout = 0;
+        }
+
+        g_free (data);
+}
+
+static gboolean
+ice_protocol_timeout (IceConn ice_conn)
+{
+        GsmIceConnectionWatch *data;
+
+        g_debug ("GsmXsmpServer: ice_protocol_timeout for IceConn %p with status %d",
+                 ice_conn, IceConnectionStatus (ice_conn));
+
+        data = ice_conn->context;
+
+        free_ice_connection_watch (data);
+        disconnect_ice_connection (ice_conn);
+
+        return FALSE;
+}
+
+static gboolean
+auth_iochannel_watch (GIOChannel   *source,
+                      GIOCondition  condition,
+                      IceConn       ice_conn)
+{
+
+        GsmIceConnectionWatch *data;
+        gboolean               keep_going;
+
+        data = ice_conn->context;
+
+        switch (IceProcessMessages (ice_conn, NULL, NULL)) {
+        case IceProcessMessagesSuccess:
+                keep_going = TRUE;
+                break;
+        case IceProcessMessagesIOError:
+                g_debug ("GsmXsmpServer: IceProcessMessages returned IceProcessMessagesIOError");
+                free_ice_connection_watch (data);
+                disconnect_ice_connection (ice_conn);
+                keep_going = FALSE;
+                break;
+        case IceProcessMessagesConnectionClosed:
+                g_debug ("GsmXsmpServer: IceProcessMessages returned IceProcessMessagesConnectionClosed");
+                free_ice_connection_watch (data);
+                keep_going = FALSE;
+                break;
+        default:
+                g_assert_not_reached ();
+        }
+
+        return keep_going;
+}
+
+/* IceAcceptConnection returns a new ICE connection that is in a "pending" state,
+ * this is because authentification may be necessary.
+ * So we've to authenticate it, before accept_xsmp_connection() is called.
+ * Then each GsmXSMPClient will have its own IceConn watcher
+ */
+static void
+auth_ice_connection (IceConn ice_conn)
+{
+        GIOChannel            *channel;
+        GsmIceConnectionWatch *data;
+        int                    fd;
+
+        g_debug ("GsmXsmpServer: auth_ice_connection()");
+
+        fd = IceConnectionNumber (ice_conn);
+        fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+        channel = g_io_channel_unix_new (fd);
+
+        data = g_new0 (GsmIceConnectionWatch, 1);
+        ice_conn->context = data;
+
+        data->protocol_timeout = g_timeout_add_seconds (5,
+                                                        (GSourceFunc)ice_protocol_timeout,
+                                                        ice_conn);
+        data->watch_id = g_io_add_watch (channel,
+                                         G_IO_IN | G_IO_ERR,
+                                         (GIOFunc)auth_iochannel_watch,
+                                         ice_conn);
+        g_io_channel_unref (channel);
+}
+
+/* This is called (by glib via xsmp->ice_connection_watch) when a
+ * connection is first received on the ICE listening socket.
+ */
+static gboolean
+accept_ice_connection (GIOChannel           *source,
+                       GIOCondition          condition,
+                       GsmIceConnectionData *data)
+{
+        IceConn         ice_conn;
+        IceAcceptStatus status;
+
+        g_debug ("GsmXsmpServer: accept_ice_connection()");
+
+        ice_conn = IceAcceptConnection (data->listener, &status);
+        if (status != IceAcceptSuccess) {
+                g_debug ("GsmXsmpServer: IceAcceptConnection returned %d", status);
+                return TRUE;
+        }
+
+        auth_ice_connection (ice_conn);
+
+        return TRUE;
+}
+
+void
+gsm_xsmp_server_start (GsmXsmpServer *server)
+{
+        GIOChannel *channel;
+        int         i;
+
+        for (i = 0; i < server->num_local_xsmp_sockets; i++) {
+                GsmIceConnectionData *data;
+
+                data = g_new0 (GsmIceConnectionData, 1);
+                data->server = server;
+                data->listener = server->xsmp_sockets[i];
+
+                channel = g_io_channel_unix_new (IceGetListenConnectionNumber (server->xsmp_sockets[i]));
+                g_io_add_watch_full (channel,
+                                     G_PRIORITY_DEFAULT,
+                                     G_IO_IN | G_IO_HUP | G_IO_ERR,
+                                     (GIOFunc)accept_ice_connection,
+                                     data,
+                                     (GDestroyNotify)g_free);
+                g_io_channel_unref (channel);
+        }
+}
+
+static void
+gsm_xsmp_server_set_client_store (GsmXsmpServer *xsmp_server,
+                                  GsmStore      *store)
+{
+        g_return_if_fail (GSM_IS_XSMP_SERVER (xsmp_server));
+
+        if (store != NULL) {
+                g_object_ref (store);
+        }
+
+        if (xsmp_server->client_store != NULL) {
+                g_object_unref (xsmp_server->client_store);
+        }
+
+        xsmp_server->client_store = store;
+}
+
+static void
+gsm_xsmp_server_set_property (GObject      *object,
+                              guint         prop_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+        GsmXsmpServer *self;
+
+        self = GSM_XSMP_SERVER (object);
+
+        switch (prop_id) {
+        case PROP_CLIENT_STORE:
+                gsm_xsmp_server_set_client_store (self, g_value_get_object (value));
+                break;
+         default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+static void
+gsm_xsmp_server_get_property (GObject    *object,
+                              guint       prop_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+        GsmXsmpServer *self;
+
+        self = GSM_XSMP_SERVER (object);
+
+        switch (prop_id) {
+        case PROP_CLIENT_STORE:
+                g_value_set_object (value, self->client_store);
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+                break;
+        }
+}
+
+/* This is called (by libSM) when XSMP is initiated on an ICE
+ * connection that was already accepted by accept_ice_connection.
+ */
+static Status
+accept_xsmp_connection (SmsConn        sms_conn,
+                        GsmXsmpServer *server,
+                        unsigned long *mask_ret,
+                        SmsCallbacks  *callbacks_ret,
+                        char         **failure_reason_ret)
+{
+        IceConn                ice_conn;
+        GsmClient             *client;
+        GsmIceConnectionWatch *data;
+
+        /* FIXME: what about during shutdown but before gsm_xsmp_shutdown? */
+        if (server->xsmp_sockets == NULL) {
+                g_debug ("GsmXsmpServer: In shutdown, rejecting new client");
+
+                *failure_reason_ret = strdup (_("Refusing new client connection because the session is currently being shut down\n"));
+                return FALSE;
+        }
+
+        ice_conn = SmsGetIceConnection (sms_conn);
+        data = ice_conn->context;
+
+        /* Each GsmXSMPClient has its own IceConn watcher */
+        free_ice_connection_watch (data);
+
+        client = gsm_xsmp_client_new (ice_conn);
+
+        gsm_store_add (server->client_store, gsm_client_peek_id (client), G_OBJECT (client));
+        /* the store will own the ref */
+        g_object_unref (client);
+
+        gsm_xsmp_client_connect (GSM_XSMP_CLIENT (client), sms_conn, mask_ret, callbacks_ret);
+
+        return TRUE;
+}
+
+static void
+ice_error_handler (IceConn       conn,
+                   Bool          swap,
+                   int           offending_minor_opcode,
+                   unsigned long offending_sequence,
+                   int           error_class,
+                   int           severity,
+                   IcePointer    values)
+{
+        g_debug ("GsmXsmpServer: ice_error_handler (%p, %s, %d, %lx, %d, %d)",
+                 conn, swap ? "TRUE" : "FALSE", offending_minor_opcode,
+                 offending_sequence, error_class, severity);
+
+        if (severity == IceCanContinue) {
+                return;
+        }
+
+        /* FIXME: the ICElib docs are completely vague about what we're
+         * supposed to do in this case. Need to verify that calling
+         * IceCloseConnection() here is guaranteed to cause neither
+         * free-memory-reads nor leaks.
+         */
+        IceCloseConnection (conn);
+}
+
+static void
+ice_io_error_handler (IceConn conn)
+{
+        g_debug ("GsmXsmpServer: ice_io_error_handler (%p)", conn);
+
+        /* We don't need to do anything here; the next call to
+         * IceProcessMessages() for this connection will receive
+         * IceProcessMessagesIOError and we can handle the error there.
+         */
+}
+
+static void
+sms_error_handler (SmsConn       conn,
+                   Bool          swap,
+                   int           offending_minor_opcode,
+                   unsigned long offending_sequence_num,
+                   int           error_class,
+                   int           severity,
+                   IcePointer    values)
+{
+        g_debug ("GsmXsmpServer: sms_error_handler (%p, %s, %d, %lx, %d, %d)",
+                 conn, swap ? "TRUE" : "FALSE", offending_minor_opcode,
+                 offending_sequence_num, error_class, severity);
+
+        /* We don't need to do anything here; if the connection needs to be
+         * closed, libSM will do that itself.
+         */
+}
+
+static IceAuthFileEntry *
+auth_entry_new (const char *protocol,
+                const char *network_id)
+{
+        IceAuthFileEntry *file_entry;
+        IceAuthDataEntry  data_entry;
+
+        file_entry = malloc (sizeof (IceAuthFileEntry));
+
+        file_entry->protocol_name = strdup (protocol);
+        file_entry->protocol_data = NULL;
+        file_entry->protocol_data_length = 0;
+        file_entry->network_id = strdup (network_id);
+        file_entry->auth_name = strdup (GSM_ICE_MAGIC_COOKIE_AUTH_NAME);
+        file_entry->auth_data = IceGenerateMagicCookie (GSM_ICE_MAGIC_COOKIE_LEN);
+        file_entry->auth_data_length = GSM_ICE_MAGIC_COOKIE_LEN;
+
+        /* Also create an in-memory copy, which is what the server will
+         * actually use for checking client auth.
+         */
+        data_entry.protocol_name = file_entry->protocol_name;
+        data_entry.network_id = file_entry->network_id;
+        data_entry.auth_name = file_entry->auth_name;
+        data_entry.auth_data = file_entry->auth_data;
+        data_entry.auth_data_length = file_entry->auth_data_length;
+        IceSetPaAuthData (1, &data_entry);
+
+        return file_entry;
+}
+
+static gboolean
+update_iceauthority (GsmXsmpServer *server,
+                     gboolean       adding)
+{
+        char             *filename;
+        char            **our_network_ids;
+        FILE             *fp;
+        IceAuthFileEntry *auth_entry;
+        GSList           *entries;
+        GSList           *e;
+        int               i;
+        gboolean          ok = FALSE;
+
+        filename = IceAuthFileName ();
+        if (IceLockAuthFile (filename,
+                             GSM_ICE_AUTH_RETRIES,
+                             GSM_ICE_AUTH_INTERVAL,
+                             GSM_ICE_AUTH_LOCK_TIMEOUT) != IceAuthLockSuccess) {
+                return FALSE;
+        }
+
+        our_network_ids = g_malloc (server->num_local_xsmp_sockets * sizeof (char *));
+        for (i = 0; i < server->num_local_xsmp_sockets; i++) {
+                our_network_ids[i] = IceGetListenConnectionString (server->xsmp_sockets[i]);
+        }
+
+        entries = NULL;
+
+        fp = fopen (filename, "r+");
+        if (fp != NULL) {
+                while ((auth_entry = IceReadAuthFileEntry (fp)) != NULL) {
+                        /* Skip/delete entries with no network ID (invalid), or with
+                         * our network ID; if we're starting up, an entry with our
+                         * ID must be a stale entry left behind by an old process,
+                         * and if we're shutting down, it won't be valid in the
+                         * future, so either way we want to remove it from the list.
+                         */
+                        if (!auth_entry->network_id) {
+                                IceFreeAuthFileEntry (auth_entry);
+                                continue;
+                        }
+
+                        for (i = 0; i < server->num_local_xsmp_sockets; i++) {
+                                if (!strcmp (auth_entry->network_id, our_network_ids[i])) {
+                                        IceFreeAuthFileEntry (auth_entry);
+                                        break;
+                                }
+                        }
+                        if (i != server->num_local_xsmp_sockets) {
+                                continue;
+                        }
+
+                        entries = g_slist_prepend (entries, auth_entry);
+                }
+
+                rewind (fp);
+        } else {
+                int fd;
+
+                if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+                        g_warning ("Unable to read ICE authority file: %s", filename);
+                        goto cleanup;
+                }
+
+                fd = open (filename, O_CREAT | O_WRONLY, 0600);
+                fp = fdopen (fd, "w");
+                if (!fp) {
+                        g_warning ("Unable to write to ICE authority file: %s", filename);
+                        if (fd != -1) {
+                                close (fd);
+                        }
+                        goto cleanup;
+                }
+        }
+
+        if (adding) {
+                for (i = 0; i < server->num_local_xsmp_sockets; i++) {
+                        entries = g_slist_append (entries,
+                                                  auth_entry_new ("ICE", our_network_ids[i]));
+                        entries = g_slist_prepend (entries,
+                                                   auth_entry_new ("XSMP", our_network_ids[i]));
+                }
+        }
+
+        for (e = entries; e; e = e->next) {
+                IceAuthFileEntry *auth_file_entry = e->data;
+                IceWriteAuthFileEntry (fp, auth_file_entry);
+                IceFreeAuthFileEntry (auth_file_entry);
+        }
+        g_slist_free (entries);
+
+        fclose (fp);
+        ok = TRUE;
+
+ cleanup:
+        IceUnlockAuthFile (filename);
+        for (i = 0; i < server->num_local_xsmp_sockets; i++) {
+                free (our_network_ids[i]);
+        }
+        g_free (our_network_ids);
+
+        return ok;
+}
+
+static void
+setup_listener (GsmXsmpServer *server)
+{
+        char   error[256];
+        mode_t saved_umask;
+        char  *network_id_list;
+        int    i;
+        int    res;
+
+        /* Set up sane error handlers */
+        IceSetErrorHandler (ice_error_handler);
+        IceSetIOErrorHandler (ice_io_error_handler);
+        SmsSetErrorHandler (sms_error_handler);
+
+        /* Initialize libSM; we pass NULL for hostBasedAuthProc to disable
+         * host-based authentication.
+         */
+        res = SmsInitialize (PACKAGE,
+                             VERSION,
+                             (SmsNewClientProc)accept_xsmp_connection,
+                             server,
+                             NULL,
+                             sizeof (error),
+                             error);
+        if (! res) {
+                gsm_util_init_error (TRUE, "Could not initialize libSM: %s", error);
+        }
+
+#if HAVE_XTRANS
+        /* By default, IceListenForConnections will open one socket for each
+         * transport type known to X. We don't want connections from remote
+         * hosts, so for security reasons it would be best if ICE didn't
+         * even open any non-local sockets. So we use an internal ICElib
+         * method to disable them here. Unfortunately, there is no way to
+         * ask X what transport types it knows about, so we're forced to
+         * guess.
+         */
+        _IceTransNoListen ("tcp");
+#endif
+
+        /* Create the XSMP socket. Older versions of IceListenForConnections
+         * have a bug which causes the umask to be set to 0 on certain types
+         * of failures. Probably not an issue on any modern systems, but
+         * we'll play it safe.
+         */
+        saved_umask = umask (0);
+        umask (saved_umask);
+        res = IceListenForConnections (&server->num_xsmp_sockets,
+                                       &server->xsmp_sockets,
+                                       sizeof (error),
+                                       error);
+        if (! res) {
+                gsm_util_init_error (TRUE, _("Could not create ICE listening socket: %s"), error);
+        }
+
+        umask (saved_umask);
+
+        /* Find the local sockets in the returned socket list and move them
+         * to the start of the list.
+         */
+        for (i = server->num_local_xsmp_sockets = 0; i < server->num_xsmp_sockets; i++) {
+                char *id = IceGetListenConnectionString (server->xsmp_sockets[i]);
+
+                if (!strncmp (id, "local/", sizeof ("local/") - 1) ||
+                    !strncmp (id, "unix/", sizeof ("unix/") - 1)) {
+                        if (i > server->num_local_xsmp_sockets) {
+                                IceListenObj tmp;
+                                tmp = server->xsmp_sockets[i];
+                                server->xsmp_sockets[i] = server->xsmp_sockets[server->num_local_xsmp_sockets];
+                                server->xsmp_sockets[server->num_local_xsmp_sockets] = tmp;
+                        }
+                        server->num_local_xsmp_sockets++;
+                }
+                free (id);
+        }
+
+        if (server->num_local_xsmp_sockets == 0) {
+                gsm_util_init_error (TRUE, "IceListenForConnections did not return a local listener!");
+        }
+
+#ifdef HAVE_XTRANS
+        if (server->num_local_xsmp_sockets != server->num_xsmp_sockets) {
+                /* Xtrans was apparently compiled with support for some
+                 * non-local transport besides TCP (which we disabled above); we
+                 * won't create IO watches on those extra sockets, so
+                 * connections to them will never be noticed, but they're still
+                 * there, which is inelegant.
+                 *
+                 * If the g_warning below is triggering for you and you want to
+                 * stop it, the fix is to add additional _IceTransNoListen()
+                 * calls above.
+                 */
+                network_id_list = IceComposeNetworkIdList (server->num_xsmp_sockets - server->num_local_xsmp_sockets,
+                                                           server->xsmp_sockets + server->num_local_xsmp_sockets);
+                g_warning ("IceListenForConnections returned %d non-local listeners: %s",
+                           server->num_xsmp_sockets - server->num_local_xsmp_sockets,
+                           network_id_list);
+                free (network_id_list);
+        }
+#endif
+
+        /* Update .ICEauthority with new auth entries for our socket */
+        if (!update_iceauthority (server, TRUE)) {
+                /* FIXME: is this really fatal? Hm... */
+                gsm_util_init_error (TRUE,
+                                     "Could not update ICEauthority file %s",
+                                     IceAuthFileName ());
+        }
+
+        network_id_list = IceComposeNetworkIdList (server->num_local_xsmp_sockets,
+                                                   server->xsmp_sockets);
+
+        gsm_util_setenv ("SESSION_MANAGER", network_id_list);
+        g_debug ("GsmXsmpServer: SESSION_MANAGER=%s\n", network_id_list);
+        free (network_id_list);
+}
+
+static GObject *
+gsm_xsmp_server_constructor (GType                  type,
+                             guint                  n_construct_properties,
+                             GObjectConstructParam *construct_properties)
+{
+        GsmXsmpServer *xsmp_server;
+
+        xsmp_server = GSM_XSMP_SERVER (G_OBJECT_CLASS (gsm_xsmp_server_parent_class)->constructor (type,
+                                                                                       n_construct_properties,
+                                                                                       construct_properties));
+        setup_listener (xsmp_server);
+
+        return G_OBJECT (xsmp_server);
+}
+
+static void
+gsm_xsmp_server_class_init (GsmXsmpServerClass *klass)
+{
+        GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+
+        object_class->get_property = gsm_xsmp_server_get_property;
+        object_class->set_property = gsm_xsmp_server_set_property;
+        object_class->constructor = gsm_xsmp_server_constructor;
+        object_class->finalize = gsm_xsmp_server_finalize;
+
+        g_object_class_install_property (object_class,
+                                         PROP_CLIENT_STORE,
+                                         g_param_spec_object ("client-store",
+                                                              NULL,
+                                                              NULL,
+                                                              GSM_TYPE_STORE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+static void
+gsm_xsmp_server_init (GsmXsmpServer *xsmp_server)
+{
+}
+
+static void
+gsm_xsmp_server_finalize (GObject *object)
+{
+        GsmXsmpServer *xsmp_server;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSM_IS_XSMP_SERVER (object));
+
+        xsmp_server = GSM_XSMP_SERVER (object);
+
+        IceFreeListenObjs (xsmp_server->num_xsmp_sockets,
+                           xsmp_server->xsmp_sockets);
+
+        if (xsmp_server->client_store != NULL) {
+                g_object_unref (xsmp_server->client_store);
+        }
+
+        G_OBJECT_CLASS (gsm_xsmp_server_parent_class)->finalize (object);
+}
+
+GsmXsmpServer *
+gsm_xsmp_server_new (GsmStore *client_store)
+{
+        if (xsmp_server_object != NULL) {
+                g_object_ref (xsmp_server_object);
+        } else {
+                xsmp_server_object = g_object_new (GSM_TYPE_XSMP_SERVER,
+                                                   "client-store", client_store,
+                                                   NULL);
+
+                g_object_add_weak_pointer (xsmp_server_object,
+                                           (gpointer *) &xsmp_server_object);
+        }
+
+        return GSM_XSMP_SERVER (xsmp_server_object);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/53.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/53.html new file mode 100644 index 0000000..9391044 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/53.html @@ -0,0 +1,315 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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_XSMP_SERVER_H
+#define __GSM_XSMP_SERVER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-store.h"
+
+G_BEGIN_DECLS
+
+#define GSM_TYPE_XSMP_SERVER         (gsm_xsmp_server_get_type ())
+G_DECLARE_FINAL_TYPE (GsmXsmpServer, gsm_xsmp_server, GSM, XSMP_SERVER, GObject)
+
+GsmXsmpServer *     gsm_xsmp_server_new                            (GsmStore      *client_store);
+void                gsm_xsmp_server_start                          (GsmXsmpServer *server);
+
+G_END_DECLS
+
+#endif /* __GSM_XSMP_SERVER_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/54.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/54.html new file mode 100644 index 0000000..a78696e --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/54.html @@ -0,0 +1,1831 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Novell, Inc.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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.
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <dbus/dbus.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-bindings.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib-lowlevel.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mdm-signal-handler.h"
+#include "mdm-log.h"
+
+#include "gsm-consolekit.h"
+#ifdef HAVE_SYSTEMD
+#include "gsm-systemd.h"
+#endif
+#include "gsm-util.h"
+#include "gsm-manager.h"
+#include "gsm-xsmp-server.h"
+#include "gsm-store.h"
+
+#include "msm-gnome.h"
+
+#define GSM_SCHEMA "org.mate.session"
+#define GSM_DEFAULT_SESSION_KEY "default-session"
+#define GSM_REQUIRED_COMPONENTS_SCHEMA GSM_SCHEMA ".required-components"
+#define GSM_REQUIRED_COMPONENTS_LIST_KEY "required-components-list"
+
+#define ACCESSIBILITY_KEY     "accessibility"
+#define ACCESSIBILITY_SCHEMA  "org.mate.interface"
+
+#define DEBUG_SCHEMA          "org.mate.debug"
+#define DEBUG_KEY             "mate-session"
+
+#define VISUAL_SCHEMA         "org.mate.applications-at-visual"
+#define VISUAL_KEY            "exec"
+#define VISUAL_STARTUP_KEY    "startup"
+
+#define MOBILITY_SCHEMA       "org.mate.applications-at-mobility"
+#define MOBILITY_KEY          "exec"
+#define MOBILITY_STARTUP_KEY  "startup"
+
+#define MATE_INTERFACE_SCHEMA "org.mate.interface"
+#define GTK_OVERLAY_SCROLL    "gtk-overlay-scrolling"
+
+#define GSM_DBUS_NAME "org.gnome.SessionManager"
+
+#define KEY_AUTOSAVE "auto-save-session"
+
+static gboolean failsafe = FALSE;
+static gboolean show_version = FALSE;
+static gboolean debug = FALSE;
+static gboolean disable_acceleration_check = FALSE;
+
+static gboolean
+initialize_gsettings (void)
+{
+	GSettings* settings;
+	time_t now = time (0);
+	gboolean ret;
+
+	settings = g_settings_new (GSM_SCHEMA);
+
+	if (!settings)
+		return FALSE;
+
+	ret = g_settings_set_int (settings, "session-start", now);
+
+	g_settings_sync ();
+
+	g_object_unref (settings);
+
+        return ret;
+}
+
+static void on_bus_name_lost(DBusGProxy* bus_proxy, const char* name, gpointer data)
+{
+	g_warning("Lost name on bus: %s, exiting", name);
+	exit(1);
+}
+
+static gboolean acquire_name_on_proxy(DBusGProxy* bus_proxy, const char* name)
+{
+	GError* error;
+	guint result;
+	gboolean res;
+	gboolean ret;
+
+	ret = FALSE;
+
+	if (bus_proxy == NULL)
+	{
+		goto out;
+	}
+
+	error = NULL;
+	res = dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING, name, G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &result, G_TYPE_INVALID);
+
+	if (! res)
+	{
+		if (error != NULL)
+		{
+			g_warning("Failed to acquire %s: %s", name, error->message);
+			g_error_free(error);
+		}
+		else
+		{
+			g_warning ("Failed to acquire %s", name);
+		}
+
+		goto out;
+	}
+
+	if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+	{
+		if (error != NULL)
+		{
+			g_warning("Failed to acquire %s: %s", name, error->message);
+			g_error_free(error);
+		}
+		else
+		{
+			g_warning("Failed to acquire %s", name);
+		}
+
+		goto out;
+	}
+
+	/* register for name lost */
+	dbus_g_proxy_add_signal(bus_proxy, "NameLost", G_TYPE_STRING, G_TYPE_INVALID);
+	dbus_g_proxy_connect_signal(bus_proxy, "NameLost", G_CALLBACK(on_bus_name_lost), NULL, NULL);
+
+	ret = TRUE;
+
+	out:
+
+	return ret;
+}
+
+static gboolean acquire_name(void)
+{
+	DBusGProxy* bus_proxy;
+	GError* error;
+	DBusGConnection* connection;
+
+	error = NULL;
+	connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+	if (connection == NULL)
+	{
+		gsm_util_init_error(TRUE, "Could not connect to session bus: %s", error->message);
+		/* not reached */
+	}
+
+	bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
+
+	if (!acquire_name_on_proxy(bus_proxy, GSM_DBUS_NAME))
+	{
+		gsm_util_init_error(TRUE, "%s", "Could not acquire name on session bus");
+		/* not reached */
+	}
+
+	g_object_unref(bus_proxy);
+
+	return TRUE;
+}
+
+/* This doesn't contain the required components, so we need to always
+ * call append_required_apps() after a call to append_default_apps(). */
+static void append_default_apps(GsmManager* manager, const char* default_session_key, char** autostart_dirs)
+{
+	gint i;
+	gchar** default_apps;
+	GSettings* settings;
+
+	g_debug("main: *** Adding default apps");
+
+	g_assert(default_session_key != NULL);
+	g_assert(autostart_dirs != NULL);
+
+	settings = g_settings_new (GSM_SCHEMA);
+	default_apps = g_settings_get_strv (settings, default_session_key);
+	g_object_unref(settings);
+
+	for (i = 0; default_apps[i]; i++)
+	{
+		char* app_path;
+
+		if (IS_STRING_EMPTY((char*) default_apps[i]))
+		{
+			continue;
+		}
+
+		app_path = gsm_util_find_desktop_file_for_app_name(default_apps[i], autostart_dirs);
+
+		if (app_path != NULL)
+		{
+			gsm_manager_add_autostart_app(manager, app_path, NULL);
+			g_free(app_path);
+		}
+	}
+
+	g_strfreev (default_apps);
+}
+
+static void append_required_apps(GsmManager* manager)
+{
+	gchar** required_components;
+	gint i;
+	GSettings* settings;
+	GSettings* settings_required_components;
+
+	g_debug("main: *** Adding required apps");
+
+	settings = g_settings_new (GSM_SCHEMA);
+	settings_required_components = g_settings_new (GSM_REQUIRED_COMPONENTS_SCHEMA);
+
+	required_components = g_settings_get_strv(settings, GSM_REQUIRED_COMPONENTS_LIST_KEY);
+
+	if (required_components == NULL)
+	{
+		g_warning("No required applications specified");
+	}
+	else
+	{
+		for (i = 0; required_components[i]; i++)
+		{
+			char* default_provider;
+			const char* component;
+
+			if (IS_STRING_EMPTY((char*) required_components[i]))
+			{
+				continue;
+			}
+
+			component = required_components[i];
+
+			default_provider = g_settings_get_string (settings_required_components, component);
+
+			g_debug ("main: %s looking for component: '%s'", component, default_provider);
+
+			if (default_provider != NULL)
+			{
+				char* app_path;
+
+				app_path = gsm_util_find_desktop_file_for_app_name(default_provider, NULL);
+
+				if (app_path != NULL)
+				{
+					gsm_manager_add_autostart_app(manager, app_path, component);
+				}
+				else
+				{
+					g_warning("Unable to find provider '%s' of required component '%s'", default_provider, component);
+				}
+
+				g_free(app_path);
+			}
+
+			g_free(default_provider);
+		}
+	}
+
+	g_debug("main: *** Done adding required apps");
+
+	g_strfreev(required_components);
+
+	g_object_unref(settings);
+	g_object_unref(settings_required_components);
+}
+
+static void append_accessibility_apps(GsmManager* manager)
+{
+	GSettings* mobility_settings;
+	GSettings* visual_settings;
+
+	g_debug("main: *** Adding accesibility apps");
+
+	mobility_settings = g_settings_new (MOBILITY_SCHEMA);
+	visual_settings = g_settings_new (VISUAL_SCHEMA);
+
+	if (g_settings_get_boolean (mobility_settings, MOBILITY_STARTUP_KEY))
+	{
+		gchar *mobility_exec;
+		mobility_exec = g_settings_get_string (mobility_settings, MOBILITY_KEY);
+		if (mobility_exec != NULL && mobility_exec[0] != 0)
+		{
+			char* app_path;
+			app_path = gsm_util_find_desktop_file_for_app_name(mobility_exec, NULL);
+			if (app_path != NULL)
+			{
+				gsm_manager_add_autostart_app(manager, app_path, NULL);
+				g_free (app_path);
+			}
+			g_free (mobility_exec);
+		}
+	}
+
+	if (g_settings_get_boolean (visual_settings, VISUAL_STARTUP_KEY))
+	{
+		gchar *visual_exec;
+		visual_exec = g_settings_get_string (visual_settings, VISUAL_KEY);
+		if (visual_exec != NULL && visual_exec[0] != 0)
+		{
+			char* app_path;
+			app_path = gsm_util_find_desktop_file_for_app_name(visual_exec, NULL);
+			if (app_path != NULL)
+			{
+				gsm_manager_add_autostart_app(manager, app_path, NULL);
+				g_free (app_path);
+			}
+			g_free (visual_exec);
+		}
+	}
+
+	g_object_unref (mobility_settings);
+	g_object_unref (visual_settings);
+}
+
+static void maybe_load_saved_session_apps(GsmManager* manager)
+{
+	GsmConsolekit* consolekit = NULL;
+#ifdef HAVE_SYSTEMD
+	GsmSystemd* systemd = NULL;
+#endif
+	char* session_type;
+	gboolean is_login;
+
+#ifdef HAVE_SYSTEMD
+	if (LOGIND_RUNNING()) {
+		systemd = gsm_get_systemd();
+		session_type = gsm_systemd_get_current_session_type(systemd);
+		is_login = g_strcmp0 (session_type, GSM_SYSTEMD_SESSION_TYPE_LOGIN_WINDOW) == 0;
+	}
+	else {
+#endif
+	consolekit = gsm_get_consolekit();
+	session_type = gsm_consolekit_get_current_session_type(consolekit);
+	is_login = g_strcmp0 (session_type, GSM_CONSOLEKIT_SESSION_TYPE_LOGIN_WINDOW) == 0;
+#ifdef HAVE_SYSTEMD
+	}
+#endif
+
+	if (!is_login)
+	{
+		GSettings* settings;
+		gboolean autostart;
+
+		settings = g_settings_new (GSM_SCHEMA);
+		autostart = g_settings_get_boolean (settings, KEY_AUTOSAVE);
+		g_object_unref (settings);
+
+		if (autostart == TRUE)
+			gsm_manager_add_autostart_apps_from_dir(manager, gsm_util_get_saved_session_dir());
+	}
+
+	if (consolekit != NULL)
+		g_object_unref(consolekit);
+#ifdef HAVE_SYSTEMD
+	if (systemd != NULL)
+		g_object_unref(systemd);
+#endif
+	g_free(session_type);
+}
+
+static void load_standard_apps (GsmManager* manager, const char* default_session_key)
+{
+	char** autostart_dirs;
+	int i;
+
+	autostart_dirs = gsm_util_get_autostart_dirs();
+
+	if (!failsafe)
+	{
+		maybe_load_saved_session_apps(manager);
+
+		for (i = 0; autostart_dirs[i]; i++)
+		{
+			gsm_manager_add_autostart_apps_from_dir(manager, autostart_dirs[i]);
+		}
+	}
+
+	/* We do this at the end in case a saved session contains an
+	 * application that already provides one of the components. */
+	append_default_apps(manager, default_session_key, autostart_dirs);
+	append_required_apps(manager);
+	append_accessibility_apps(manager);
+
+	g_strfreev(autostart_dirs);
+}
+
+static void load_override_apps(GsmManager* manager, char** override_autostart_dirs)
+{
+	int i;
+
+	for (i = 0; override_autostart_dirs[i]; i++)
+	{
+		gsm_manager_add_autostart_apps_from_dir(manager, override_autostart_dirs[i]);
+	}
+}
+
+static gboolean signal_cb(int signo, gpointer data)
+{
+	int ret;
+	GsmManager* manager;
+
+	g_debug("Got callback for signal %d", signo);
+
+	ret = TRUE;
+
+	switch (signo)
+	{
+		case SIGFPE:
+		case SIGPIPE:
+			/* let the fatal signals interrupt us */
+			g_debug ("Caught signal %d, shutting down abnormally.", signo);
+			ret = FALSE;
+			break;
+		case SIGINT:
+		case SIGTERM:
+			manager = (GsmManager*) data;
+			gsm_manager_logout(manager, GSM_MANAGER_LOGOUT_MODE_FORCE, NULL);
+
+			/* let the fatal signals interrupt us */
+			g_debug("Caught signal %d, shutting down normally.", signo);
+			ret = TRUE;
+			break;
+		case SIGHUP:
+			g_debug("Got HUP signal");
+			ret = TRUE;
+			break;
+		case SIGUSR1:
+			g_debug("Got USR1 signal");
+			ret = TRUE;
+			mdm_log_toggle_debug();
+			break;
+		default:
+			g_debug("Caught unhandled signal %d", signo);
+			ret = TRUE;
+
+			break;
+	}
+
+	return ret;
+}
+
+static void shutdown_cb(gpointer data)
+{
+	GsmManager* manager = (GsmManager*) data;
+	g_debug("Calling shutdown callback function");
+
+	/*
+	 * When the signal handler gets a shutdown signal, it calls
+	 * this function to inform GsmManager to not restart
+	 * applications in the off chance a handler is already queued
+	 * to dispatch following the below call to gtk_main_quit.
+	 */
+	gsm_manager_set_phase(manager, GSM_MANAGER_PHASE_EXIT);
+
+	gtk_main_quit();
+}
+
+static gboolean require_dbus_session(int argc, char** argv, GError** error)
+{
+	char** new_argv;
+	int i;
+
+	if (g_getenv("DBUS_SESSION_BUS_ADDRESS"))
+	{
+		return TRUE;
+	}
+
+	/* Just a sanity check to prevent infinite recursion if
+	 * dbus-launch fails to set DBUS_SESSION_BUS_ADDRESS
+	 */
+	g_return_val_if_fail(!g_str_has_prefix(argv[0], "dbus-launch"), TRUE);
+
+	/* +2 for our new arguments, +1 for NULL */
+	new_argv = g_malloc(argc + 3 * sizeof (*argv));
+
+	new_argv[0] = "dbus-launch";
+	new_argv[1] = "--exit-with-session";
+
+	for (i = 0; i < argc; i++)
+	{
+		new_argv[i + 2] = argv[i];
+	}
+
+	new_argv[i + 2] = NULL;
+
+	if (!execvp("dbus-launch", new_argv))
+	{
+		g_set_error(error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, "No session bus and could not exec dbus-launch: %s", g_strerror(errno));
+		g_free (new_argv);
+		return FALSE;
+	}
+
+	g_free (new_argv);
+
+	/* Should not be reached */
+	return TRUE;
+}
+
+static void
+debug_changed (GSettings *settings, gchar *key, gpointer user_data)
+{
+	debug = g_settings_get_boolean (settings, DEBUG_KEY);
+	mdm_log_set_debug (debug);
+}
+
+static gboolean
+schema_exists (const gchar* schema_name)
+{
+    GSettingsSchemaSource *source;
+    GSettingsSchema *schema;
+    gboolean exists;
+
+    source = g_settings_schema_source_get_default();
+    schema = g_settings_schema_source_lookup (source, schema_name, FALSE);
+    exists = (schema != NULL);
+    if (schema)
+        g_settings_schema_unref (schema);
+
+    return exists;
+}
+
+static void set_overlay_scroll (void)
+{
+	GSettings *settings;
+	gboolean   enabled;
+
+	settings = g_settings_new (MATE_INTERFACE_SCHEMA);
+	enabled = g_settings_get_boolean (settings, GTK_OVERLAY_SCROLL);
+
+	if (enabled) {
+		gsm_util_setenv ("GTK_OVERLAY_SCROLLING", "1");
+	} else {
+		gsm_util_setenv ("GTK_OVERLAY_SCROLLING", "0");
+	}
+
+	g_object_unref (settings);
+}
+
+static gboolean
+check_gl (gchar **gl_renderer, GError **error)
+{
+	int status;
+	char *argv[] = { LIBEXECDIR "/mate-session-check-accelerated", NULL };
+
+	if (getenv ("DISPLAY") == NULL) {
+		/* Not connected to X11, someone else will take care of checking GL */
+		return TRUE;
+	}
+
+	if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, gl_renderer, NULL,
+		           &status, error)) {
+		return FALSE;
+	}
+
+	return g_spawn_check_exit_status (status, error);
+}
+
+int main(int argc, char** argv)
+{
+	struct sigaction sa;
+	GError* error;
+	const char* display_str;
+	GsmManager* manager;
+	GsmStore* client_store;
+	GsmXsmpServer* xsmp_server;
+	GSettings* debug_settings = NULL;
+	GSettings* accessibility_settings;
+	MdmSignalHandler* signal_handler;
+	static char** override_autostart_dirs = NULL;
+	char* gl_renderer = NULL;
+	gboolean gl_failed = FALSE;
+
+	static GOptionEntry entries[] = {
+		{"autostart", 'a', 0, G_OPTION_ARG_STRING_ARRAY, &override_autostart_dirs, N_("Override standard autostart directories"), NULL},
+		{"debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Enable debugging code"), NULL},
+		{"failsafe", 'f', 0, G_OPTION_ARG_NONE, &failsafe, N_("Do not load user-specified applications"), NULL},
+		{"version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL},
+		{ "disable-acceleration-check", 0, 0, G_OPTION_ARG_NONE, &disable_acceleration_check, N_("Disable hardware acceleration check"), NULL },
+		{NULL, 0, 0, 0, NULL, NULL, NULL }
+	};
+
+	/* Make sure that we have a session bus */
+	if (!require_dbus_session(argc, argv, &error))
+	{
+		gsm_util_init_error(TRUE, "%s", error->message);
+	}
+
+#ifdef ENABLE_NLS
+	bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
+	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+	textdomain(GETTEXT_PACKAGE);
+#endif /* ENABLE_NLS */
+
+	sa.sa_handler = SIG_IGN;
+	sa.sa_flags = 0;
+	sigemptyset(&sa.sa_mask);
+	sigaction(SIGPIPE, &sa, 0);
+
+	error = NULL;
+	gtk_init_with_args(&argc, &argv, (char*) _(" - the MATE session manager"), entries, GETTEXT_PACKAGE, &error);
+
+	if (error != NULL)
+	{
+		g_warning("%s", error->message);
+		exit(1);
+	}
+
+	if (show_version)
+	{
+		g_print("%s %s\n", g_get_application_name(), VERSION);
+		exit(1);
+	}
+
+        gsm_util_export_activation_environment (NULL);
+
+#ifdef HAVE_SYSTEMD
+        gsm_util_export_user_environment (NULL);
+#endif
+
+	mdm_log_init();
+
+	/* Allows to enable/disable debug from GSettings only if it is not set from argument */
+	if (!debug && schema_exists(DEBUG_SCHEMA))
+	{
+		debug_settings = g_settings_new (DEBUG_SCHEMA);
+		g_signal_connect (debug_settings, "changed::" DEBUG_KEY, G_CALLBACK (debug_changed), NULL);
+		debug = g_settings_get_boolean (debug_settings, DEBUG_KEY);
+	}
+
+	mdm_log_set_debug(debug);
+
+	if (disable_acceleration_check) {
+		g_debug ("hardware acceleration check is disabled");
+	} else {
+		/* Check GL, if it doesn't work out then force software fallback */
+		if (!check_gl (&gl_renderer, &error)) {
+			gl_failed = TRUE;
+
+			g_debug ("hardware acceleration check failed: %s",
+			         error? error->message : "");
+			g_clear_error (&error);
+			if (g_getenv ("LIBGL_ALWAYS_SOFTWARE") == NULL) {
+				g_setenv ("LIBGL_ALWAYS_SOFTWARE", "1", TRUE);
+				if (!check_gl (&gl_renderer, &error)) {
+					g_warning ("software acceleration check failed: %s",
+					           error? error->message : "");
+					g_clear_error (&error);
+				} else {
+					gl_failed = FALSE;
+				}
+			}
+		}
+	}
+
+	if (gl_failed) {
+		g_warning ("gl_failed!");
+	}
+
+	if (g_getenv ("XDG_CURRENT_DESKTOP") == NULL)
+		gsm_util_setenv ("XDG_CURRENT_DESKTOP", "MATE");
+
+	/* Set DISPLAY explicitly for all our children, in case --display
+	 * was specified on the command line.
+	 */
+	display_str = gdk_display_get_name (gdk_display_get_default());
+	gsm_util_setenv("DISPLAY", display_str);
+
+	/* Some third-party programs rely on MATE_DESKTOP_SESSION_ID to
+	 * detect if MATE is running. We keep this for compatibility reasons.
+	 */
+	gsm_util_setenv("MATE_DESKTOP_SESSION_ID", "this-is-deprecated");
+
+	/*
+	 * Make sure gsettings is set up correctly.  If not, then bail.
+	 */
+
+	if (initialize_gsettings () != TRUE)
+		exit (1);
+
+	/* Look if accessibility is enabled */
+	accessibility_settings = g_settings_new (ACCESSIBILITY_SCHEMA);
+	if (g_settings_get_boolean (accessibility_settings, ACCESSIBILITY_KEY))
+	{
+		gsm_util_setenv("GTK_MODULES", "gail:atk-bridge");
+	}
+	g_object_unref (accessibility_settings);
+
+	client_store = gsm_store_new();
+
+	xsmp_server = gsm_xsmp_server_new(client_store);
+
+	/* Now make sure they succeeded. (They'll call
+	 * gsm_util_init_error() if they failed.)
+	 */
+	acquire_name();
+
+	/* Starts gnome compat mode */
+	msm_gnome_start();
+
+	/* Set to use Gtk3 overlay scroll */
+	set_overlay_scroll ();
+
+	manager = gsm_manager_new(client_store, failsafe);
+
+	signal_handler = mdm_signal_handler_new();
+	mdm_signal_handler_add_fatal(signal_handler);
+	mdm_signal_handler_add(signal_handler, SIGFPE, signal_cb, NULL);
+	mdm_signal_handler_add(signal_handler, SIGHUP, signal_cb, NULL);
+	mdm_signal_handler_add(signal_handler, SIGUSR1, signal_cb, NULL);
+	mdm_signal_handler_add(signal_handler, SIGTERM, signal_cb, manager);
+	mdm_signal_handler_add(signal_handler, SIGINT, signal_cb, manager);
+	mdm_signal_handler_set_fatal_func(signal_handler, shutdown_cb, manager);
+
+	if (override_autostart_dirs != NULL)
+	{
+		load_override_apps(manager, override_autostart_dirs);
+	}
+	else
+	{
+		load_standard_apps(manager, GSM_DEFAULT_SESSION_KEY);
+	}
+
+	gsm_xsmp_server_start(xsmp_server);
+	_gsm_manager_set_renderer (manager, gl_renderer);
+	gsm_manager_start(manager);
+
+	gtk_main();
+
+	if (xsmp_server != NULL)
+	{
+		g_object_unref(xsmp_server);
+	}
+
+	if (manager != NULL)
+	{
+		g_debug("Unreffing manager");
+		g_object_unref(manager);
+	}
+
+        if (gl_renderer != NULL)
+        {
+                g_free (gl_renderer);
+        }
+
+	if (client_store != NULL)
+	{
+		g_object_unref(client_store);
+	}
+
+	if (debug_settings != NULL)
+	{
+		g_object_unref(debug_settings);
+	}
+
+	msm_gnome_stop();
+	mdm_log_shutdown();
+
+	return 0;
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/55.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/55.html new file mode 100644 index 0000000..d8e84f4 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/55.html @@ -0,0 +1,333 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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 __MDM_SIGNAL_HANDLER_H
+#define __MDM_SIGNAL_HANDLER_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS<--- syntax error
+
+#define MDM_TYPE_SIGNAL_HANDLER (mdm_signal_handler_get_type())
+G_DECLARE_FINAL_TYPE (MdmSignalHandler, mdm_signal_handler, MDM, SIGNAL_HANDLER, GObject)
+
+typedef gboolean (*MdmSignalHandlerFunc)(int signal, gpointer data);
+
+typedef void (*MdmShutdownHandlerFunc)(gpointer data);
+
+typedef struct MdmSignalHandlerPrivate MdmSignalHandlerPrivate;
+
+MdmSignalHandler* mdm_signal_handler_new(void);
+void mdm_signal_handler_set_fatal_func(MdmSignalHandler* handler, MdmShutdownHandlerFunc func, gpointer user_data);
+
+void mdm_signal_handler_add_fatal(MdmSignalHandler* handler);
+guint mdm_signal_handler_add(MdmSignalHandler* handler, int signal_number, MdmSignalHandlerFunc callback, gpointer data);
+void mdm_signal_handler_remove(MdmSignalHandler* handler, guint id);
+void mdm_signal_handler_remove_func(MdmSignalHandler* handler, guint signal_number, MdmSignalHandlerFunc callback, gpointer data);
+
+G_END_DECLS
+
+#endif /* __MDM_SIGNAL_HANDLER_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/56.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/56.html new file mode 100644 index 0000000..e72ef4b --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/56.html @@ -0,0 +1,349 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ * Authors: William Jon McCann <mccann@jhu.edu>
+ *
+ */
+
+#ifndef __MDM_LOG_H
+#define __MDM_LOG_H
+
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void      mdm_log_default_handler (const gchar   *log_domain,
+                                   GLogLevelFlags log_level,
+                                   const gchar   *message,
+                                   gpointer      unused_data);
+void      mdm_log_set_debug       (gboolean       debug);
+void      mdm_log_toggle_debug    (void);
+void      mdm_log_init            (void);
+void      mdm_log_shutdown        (void);
+
+/* compatibility */
+#define   mdm_fail               g_critical
+#define   mdm_error              g_warning
+#define   mdm_info               g_message
+#define   mdm_debug              g_debug
+
+#define   mdm_assert             g_assert
+#define   mdm_assert_not_reached g_assert_not_reached
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MDM_LOG_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/57.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/57.html new file mode 100644 index 0000000..f9d41df --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/57.html @@ -0,0 +1,651 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ * Authors: William Jon McCann <mccann@jhu.edu>
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdarg.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <syslog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mdm-log.h"
+
+static gboolean initialized = FALSE;
+static int      syslog_levels = (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
+static void
+log_level_to_priority_and_prefix (GLogLevelFlags log_level,
+                                  int           *priorityp,
+                                  const char   **prefixp)
+{
+        int         priority;
+        const char *prefix;
+
+        /* Process the message prefix and priority */
+        switch (log_level & G_LOG_LEVEL_MASK) {
+        case G_LOG_FLAG_FATAL:
+                priority = LOG_EMERG;
+                prefix = "FATAL";
+                break;
+        case G_LOG_LEVEL_ERROR:
+                priority = LOG_ERR;
+                prefix = "ERROR";
+                break;
+        case G_LOG_LEVEL_CRITICAL:
+                priority = LOG_CRIT;
+                prefix = "CRITICAL";
+                break;
+        case G_LOG_LEVEL_WARNING:
+                priority = LOG_WARNING;
+                prefix = "WARNING";
+                break;
+        case G_LOG_LEVEL_MESSAGE:
+                priority = LOG_NOTICE;
+                prefix = "MESSAGE";
+                break;
+        case G_LOG_LEVEL_INFO:
+                priority = LOG_INFO;
+                prefix = "INFO";
+                break;
+        case G_LOG_LEVEL_DEBUG:
+                /* if debug was requested then bump this up to ERROR
+                 * to ensure it is seen in a log */
+                if (syslog_levels & G_LOG_LEVEL_DEBUG) {
+                        priority = LOG_WARNING;
+                        prefix = "DEBUG(+)";
+                } else {
+                        priority = LOG_DEBUG;
+                        prefix = "DEBUG";
+                }
+                break;
+        default:
+                priority = LOG_DEBUG;
+                prefix = "UNKNOWN";
+                break;
+        }
+
+        if (priorityp != NULL) {
+                *priorityp = priority;
+        }
+        if (prefixp != NULL) {
+                *prefixp = prefix;
+        }
+}
+
+void
+mdm_log_default_handler (const gchar   *log_domain,
+                         GLogLevelFlags log_level,
+                         const gchar   *message,
+                         gpointer       unused_data)
+{
+        GString     *gstring;
+        int          priority;
+        const char  *level_prefix;
+        char        *string;
+        gboolean     do_log;
+        gboolean     is_fatal;
+
+        is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
+
+        do_log = (log_level & syslog_levels);
+        if (! do_log) {
+                return;
+        }
+
+        if (! initialized) {
+                mdm_log_init ();
+        }
+
+        log_level_to_priority_and_prefix (log_level,
+                                          &priority,
+                                          &level_prefix);
+
+        gstring = g_string_new (NULL);
+
+        if (log_domain != NULL) {
+                g_string_append (gstring, log_domain);
+                g_string_append_c (gstring, '-');
+        }
+        g_string_append (gstring, level_prefix);
+
+        g_string_append (gstring, ": ");
+        if (message == NULL) {
+                g_string_append (gstring, "(NULL) message");
+        } else {
+                g_string_append (gstring, message);
+        }
+        if (is_fatal) {
+                g_string_append (gstring, "\naborting...\n");
+        } else {
+                g_string_append (gstring, "\n");
+        }
+
+        string = g_string_free (gstring, FALSE);
+
+        syslog (priority, "%s", string);
+
+        g_free (string);
+}
+
+void
+mdm_log_toggle_debug (void)
+{
+        if (syslog_levels & G_LOG_LEVEL_DEBUG) {
+                g_debug ("Debugging disabled");
+                syslog_levels &= ~G_LOG_LEVEL_DEBUG;
+        } else {
+                syslog_levels |= G_LOG_LEVEL_DEBUG;
+                g_debug ("Debugging enabled");
+        }
+}
+
+void
+mdm_log_set_debug (gboolean debug)
+{
+        if (debug) {
+                syslog_levels |= G_LOG_LEVEL_DEBUG;
+                g_debug ("Enabling debugging");
+        } else {
+                g_debug ("Disabling debugging");
+                syslog_levels &= ~G_LOG_LEVEL_DEBUG;
+        }
+}
+
+void
+mdm_log_init (void)
+{
+        const char *prg_name;
+        int         options;
+
+        g_log_set_default_handler (mdm_log_default_handler, NULL);
+
+        prg_name = g_get_prgname ();
+
+        options = LOG_PID;
+#ifdef LOG_PERROR
+        options |= LOG_PERROR;
+#endif
+
+        openlog (prg_name, options, LOG_DAEMON);
+
+        initialized = TRUE;
+}
+
+void
+mdm_log_shutdown (void)
+{
+        closelog ();
+        initialized = FALSE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/58.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/58.html new file mode 100644 index 0000000..98694a9 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/58.html @@ -0,0 +1,1335 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006 Red Hat, Inc.
+ * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#if HAVE_EXECINFO_H
+	#include <execinfo.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+#include <syslog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mdm-signal-handler.h"
+
+#ifdef __GNUC__
+#define UNUSED_VARIABLE __attribute__ ((unused))
+#else
+#define UNUSED_VARIABLE
+#endif
+
+typedef struct {
+	int signal_number;
+	MdmSignalHandlerFunc func;
+	gpointer data;
+	guint id;
+} CallbackData;
+
+struct _MdmSignalHandler {
+	GObject    parent_instance;
+	GHashTable* lookup;
+	GHashTable* id_lookup;
+	GHashTable* action_lookup;
+	guint next_id;
+	GDestroyNotify fatal_func;
+	gpointer fatal_data;
+};
+
+static void mdm_signal_handler_finalize (GObject* object);
+
+static gpointer signal_handler_object = NULL;
+static int signal_pipes[2];
+static int signals_blocked = 0;
+static sigset_t signals_block_mask;
+static sigset_t signals_oldmask;
+
+G_DEFINE_TYPE(MdmSignalHandler, mdm_signal_handler, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void block_signals_push(void)
+{
+	signals_blocked++;
+
+	if (signals_blocked == 1)
+	{
+		/* Set signal mask */
+		sigemptyset(&signals_block_mask);
+		sigfillset(&signals_block_mask);
+		sigprocmask(SIG_BLOCK, &signals_block_mask, &signals_oldmask);
+	}
+}
+
+static void block_signals_pop(void)
+{
+	signals_blocked--;
+
+	if (signals_blocked == 0)
+	{
+		/* Set signal mask */
+		sigprocmask(SIG_SETMASK, &signals_oldmask, NULL);
+	}
+}
+
+static gboolean signal_io_watch(GIOChannel* ioc, GIOCondition condition, MdmSignalHandler* handler)
+{
+	char buf[256];
+	gboolean is_fatal;
+	gsize bytes_read;
+	int i;
+
+	block_signals_push();
+
+	g_io_channel_read_chars(ioc, buf, sizeof(buf), &bytes_read, NULL);
+
+	is_fatal = FALSE;
+
+	for (i = 0; i < bytes_read; i++)
+	{
+		int signum;
+		GSList* handlers;
+		GSList* l;
+
+		signum = (gint32) buf[i];
+
+		g_debug("MdmSignalHandler: handling signal %d", signum);
+		handlers = g_hash_table_lookup(handler->lookup, GINT_TO_POINTER(signum));
+
+		g_debug("MdmSignalHandler: Found %u callbacks", g_slist_length(handlers));
+
+		for (l = handlers; l != NULL; l = l->next)
+		{
+			gboolean res;
+			CallbackData* data;
+
+			data = g_hash_table_lookup(handler->id_lookup, l->data);
+
+			if (data != NULL)
+			{
+				if (data->func != NULL)
+				{
+					g_debug("MdmSignalHandler: running %d handler: %p", signum, data->func);
+
+					res = data->func(signum, data->data);
+
+					if (!res)
+					{
+						is_fatal = TRUE;
+					}
+				}
+			}
+		}
+	}
+
+	block_signals_pop();
+
+	if (is_fatal)
+	{
+		if (handler->fatal_func != NULL)
+		{
+			g_debug("MdmSignalHandler: Caught termination signal - calling fatal func");
+			handler->fatal_func(handler->fatal_data);
+		}
+		else
+		{
+			g_debug("MdmSignalHandler: Caught termination signal - exiting");
+			exit (1);
+		}
+
+		return FALSE;
+	}
+
+	g_debug("MdmSignalHandler: Done handling signals");
+
+	return TRUE;
+}
+
+static void fallback_get_backtrace(void)
+{
+	#if HAVE_EXECINFO_H
+		void* frames[64];
+		size_t size;
+		char** strings;
+		size_t i;
+
+		size = backtrace(frames, G_N_ELEMENTS(frames));
+
+		if ((strings = backtrace_symbols(frames, size)))
+		{
+			syslog(LOG_CRIT, "******************* START ********************************");
+
+			for (i = 0; i < size; i++)
+			{
+				syslog(LOG_CRIT, "Frame %zd: %s", i, strings[i]);
+			}
+
+			free(strings);
+			syslog(LOG_CRIT, "******************* END **********************************");
+		}
+		else
+		{
+	#endif
+			g_warning ("MDM crashed, but symbols couldn't be retrieved.");
+	#if HAVE_EXECINFO_H
+		}
+	#endif
+}
+
+static gboolean crashlogger_get_backtrace(void)
+{
+	gboolean success = FALSE;
+	int pid;
+
+	pid = fork();
+
+	if (pid > 0)
+	{
+		/* Wait for the child to finish */
+		int estatus;
+
+		if (waitpid(pid, &estatus, 0) != -1)
+		{
+			/* Only succeed if the crashlogger succeeded */
+			if (WIFEXITED(estatus) && (WEXITSTATUS(estatus) == 0))
+			{
+				success = TRUE;
+			}
+		}
+	}
+	else if (pid == 0)
+	{
+		/* Child process */
+		execl(LIBEXECDIR "/mdm-crash-logger", LIBEXECDIR "/mdm-crash-logger", NULL);
+	}
+
+	return success;
+}
+
+static void mdm_signal_handler_backtrace(void)
+{
+	struct stat s;
+	gboolean fallback = TRUE;
+
+	/* Try to use gdb via mdm-crash-logger if it exists, since
+	 * we get much better information out of it.  Otherwise
+	 * fall back to execinfo.
+	 */
+	if (g_stat(LIBEXECDIR "/mdm-crash-logger", &s) == 0)
+	{
+		fallback = crashlogger_get_backtrace() ? FALSE : TRUE;
+	}
+
+	if (fallback)
+	{
+		fallback_get_backtrace();
+	}
+}
+
+static void signal_handler(int signo)
+{
+	static int in_fatal = 0;
+	int UNUSED_VARIABLE ignore;
+	guchar signo_byte = signo;
+
+	/* avoid loops */
+	if (in_fatal > 0)
+	{
+		return;
+	}
+
+	++in_fatal;
+
+	switch (signo)
+	{
+		case SIGSEGV:
+		case SIGBUS:
+		case SIGILL:
+		case SIGABRT:
+		case SIGTRAP:
+			mdm_signal_handler_backtrace();
+			exit(1);
+			break;
+		case SIGFPE:
+		case SIGPIPE:
+			/* let the fatal signals interrupt us */
+			--in_fatal;
+			mdm_signal_handler_backtrace();
+			ignore = write(signal_pipes [1], &signo_byte, 1);
+			break;
+		default:
+			--in_fatal;
+			ignore = write(signal_pipes [1], &signo_byte, 1);
+			break;
+	}
+}
+
+static void catch_signal(MdmSignalHandler *handler, int signal_number)
+{
+	struct sigaction action;
+	struct sigaction* old_action;
+
+	g_debug("MdmSignalHandler: Registering for %d signals", signal_number);
+
+	action.sa_handler = signal_handler;
+	sigemptyset(&action.sa_mask);
+	action.sa_flags = 0;
+
+	old_action = g_new0(struct sigaction, 1);
+
+	sigaction(signal_number, &action, old_action);
+
+	g_hash_table_insert(handler->action_lookup, GINT_TO_POINTER(signal_number), old_action);
+}
+
+static void uncatch_signal(MdmSignalHandler* handler, int signal_number)
+{
+	struct sigaction* old_action;
+
+	g_debug("MdmSignalHandler: Unregistering for %d signals", signal_number);
+
+	old_action = g_hash_table_lookup(handler->action_lookup, GINT_TO_POINTER(signal_number));
+	g_hash_table_remove(handler->action_lookup, GINT_TO_POINTER(signal_number));
+
+	sigaction(signal_number, old_action, NULL);
+
+	g_free(old_action);
+}
+
+guint mdm_signal_handler_add(MdmSignalHandler* handler, int signal_number, MdmSignalHandlerFunc callback, gpointer data)
+{
+	CallbackData* cdata;
+	GSList* list;
+
+	g_return_val_if_fail(MDM_IS_SIGNAL_HANDLER(handler), 0);
+
+	cdata = g_new0(CallbackData, 1);
+	cdata->signal_number = signal_number;
+	cdata->func = callback;
+	cdata->data = data;
+	cdata->id = handler->next_id++;
+
+	g_debug("MdmSignalHandler: Adding handler %u: signum=%d %p", cdata->id, cdata->signal_number, cdata->func);
+
+	if (g_hash_table_lookup(handler->action_lookup, GINT_TO_POINTER(signal_number)) == NULL)
+	{
+		catch_signal(handler, signal_number);
+	}
+
+	/* ID lookup owns the CallbackData */
+	g_hash_table_insert(handler->id_lookup, GUINT_TO_POINTER(cdata->id), cdata);
+
+	list = g_hash_table_lookup(handler->lookup, GINT_TO_POINTER(signal_number));
+	list = g_slist_prepend(list, GUINT_TO_POINTER (cdata->id));
+
+	g_hash_table_insert(handler->lookup, GINT_TO_POINTER(signal_number), list);
+
+	return cdata->id;
+}
+
+void mdm_signal_handler_add_fatal(MdmSignalHandler* handler)
+{
+	g_return_if_fail(MDM_IS_SIGNAL_HANDLER(handler));
+
+	mdm_signal_handler_add(handler, SIGILL, NULL, NULL);
+	mdm_signal_handler_add(handler, SIGBUS, NULL, NULL);
+	mdm_signal_handler_add(handler, SIGSEGV, NULL, NULL);
+	mdm_signal_handler_add(handler, SIGABRT, NULL, NULL);
+	mdm_signal_handler_add(handler, SIGTRAP, NULL, NULL);
+}
+
+static void callback_data_free(CallbackData* d)
+{
+	g_free(d);
+}
+
+static void mdm_signal_handler_remove_and_free_data(MdmSignalHandler* handler, CallbackData* cdata)
+{
+	GSList* list;
+
+	g_return_if_fail(MDM_IS_SIGNAL_HANDLER(handler));
+
+	list = g_hash_table_lookup(handler->lookup, GINT_TO_POINTER(cdata->signal_number));
+	list = g_slist_remove_all(list, GUINT_TO_POINTER(cdata->id));
+
+	if (list == NULL)
+	{
+		uncatch_signal(handler, cdata->signal_number);
+	}
+
+	g_debug("MdmSignalHandler: Removing handler %u: signum=%d %p", cdata->signal_number, cdata->id, cdata->func);
+	/* put changed list back in */
+	g_hash_table_insert(handler->lookup, GINT_TO_POINTER(cdata->signal_number), list);
+
+	g_hash_table_remove(handler->id_lookup, GUINT_TO_POINTER(cdata->id));
+}
+
+void mdm_signal_handler_remove(MdmSignalHandler* handler, guint id)
+{
+	CallbackData* found;
+
+	g_return_if_fail(MDM_IS_SIGNAL_HANDLER(handler));
+
+	found = g_hash_table_lookup(handler->id_lookup, GUINT_TO_POINTER(id));
+
+	if (found != NULL)
+	{
+		mdm_signal_handler_remove_and_free_data(handler, found);
+		found = NULL;
+	}
+}
+
+static CallbackData* find_callback_data_by_func(MdmSignalHandler* handler, guint signal_number, MdmSignalHandlerFunc callback, gpointer data)
+{
+	GSList* list;
+	GSList* l;
+	CallbackData* found;
+
+	found = NULL;
+
+	list = g_hash_table_lookup(handler->lookup, GINT_TO_POINTER(signal_number));
+
+	for (l = list; l != NULL; l = l->next)
+	{
+		guint id;
+		CallbackData* d;
+
+		id = GPOINTER_TO_UINT(l->data);
+
+		d = g_hash_table_lookup(handler->id_lookup, GUINT_TO_POINTER (id));
+
+		if (d != NULL && d->func == callback && d->data == data)
+		{
+			found = d;
+			break;
+		}
+	}
+
+	return found;
+}
+
+void mdm_signal_handler_remove_func(MdmSignalHandler* handler, guint signal_number, MdmSignalHandlerFunc callback, gpointer data)
+{
+	CallbackData* found;
+
+	g_return_if_fail(MDM_IS_SIGNAL_HANDLER(handler));
+
+	found = find_callback_data_by_func(handler, signal_number, callback, data);
+
+	if (found != NULL)
+	{
+		mdm_signal_handler_remove_and_free_data(handler, found);
+		found = NULL;
+	}
+
+	/* FIXME: once all handlers are removed deregister signum handler */
+}
+
+static void mdm_signal_handler_class_init(MdmSignalHandlerClass* klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS(klass);
+
+	object_class->finalize = mdm_signal_handler_finalize;
+}
+
+static void signal_list_free(GSList *list)
+{
+	g_slist_free(list);
+}
+
+void mdm_signal_handler_set_fatal_func(MdmSignalHandler* handler, MdmShutdownHandlerFunc func, gpointer user_data)
+{
+	g_return_if_fail(MDM_IS_SIGNAL_HANDLER(handler));
+
+	handler->fatal_func = func;
+	handler->fatal_data = user_data;
+}
+
+static void mdm_signal_handler_init(MdmSignalHandler* handler)
+{
+	GIOChannel* ioc;
+
+	handler->next_id = 1;
+
+	handler->lookup = g_hash_table_new(NULL, NULL);
+	handler->id_lookup = g_hash_table_new(NULL, NULL);
+	handler->action_lookup = g_hash_table_new(NULL, NULL);
+
+	if (pipe(signal_pipes) == -1)
+	{
+		g_error ("Could not create pipe() for signal handling");
+	}
+
+	ioc = g_io_channel_unix_new(signal_pipes[0]);
+	g_io_channel_set_flags(ioc, G_IO_FLAG_NONBLOCK, NULL);
+	g_io_add_watch_full(ioc, G_PRIORITY_HIGH, G_IO_IN, (GIOFunc) signal_io_watch, handler, NULL);
+	g_io_channel_set_close_on_unref(ioc, TRUE);
+	g_io_channel_unref(ioc);
+}
+
+static void mdm_signal_handler_finalize(GObject* object)
+{
+	MdmSignalHandler* handler;
+	GList* l;
+
+	g_return_if_fail(object != NULL);
+	g_return_if_fail(MDM_IS_SIGNAL_HANDLER(object));
+
+	handler = MDM_SIGNAL_HANDLER(object);
+
+	g_debug("MdmSignalHandler: Finalizing signal handler");
+
+	for (l = g_hash_table_get_values(handler->lookup); l != NULL; l = l->next)
+	{
+		signal_list_free((GSList*) l->data);
+	}
+
+	g_hash_table_destroy(handler->lookup);
+
+	for (l = g_hash_table_get_values(handler->id_lookup); l != NULL; l = l->next)
+	{
+		callback_data_free((CallbackData*) l->data);
+	}
+
+	g_hash_table_destroy(handler->id_lookup);
+
+	for (l = g_hash_table_get_values(handler->action_lookup); l != NULL; l = l->next)
+	{
+		g_free(l->data);
+	}
+
+	g_hash_table_destroy(handler->action_lookup);
+
+	close(signal_pipes[0]);
+	close(signal_pipes[1]);
+
+	G_OBJECT_CLASS(mdm_signal_handler_parent_class)->finalize(object);
+}
+
+MdmSignalHandler* mdm_signal_handler_new(void)
+{
+	if (signal_handler_object != NULL)
+	{
+		g_object_ref(signal_handler_object);
+	}
+	else
+	{
+		signal_handler_object = g_object_new(MDM_TYPE_SIGNAL_HANDLER, NULL);
+		g_object_add_weak_pointer(signal_handler_object, (gpointer*) &signal_handler_object);
+	}
+
+	return MDM_SIGNAL_HANDLER(signal_handler_object);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/59.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/59.html new file mode 100644 index 0000000..f94f78a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/59.html @@ -0,0 +1,1231 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2005 Raffaele Sandrini
+ * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2002, 2003 George Lebl
+ * Copyright (C) 2001 Queen of England,
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *      Raffaele Sandrini <rasa@gmx.ch>
+ *      George Lebl <jirka@5z.com>
+ *      Mark McLoughlin <mark@skynet.ie>
+ */
+
+#ifdef HAVE_CONFIG_H
+	#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/un.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xauth.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mdm.h"
+
+#define MDM_PROTOCOL_UPDATE_INTERVAL 1 /* seconds */
+
+#define MDM_PROTOCOL_SOCKET_PATH "/var/run/mdm_socket"
+
+#define MDM_PROTOCOL_MSG_CLOSE "CLOSE"
+#define MDM_PROTOCOL_MSG_VERSION "VERSION"
+#define MDM_PROTOCOL_MSG_AUTHENTICATE "AUTH_LOCAL"
+#define MDM_PROTOCOL_MSG_QUERY_ACTION "QUERY_LOGOUT_ACTION"
+#define MDM_PROTOCOL_MSG_SET_ACTION "SET_SAFE_LOGOUT_ACTION"
+#define MDM_PROTOCOL_MSG_FLEXI_XSERVER "FLEXI_XSERVER"
+
+#define MDM_ACTION_STR_NONE "NONE"
+#define MDM_ACTION_STR_SHUTDOWN "HALT"
+#define MDM_ACTION_STR_REBOOT "REBOOT"
+#define MDM_ACTION_STR_SUSPEND "SUSPEND"
+
+typedef struct {
+	int fd;
+	char* auth_cookie;
+
+	MdmLogoutAction available_actions;
+	MdmLogoutAction current_actions;
+
+	time_t last_update;
+} MdmProtocolData;
+
+static MdmProtocolData mdm_protocol_data = {
+	0,
+	NULL,
+	MDM_LOGOUT_ACTION_NONE,
+	MDM_LOGOUT_ACTION_NONE,
+	0
+};
+
+static char* mdm_send_protocol_msg(MdmProtocolData* data, const char* msg)
+{
+	GString* retval;
+	char buf[256];
+	char* p;
+	int len;
+
+	p = g_strconcat(msg, "\n", NULL);
+
+	if (write(data->fd, p, strlen(p)) < 0)
+	{
+		g_free(p);
+
+		g_warning("Failed to send message to MDM: %s", g_strerror(errno));
+
+		return NULL;
+	}
+
+	g_free(p);
+
+	p = NULL;
+	retval = NULL;
+
+	while ((len = read(data->fd, buf, sizeof(buf) - 1)) > 0)
+	{
+		buf[len] = '\0';
+
+		if (!retval)
+		{
+			retval = g_string_new(buf);
+		}
+		else
+		{
+			retval = g_string_append(retval, buf);
+		}
+
+		if ((p = strchr(retval->str, '\n')))
+		{
+			break;
+		}
+	}
+
+	if (p)
+	{
+		*p = '\0';
+	}
+
+	return retval ? g_string_free(retval, FALSE) : NULL;
+}
+
+static char* get_display_number(void)
+{
+	const char* display_name;
+	char* retval;
+	char* p;
+
+	display_name = gdk_display_get_name(gdk_display_get_default());
+
+	p = strchr(display_name, ':');
+
+	if (!p)
+	{
+		return g_strdup("0");
+	}
+
+	while (*p == ':')
+	{
+		p++;
+	}
+
+	retval = g_strdup(p);
+
+	p = strchr(retval, '.');
+
+	if (p != NULL)
+	{
+		*p = '\0';
+	}
+
+	return retval;
+}
+
+static gboolean mdm_authenticate_connection(MdmProtocolData* data)
+{
+	#define MDM_MIT_MAGIC_COOKIE_LEN 16
+
+	const char* xau_path;
+	FILE* f;
+	Xauth* xau;
+	char* display_number;
+	gboolean retval;
+
+	if (data->auth_cookie)
+	{
+		char* msg;
+		char* response;
+
+		msg = g_strdup_printf(MDM_PROTOCOL_MSG_AUTHENTICATE " %s", data->auth_cookie);
+		response = mdm_send_protocol_msg(data, msg);
+		g_free(msg);
+
+		if (response && !strcmp(response, "OK"))
+		{
+			g_free(response);
+			return TRUE;
+		}
+		else
+		{
+			g_free(response);
+			g_free(data->auth_cookie);
+			data->auth_cookie = NULL;
+		}
+	}
+
+	if (!(xau_path = XauFileName()))
+	{
+		return FALSE;
+	}
+
+	if (!(f = fopen(xau_path, "r")))
+	{
+		return FALSE;
+	}
+
+	retval = FALSE;
+	display_number = get_display_number();
+
+	while ((xau = XauReadAuth(f)))
+	{
+		char buffer[40]; /* 2*16 == 32, so 40 is enough */
+		char* msg;
+		char* response;
+		int   i;
+
+		if (xau->family != FamilyLocal || strncmp(xau->number, display_number, xau->number_length) || strncmp(xau->name, "MIT-MAGIC-COOKIE-1", xau->name_length) || xau->data_length != MDM_MIT_MAGIC_COOKIE_LEN)
+		{
+			XauDisposeAuth(xau);
+			continue;
+		}
+
+		for (i = 0; i < MDM_MIT_MAGIC_COOKIE_LEN; i++)
+		{
+			g_snprintf(buffer + 2 * i, 3, "%02x", (guint)(guchar) xau->data[i]);
+		}
+
+		XauDisposeAuth(xau);
+
+		msg = g_strdup_printf(MDM_PROTOCOL_MSG_AUTHENTICATE " %s", buffer);
+		response = mdm_send_protocol_msg(data, msg);
+		g_free(msg);
+
+		if (response && !strcmp(response, "OK"))
+		{
+			data->auth_cookie = g_strdup(buffer);
+			g_free(response);
+			retval = TRUE;
+			break;
+		}
+
+		g_free(response);
+	}
+
+	g_free(display_number);
+
+	fclose(f);
+
+	return retval;
+
+	#undef MDM_MIT_MAGIC_COOKIE_LEN
+}
+
+static void mdm_shutdown_protocol_connection(MdmProtocolData *data)
+{
+	if (data->fd)
+	{
+		close(data->fd);
+	}
+
+	data->fd = 0;
+}
+
+static gboolean mdm_init_protocol_connection(MdmProtocolData* data)
+{
+	struct sockaddr_un addr;
+	char* response;
+
+	g_assert(data->fd <= 0);
+
+	if (g_file_test(MDM_PROTOCOL_SOCKET_PATH, G_FILE_TEST_EXISTS))
+	{
+		g_strlcpy (addr.sun_path, MDM_PROTOCOL_SOCKET_PATH, sizeof (addr.sun_path));
+	}
+	else if (g_file_test("/tmp/.mdm_socket", G_FILE_TEST_EXISTS))
+	{
+		g_strlcpy (addr.sun_path, "/tmp/.mdm_socket", sizeof (addr.sun_path));
+	}
+	else
+	{
+		return FALSE;
+	}
+
+	data->fd = socket(AF_UNIX, SOCK_STREAM, 0);
+
+	if (data->fd < 0)
+	{
+		g_warning("Failed to create MDM socket: %s", g_strerror(errno));
+
+		mdm_shutdown_protocol_connection(data);
+
+		return FALSE;
+	}
+
+	addr.sun_family = AF_UNIX;
+
+	if (connect(data->fd, (struct sockaddr*) &addr, sizeof(addr)) < 0)
+	{
+		g_warning("Failed to establish a connection with MDM: %s", g_strerror(errno));
+
+		mdm_shutdown_protocol_connection(data);
+
+		return FALSE;
+	}
+
+	response = mdm_send_protocol_msg(data, MDM_PROTOCOL_MSG_VERSION);
+
+	if (!response || strncmp(response, "MDM ", strlen("MDM ")) != 0)
+	{
+		g_free(response);
+
+		g_warning("Failed to get protocol version from MDM");
+		mdm_shutdown_protocol_connection(data);
+
+		return FALSE;
+	}
+
+	g_free(response);
+
+	if (!mdm_authenticate_connection(data))
+	{
+		g_warning("Failed to authenticate with MDM");
+		mdm_shutdown_protocol_connection(data);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void mdm_parse_query_response(MdmProtocolData* data, const char* response)
+{
+	char** actions;
+	int i;
+
+	data->available_actions = MDM_LOGOUT_ACTION_NONE;
+	data->current_actions = MDM_LOGOUT_ACTION_NONE;
+
+	if (strncmp(response, "OK ", 3) != 0)
+	{
+		return;
+	}
+
+	response += 3;
+
+	actions = g_strsplit(response, ";", -1);
+
+	for (i = 0; actions[i]; i++)
+	{
+		MdmLogoutAction action = MDM_LOGOUT_ACTION_NONE;
+		gboolean selected = FALSE;
+		char* str = actions [i];
+		int len;
+
+		len = strlen(str);
+
+		if (!len)
+		{
+			continue;
+		}
+
+		if (str[len - 1] == '!')
+		{
+			selected = TRUE;
+			str[len - 1] = '\0';
+		}
+
+		if (!strcmp(str, MDM_ACTION_STR_SHUTDOWN))
+		{
+				action = MDM_LOGOUT_ACTION_SHUTDOWN;
+		}
+		else if (!strcmp(str, MDM_ACTION_STR_REBOOT))
+		{
+				action = MDM_LOGOUT_ACTION_REBOOT;
+		}
+		else if (!strcmp(str, MDM_ACTION_STR_SUSPEND))
+		{
+				action = MDM_LOGOUT_ACTION_SUSPEND;
+		}
+
+		data->available_actions |= action;
+
+		if (selected)
+		{
+			data->current_actions |= action;
+		}
+	}
+
+	g_strfreev(actions);
+}
+
+static void mdm_update_logout_actions(MdmProtocolData* data)
+{
+	time_t current_time;
+	char* response;
+
+	current_time = time(NULL);
+
+	if (current_time <= (data->last_update + MDM_PROTOCOL_UPDATE_INTERVAL))
+	{
+		return;
+	}
+
+	data->last_update = current_time;
+
+	if (!mdm_init_protocol_connection(data))
+	{
+		return;
+	}
+
+	if ((response = mdm_send_protocol_msg(data, MDM_PROTOCOL_MSG_QUERY_ACTION)))
+	{
+		mdm_parse_query_response(data, response);
+		g_free(response);
+	}
+
+	mdm_shutdown_protocol_connection(data);
+}
+
+gboolean mdm_is_available(void)
+{
+	if (!mdm_init_protocol_connection(&mdm_protocol_data))
+	{
+		return FALSE;
+	}
+
+	mdm_shutdown_protocol_connection(&mdm_protocol_data);
+
+	return TRUE;
+}
+
+gboolean mdm_supports_logout_action(MdmLogoutAction action)
+{
+	mdm_update_logout_actions(&mdm_protocol_data);
+
+	return (mdm_protocol_data.available_actions & action) != 0;
+}
+
+MdmLogoutAction mdm_get_logout_action(void)
+{
+	mdm_update_logout_actions(&mdm_protocol_data);
+
+	return mdm_protocol_data.current_actions;
+}
+
+void mdm_set_logout_action(MdmLogoutAction action)
+{
+	char* action_str = NULL;
+	char* msg;
+	char* response;
+
+	if (!mdm_init_protocol_connection(&mdm_protocol_data))
+	{
+		return;
+	}
+
+	switch (action)
+	{
+		case MDM_LOGOUT_ACTION_NONE:
+			action_str = MDM_ACTION_STR_NONE;
+			break;
+		case MDM_LOGOUT_ACTION_SHUTDOWN:
+			action_str = MDM_ACTION_STR_SHUTDOWN;
+			break;
+		case MDM_LOGOUT_ACTION_REBOOT:
+			action_str = MDM_ACTION_STR_REBOOT;
+			break;
+		case MDM_LOGOUT_ACTION_SUSPEND:
+			action_str = MDM_ACTION_STR_SUSPEND;
+			break;
+	}
+
+	msg = g_strdup_printf(MDM_PROTOCOL_MSG_SET_ACTION " %s", action_str);
+
+	response = mdm_send_protocol_msg(&mdm_protocol_data, msg);
+
+	g_free(msg);
+	g_free(response);
+
+	mdm_protocol_data.last_update = 0;
+
+	mdm_shutdown_protocol_connection(&mdm_protocol_data);
+}
+
+void mdm_new_login(void)
+{
+    char* response;
+
+    if (!mdm_init_protocol_connection(&mdm_protocol_data))
+    {
+        return;
+    }
+
+    response = mdm_send_protocol_msg(&mdm_protocol_data, MDM_PROTOCOL_MSG_FLEXI_XSERVER);
+
+    g_free(response);
+
+    mdm_protocol_data.last_update = 0;
+
+    mdm_shutdown_protocol_connection(&mdm_protocol_data);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/6.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/6.html new file mode 100644 index 0000000..238019a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/6.html @@ -0,0 +1,419 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ * Copyright (C) 2007, 2009 Vincent Untz.
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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 __GSP_APP_H
+#define __GSP_APP_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define GSP_TYPE_APP            (gsp_app_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GspApp, gsp_app, GSP, APP, GObject)
+
+struct _GspAppClass
+{
+        GObjectClass parent_class;
+
+        void (* changed) (GspApp *app);
+        void (* removed) (GspApp *app);
+};
+
+void             gsp_app_create            (const char   *name,
+                                            const char   *comment,
+                                            const char   *exec,
+                                            guint         delay);
+void             gsp_app_update            (GspApp       *app,
+                                            const char   *name,
+                                            const char   *comment,
+                                            const char   *exec,
+                                            guint         delay);
+
+gboolean         gsp_app_copy_desktop_file (const char   *uri);
+
+void             gsp_app_delete            (GspApp       *app);
+
+const char      *gsp_app_get_basename      (GspApp       *app);
+const char      *gsp_app_get_path          (GspApp       *app);
+
+gboolean         gsp_app_get_hidden        (GspApp       *app);
+void             gsp_app_set_hidden        (GspApp       *app,
+                                            gboolean      hidden);
+
+gboolean         gsp_app_get_nodisplay     (GspApp       *app);
+
+const char      *gsp_app_get_name          (GspApp       *app);
+const char      *gsp_app_get_exec          (GspApp       *app);
+const char      *gsp_app_get_comment       (GspApp       *app);
+guint            gsp_app_get_delay         (GspApp       *app);
+
+const char      *gsp_app_get_description   (GspApp       *app);
+GIcon           *gsp_app_get_icon          (GspApp       *app);
+
+/* private interface for GspAppManager only */
+
+GspApp          *gsp_app_new                      (const char   *path,
+                                                   unsigned int  xdg_position);
+
+void             gsp_app_reload_at                (GspApp       *app,
+                                                   const char   *path,
+                                                   unsigned int  xdg_position);
+
+unsigned int     gsp_app_get_xdg_position         (GspApp       *app);
+unsigned int     gsp_app_get_xdg_system_position  (GspApp       *app);
+void             gsp_app_set_xdg_system_position  (GspApp       *app,
+                                                   unsigned int  position);
+
+G_END_DECLS
+
+#endif /* __GSP_APP_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/60.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/60.html new file mode 100644 index 0000000..2536496 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/60.html @@ -0,0 +1,621 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
/*
+ * Copyright (c) 2004-2005 Benedikt Meurer <benny@xfce.org>
+ *               2013 Stefano Karapetsas <stefano@karapetsas.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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, 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 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 Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA.
+ *
+ * Most parts of this file where taken from xfce4-session and
+ * gnome-session.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <signal.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "msm-gnome.h"
+
+#define GSM_SCHEMA "org.mate.session"
+#define GSM_GNOME_COMPAT_STARTUP_KEY "gnome-compat-startup"
+
+#define GNOME_KEYRING_DAEMON "gnome-keyring-daemon"
+
+static gboolean gnome_compat_started = FALSE;
+static Window gnome_smproxy_window = None;
+
+static void
+gnome_keyring_daemon_finished (GPid pid,
+                               gint status,
+                               gpointer user_data)
+{
+  if (WEXITSTATUS (status) != 0)
+    {
+      /* daemon failed for some reason */
+      g_printerr ("gnome-keyring-daemon failed to start correctly, "
+                  "exit code: %d\n", WEXITSTATUS (status));
+    }
+}
+
+static void
+gnome_keyring_daemon_startup (void)
+{
+  GError      *error = NULL;
+  GPid         pid;
+  gchar       *argv[3];
+
+  error = NULL;
+  argv[0] = GNOME_KEYRING_DAEMON;
+  argv[1] = "--start";
+  argv[2] = NULL;
+  g_spawn_async (NULL, argv, NULL,
+		 G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
+		 NULL, NULL, &pid,
+		 &error);
+
+  if (error != NULL)
+    {
+      g_printerr ("Failed to spawn gnome-keyring-daemon: %s\n",
+                  error->message);
+      g_error_free (error);
+      return;
+    }
+
+  g_child_watch_add (pid, gnome_keyring_daemon_finished, NULL);
+}
+
+static void
+msm_compat_gnome_smproxy_startup (void)
+{
+  Atom gnome_sm_proxy;
+  Display *dpy;
+  Window root;
+  GdkDisplay *gdkdisplay;
+
+  gdkdisplay = gdk_display_get_default ();
+  gdk_x11_display_error_trap_push (gdkdisplay);
+
+  /* Set GNOME_SM_PROXY property, since some apps (like OOo) seem to require
+   * it to behave properly. Thanks to Jasper/Francois for reporting this.
+   * This has another advantage, since it prevents people from running
+   * gnome-smproxy in xfce4, which would cause trouble otherwise.
+   */
+  dpy = GDK_DISPLAY_XDISPLAY(gdkdisplay);
+  root = RootWindow (dpy, 0);
+
+  if (gnome_smproxy_window != None)
+    XDestroyWindow (dpy, gnome_smproxy_window);
+
+  gnome_sm_proxy = XInternAtom (dpy, "GNOME_SM_PROXY", False);
+  gnome_smproxy_window = XCreateSimpleWindow (dpy, root, 1, 1, 1, 1, 0, 0, 0);
+
+  XChangeProperty (dpy, gnome_smproxy_window, gnome_sm_proxy,
+                   XA_CARDINAL, 32, PropModeReplace,
+                   (unsigned char *) (void *) &gnome_smproxy_window, 1);
+  XChangeProperty (dpy, root, gnome_sm_proxy,
+                   XA_CARDINAL, 32, PropModeReplace,
+                   (unsigned char *) (void *) &gnome_smproxy_window, 1);
+
+  XSync (dpy, False);
+  gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+}
+
+static void
+msm_compat_gnome_smproxy_shutdown (void)
+{
+  GdkDisplay *gdkdisplay;
+
+  gdkdisplay = gdk_display_get_default ();
+  gdk_x11_display_error_trap_push (gdkdisplay);
+
+  if (gnome_smproxy_window != None)
+    {
+      XDestroyWindow (GDK_DISPLAY_XDISPLAY(gdkdisplay), gnome_smproxy_window);
+      XSync (GDK_DISPLAY_XDISPLAY(gdkdisplay), False);
+      gnome_smproxy_window = None;
+    }
+  gdk_x11_display_error_trap_pop_ignored (gdkdisplay);
+}
+
+void
+msm_gnome_start (void)
+{
+  GSettings* settings;
+  gchar **array;
+
+  if (gnome_compat_started == TRUE)
+    return;
+
+  settings = g_settings_new (GSM_SCHEMA);
+  array = g_settings_get_strv (settings, GSM_GNOME_COMPAT_STARTUP_KEY);
+  if (array) {
+    guint i;
+
+    for (i = 0; array[i]; i++) {
+      if (strcmp (array[i], "smproxy") == 0) {
+        g_debug ("MsmGnome: starting smproxy");
+        msm_compat_gnome_smproxy_startup ();
+        gnome_compat_started = TRUE;
+      } else if (strcmp (array[i], "keyring") == 0) {
+        g_debug ("MsmGnome: starting keyring");
+        gnome_keyring_daemon_startup ();
+        gnome_compat_started = TRUE;
+      } else {
+        g_debug ("MsmGnome: ignoring unknown component \"%s\"", array[i]);
+      }
+    }
+    g_strfreev (array);
+  } else {
+    g_debug ("MsmGnome: No components found to start");
+  }
+  g_object_unref (settings);
+}
+
+void
+msm_gnome_stop (void)
+{
+  if (gnome_compat_started == FALSE)
+    return;
+
+  g_debug ("MsmGnome: stopping");
+
+  msm_compat_gnome_smproxy_shutdown ();
+
+  gnome_compat_started = FALSE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/61.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/61.html new file mode 100644 index 0000000..dae8d07 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/61.html @@ -0,0 +1,777 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+static GDBusConnection *bus_connection = NULL;
+static GDBusProxy      *sm_proxy = NULL;
+static char            *client_id = NULL;
+static GDBusProxy      *client_proxy = NULL;
+static GMainLoop       *main_loop = NULL;
+
+static gboolean
+session_manager_connect (void)
+{
+
+        if (bus_connection == NULL) {
+                GError *error;
+
+                error = NULL;
+                bus_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+                if (bus_connection == NULL) {
+                        g_message ("Failed to connect to the session bus: %s",
+                                   error->message);
+                        g_error_free (error);
+                        exit (1);
+                }
+        }
+
+        sm_proxy = g_dbus_proxy_new_sync (bus_connection,
+                                          G_DBUS_PROXY_FLAGS_NONE,
+                                          NULL,
+                                          SM_DBUS_NAME,
+                                          SM_DBUS_PATH,
+                                          SM_DBUS_INTERFACE,
+                                          NULL,
+                                          NULL);
+        return (sm_proxy != NULL);
+}
+
+static void
+on_client_query_end_session (GDBusProxy     *proxy,
+                             GVariant   *parameters)
+{
+        GError     *error;
+        gboolean    is_ok;
+        GVariant   *res;
+        guint       flags;
+        const char *reason;
+
+        is_ok = FALSE;
+        reason = "Unsaved files";
+        g_variant_get (parameters, "(u)", &flags);
+
+        g_debug ("Got query end session signal flags=%u", flags);
+
+        error = NULL;
+        res = g_dbus_proxy_call_sync (proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_ok,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1,
+                                      NULL,
+                                      &error);
+        if (res == NULL) {
+                g_warning ("Failed to respond to EndSession: %s", error->message);
+                g_error_free (error);
+        } else {
+                g_variant_unref (res);
+        }
+}
+
+static void
+on_client_end_session (GVariant *parameters)
+{
+        guint flags;
+        g_variant_get (parameters, "(u)", &flags);
+        g_debug ("Got end session signal flags=%u", flags);
+}
+
+static void
+on_client_cancel_end_session (void)
+{
+        g_debug ("Got end session cancelled signal");
+}
+
+static void
+on_client_stop (void)
+{
+        g_debug ("Got client stop signal");
+        g_main_loop_quit (main_loop);
+}
+
+static void
+on_client_dbus_signal (GDBusProxy  *proxy,
+                       gchar       *sender_name,
+                       gchar       *signal_name,
+                       GVariant    *parameters,
+                       gpointer     user_data)
+{
+        if (g_strcmp0 (signal_name, "Stop") == 0) {
+                on_client_stop ();
+        } else if (g_strcmp0 (signal_name, "CancelEndSession") == 0) {
+                on_client_cancel_end_session ();
+        } else if (g_strcmp0 (signal_name, "EndSession") == 0) {
+                on_client_end_session (parameters);
+        } else if (g_strcmp0 (signal_name, "QueryEndSession") == 0) {
+                on_client_query_end_session (proxy, parameters);
+        }
+}
+
+static gboolean
+register_client (void)
+{
+        GError     *error;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        if (!startup_id) {
+                startup_id = "";
+        }
+        app_id = "gedit";
+
+        error = NULL;
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1,
+                                      NULL,
+                                      &error);
+        if (res == NULL) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_get (res, "(o)", &client_id);
+        g_debug ("Client registered with session manager: %s", client_id);
+
+        client_proxy = g_dbus_proxy_new_sync (bus_connection,
+                                              G_DBUS_PROXY_FLAGS_NONE,
+                                              NULL,
+                                              SM_DBUS_NAME,
+                                              client_id,
+                                              SM_CLIENT_DBUS_INTERFACE,
+                                              NULL, NULL);
+        if (client_proxy != NULL) {
+                g_signal_connect (client_proxy, "g-signal",
+                                  G_CALLBACK (on_client_dbus_signal), NULL);
+        }
+
+        g_variant_unref (res);
+
+        return (client_proxy != NULL);
+}
+
+static gboolean
+session_manager_disconnect (void)
+{
+        if (sm_proxy != NULL) {
+                g_object_unref (sm_proxy);
+                sm_proxy = NULL;
+        }
+
+        return TRUE;
+}
+
+static gboolean
+unregister_client (void)
+{
+        GError  *error;
+        GVariant *res;
+
+        error = NULL;
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "UnregisterClient",
+                                      g_variant_new ("(o)", client_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, NULL, &error);
+        if (res == NULL) {
+                g_warning ("Failed to unregister client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_free (client_id);
+        client_id = NULL;
+
+        g_variant_unref (res);
+
+        return TRUE;
+}
+
+static gboolean
+quit_test (gpointer data)
+{
+        g_main_loop_quit (main_loop);
+        return FALSE;
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+        gboolean res;
+
+        g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
+        res = session_manager_connect ();
+        if (! res) {
+                g_warning ("Unable to connect to session manager");
+                exit (1);
+        }
+
+        res = register_client ();
+        if (! res) {
+                g_warning ("Unable to register client with session manager");
+        }
+
+        main_loop = g_main_loop_new (NULL, FALSE);
+
+        g_timeout_add_seconds (30, quit_test, NULL);
+
+        g_main_loop_run (main_loop);
+        g_main_loop_unref (main_loop);
+
+        unregister_client ();
+        session_manager_disconnect ();
+
+        return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/62.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/62.html new file mode 100644 index 0000000..a695cee --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/62.html @@ -0,0 +1,613 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * 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.
+ *
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <dbus/dbus-glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+
+static GDBusProxy      *sm_proxy = NULL;
+static guint            cookie = 0;
+
+static gboolean
+session_manager_connect (void)
+{
+        GError *error = NULL;
+        if (sm_proxy == NULL) {
+                sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                          G_DBUS_PROXY_FLAGS_NONE,
+                                                          NULL,
+                                                          SM_DBUS_NAME,
+                                                          SM_DBUS_PATH,
+                                                          SM_DBUS_INTERFACE,
+                                                          NULL,
+                                                          &error);
+        }
+        return (sm_proxy != NULL);
+}
+
+typedef enum {
+        GSM_INHIBITOR_FLAG_LOGOUT      = 1 << 0,
+        GSM_INHIBITOR_FLAG_SWITCH_USER = 1 << 1,
+        GSM_INHIBITOR_FLAG_SUSPEND     = 1 << 2
+} GsmInhibitFlag;
+
+static gboolean
+do_inhibit_for_window (GdkWindow *window)
+{
+        GError     *error;
+        GVariant   *ret;
+        const char *startup_id G_GNUC_UNUSED;
+        const char *app_id;
+        const char *reason;
+        guint       toplevel_xid;
+        guint       flags;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "caja-cd-burner";
+        reason = "A CD burn is in progress.";
+        toplevel_xid = gdk_x11_window_get_xid (window);
+
+        flags = GSM_INHIBITOR_FLAG_LOGOUT
+                | GSM_INHIBITOR_FLAG_SWITCH_USER
+                | GSM_INHIBITOR_FLAG_SUSPEND;
+
+        error = NULL;
+        ret = g_dbus_proxy_call_sync (sm_proxy,
+                                      "Inhibit",
+                                      g_variant_new ("(susu)", app_id, toplevel_xid, reason, flags),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1,
+                                      NULL,
+                                      &error);
+        if (ret == NULL) {
+                g_warning ("Failed to inhibit: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_get (ret, "(u)", &cookie);
+        g_variant_unref (ret);
+        g_debug ("Inhibiting session manager: %u", cookie);
+
+        return TRUE;
+}
+static gboolean
+session_manager_disconnect (void)
+{
+        if (sm_proxy != NULL) {
+                g_object_unref (sm_proxy);
+                sm_proxy = NULL;
+        }
+
+        return TRUE;
+}
+
+static gboolean
+do_uninhibit (void)
+{
+        GError  *error;
+        GVariant *ret;
+
+        error = NULL;
+        ret = g_dbus_proxy_call_sync (sm_proxy,
+                                      "Uninhibit",
+                                      g_variant_new ("(u)", cookie),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1,
+                                      NULL,
+                                      &error);
+        if (ret == NULL) {
+                g_warning ("Failed to uninhibit: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (ret);
+        cookie = 0;
+
+        return TRUE;
+}
+
+static void
+on_widget_show (GtkWidget *dialog,
+                gpointer   data)
+{
+        gboolean res;
+
+        res = do_inhibit_for_window (gtk_widget_get_window (dialog));
+        if (! res) {
+                g_warning ("Unable to register client with session manager");
+        }
+}
+
+int
+main (int   argc,
+      char *argv[])
+{
+        gboolean   res;
+        GtkWidget *dialog;
+
+        g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
+
+        gtk_init (&argc, &argv);
+
+        res = session_manager_connect ();
+        if (! res) {
+                g_warning ("Unable to connect to session manager");
+                exit (1);
+        }
+
+        g_timeout_add_seconds (30, (GSourceFunc)gtk_main_quit, NULL);
+
+        dialog = gtk_message_dialog_new (NULL,
+                                         0,
+                                         GTK_MESSAGE_INFO,
+                                         GTK_BUTTONS_CANCEL,
+                                         "Inhibiting logout, switch user, and suspend.");
+
+        g_signal_connect (dialog, "response", G_CALLBACK (gtk_main_quit), NULL);
+        g_signal_connect (dialog, "show", G_CALLBACK (on_widget_show), NULL);
+        gtk_widget_show (dialog);
+
+        gtk_main ();
+
+        do_uninhibit ();
+        session_manager_disconnect ();
+
+        return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/63.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/63.html new file mode 100644 index 0000000..8d6c383 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/63.html @@ -0,0 +1,541 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* eggdesktopfile.h - Freedesktop.Org Desktop Files
+ * Copyright (C) 2007 Novell, 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 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; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __EGG_DESKTOP_FILE_H__
+#define __EGG_DESKTOP_FILE_H__
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+typedef struct EggDesktopFile EggDesktopFile;
+
+typedef enum {
+    EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED,
+
+    EGG_DESKTOP_FILE_TYPE_APPLICATION,
+    EGG_DESKTOP_FILE_TYPE_LINK,
+    EGG_DESKTOP_FILE_TYPE_DIRECTORY
+} EggDesktopFileType;
+
+EggDesktopFile     *egg_desktop_file_new                   (const char   *desktop_file_path,
+                                                            GError      **error);
+EggDesktopFile     *egg_desktop_file_new_from_data_dirs    (const char   *desktop_file_path,
+                                                            GError      **error);
+EggDesktopFile     *egg_desktop_file_new_from_dirs         (const char   *desktop_file_path,
+                                                            const char  **search_dirs,
+                                                            GError      **error);
+EggDesktopFile     *egg_desktop_file_new_from_key_file     (GKeyFile     *key_file,
+                                                            const char   *source,
+                                                            GError      **error);
+void                egg_desktop_file_free                  (EggDesktopFile  *desktop_file);
+const char         *egg_desktop_file_get_source            (EggDesktopFile  *desktop_file);
+EggDesktopFileType  egg_desktop_file_get_desktop_file_type (EggDesktopFile  *desktop_file);
+const char         *egg_desktop_file_get_name              (EggDesktopFile  *desktop_file);
+const char         *egg_desktop_file_get_icon              (EggDesktopFile  *desktop_file);
+gboolean            egg_desktop_file_can_launch            (EggDesktopFile  *desktop_file,
+                                                            const char      *desktop_environment);
+gboolean            egg_desktop_file_accepts_documents     (EggDesktopFile  *desktop_file);
+gboolean            egg_desktop_file_accepts_multiple      (EggDesktopFile  *desktop_file);
+gboolean            egg_desktop_file_accepts_uris          (EggDesktopFile  *desktop_file);
+char               *egg_desktop_file_parse_exec            (EggDesktopFile  *desktop_file,
+                                                            GSList          *documents,
+                                                            GError         **error);
+gboolean            egg_desktop_file_launch                (EggDesktopFile  *desktop_file,
+                                                            GSList          *documents,
+                                                            GError         **error,
+                                                            ...) G_GNUC_NULL_TERMINATED;
+
+typedef enum {
+    EGG_DESKTOP_FILE_LAUNCH_CLEARENV = 1,
+    EGG_DESKTOP_FILE_LAUNCH_PUTENV,
+    EGG_DESKTOP_FILE_LAUNCH_SCREEN,
+    EGG_DESKTOP_FILE_LAUNCH_WORKSPACE,
+    EGG_DESKTOP_FILE_LAUNCH_DIRECTORY,
+    EGG_DESKTOP_FILE_LAUNCH_TIME,
+    EGG_DESKTOP_FILE_LAUNCH_FLAGS,
+    EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC,
+    EGG_DESKTOP_FILE_LAUNCH_RETURN_PID,
+    EGG_DESKTOP_FILE_LAUNCH_RETURN_STDIN_PIPE,
+    EGG_DESKTOP_FILE_LAUNCH_RETURN_STDOUT_PIPE,
+    EGG_DESKTOP_FILE_LAUNCH_RETURN_STDERR_PIPE,
+    EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID
+} EggDesktopFileLaunchOption;
+
+/* Standard Keys */
+#define EGG_DESKTOP_FILE_GROUP                  "Desktop Entry"
+
+#define EGG_DESKTOP_FILE_KEY_TYPE               "Type"
+#define EGG_DESKTOP_FILE_KEY_VERSION            "Version"
+#define EGG_DESKTOP_FILE_KEY_NAME               "Name"
+#define EGG_DESKTOP_FILE_KEY_GENERIC_NAME       "GenericName"
+#define EGG_DESKTOP_FILE_KEY_NO_DISPLAY         "NoDisplay"
+#define EGG_DESKTOP_FILE_KEY_COMMENT            "Comment"
+#define EGG_DESKTOP_FILE_KEY_ICON               "Icon"
+#define EGG_DESKTOP_FILE_KEY_HIDDEN             "Hidden"
+#define EGG_DESKTOP_FILE_KEY_ONLY_SHOW_IN       "OnlyShowIn"
+#define EGG_DESKTOP_FILE_KEY_NOT_SHOW_IN        "NotShowIn"
+#define EGG_DESKTOP_FILE_KEY_TRY_EXEC           "TryExec"
+#define EGG_DESKTOP_FILE_KEY_EXEC               "Exec"
+#define EGG_DESKTOP_FILE_KEY_PATH               "Path"
+#define EGG_DESKTOP_FILE_KEY_TERMINAL           "Terminal"
+#define EGG_DESKTOP_FILE_KEY_MIME_TYPE          "MimeType"
+#define EGG_DESKTOP_FILE_KEY_CATEGORIES         "Categories"
+#define EGG_DESKTOP_FILE_KEY_STARTUP_NOTIFY     "StartupNotify"
+#define EGG_DESKTOP_FILE_KEY_STARTUP_WM_CLASS   "StartupWMClass"
+#define EGG_DESKTOP_FILE_KEY_URL                "URL"
+
+/* Accessors */
+gboolean  egg_desktop_file_has_key                (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   GError         **error);
+char     *egg_desktop_file_get_string             (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   GError         **error) G_GNUC_MALLOC;
+char     *egg_desktop_file_get_locale_string      (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   const char      *locale,
+                                                   GError         **error) G_GNUC_MALLOC;
+gboolean  egg_desktop_file_get_boolean            (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   GError         **error);
+double    egg_desktop_file_get_numeric            (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   GError         **error);
+int	      egg_desktop_file_get_integer            (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   GError         **error);
+char    **egg_desktop_file_get_string_list        (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   gsize           *length,
+                                                   GError         **error) G_GNUC_MALLOC;
+char    **egg_desktop_file_get_locale_string_list (EggDesktopFile  *desktop_file,
+                                                   const char      *key,
+                                                   const char      *locale,
+                                                   gsize           *length,
+                                                   GError         **error) G_GNUC_MALLOC;
+
+/* Errors */
+#define EGG_DESKTOP_FILE_ERROR egg_desktop_file_error_quark()
+
+GQuark egg_desktop_file_error_quark (void);
+
+typedef enum {
+    EGG_DESKTOP_FILE_ERROR_INVALID,
+    EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
+    EGG_DESKTOP_FILE_ERROR_UNRECOGNIZED_OPTION
+} EggDesktopFileError;
+
+/* Global application desktop file */
+void            egg_set_desktop_file (const char *desktop_file_path);
+void            egg_set_desktop_file_without_defaults (const char *desktop_file_path);
+EggDesktopFile *egg_get_desktop_file (void);
+
+G_END_DECLS
+
+#endif /* __EGG_DESKTOP_FILE_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/64.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/64.html new file mode 100644 index 0000000..3dc2863 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/64.html @@ -0,0 +1,3385 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
+1410
+1411
+1412
+1413
+1414
+1415
+1416
+1417
+1418
+1419
+1420
+1421
+1422
+1423
+1424
+1425
+1426
+1427
+1428
+1429
+1430
+1431
+1432
+1433
+1434
+1435
+1436
+1437
+1438
+1439
+1440
+1441
+1442
+1443
+1444
+1445
+1446
+1447
+1448
+1449
+1450
+1451
+1452
+1453
+1454
+1455
+1456
+1457
+1458
+1459
+1460
+1461
+1462
+1463
+1464
+1465
+1466
+1467
+1468
+1469
+1470
+1471
+1472
+1473
+1474
+1475
+1476
+1477
+1478
+1479
+1480
+1481
+1482
+1483
+1484
+1485
+1486
+1487
+1488
+1489
+1490
+1491
+1492
+1493
+1494
+1495
+1496
+1497
+1498
+1499
+1500
+1501
+1502
+1503
+1504
+1505
+1506
+1507
+1508
+1509
+1510
+1511
+1512
+1513
+1514
+1515
+1516
+1517
+1518
+1519
+1520
+1521
+1522
+1523
+1524
+1525
+1526
+1527
+1528
+1529
+1530
+1531
+1532
+1533
+1534
+1535
+1536
+1537
+1538
/* eggdesktopfile.c - Freedesktop.Org Desktop Files
+ * Copyright (C) 2007 Novell, Inc.
+ *
+ * Based on mate-desktop-item.c
+ * Copyright (C) 1999, 2000 Red Hat Inc.
+ * Copyright (C) 2001 George Lebl
+ *
+ * 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 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; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include "eggdesktopfile.h"
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+struct EggDesktopFile {
+  GKeyFile           *key_file;
+  char               *source;
+
+  char               *name, *icon;
+  EggDesktopFileType  type;
+  char                document_code;
+};
+
+/**
+ * egg_desktop_file_new:
+ * @desktop_file_path: path to a Freedesktop-style Desktop file
+ * @error: error pointer
+ *
+ * Creates a new #EggDesktopFile for @desktop_file.
+ *
+ * Return value: the new #EggDesktopFile, or %NULL on error.
+ **/
+EggDesktopFile *
+egg_desktop_file_new (const char *desktop_file_path, GError **error)
+{
+  GKeyFile *key_file;
+
+  key_file = g_key_file_new ();
+  if (!g_key_file_load_from_file (key_file, desktop_file_path, 0, error))
+    {
+      g_key_file_free (key_file);
+      return NULL;
+    }
+
+  return egg_desktop_file_new_from_key_file (key_file, desktop_file_path,
+					     error);
+}
+
+/**
+ * egg_desktop_file_new_from_data_dirs:
+ * @desktop_file_path: relative path to a Freedesktop-style Desktop file
+ * @error: error pointer
+ *
+ * Looks for @desktop_file_path in the paths returned from
+ * g_get_user_data_dir() and g_get_system_data_dirs(), and creates
+ * a new #EggDesktopFile from it.
+ *
+ * Return value: the new #EggDesktopFile, or %NULL on error.
+ **/
+EggDesktopFile *
+egg_desktop_file_new_from_data_dirs (const char  *desktop_file_path,
+				     GError     **error)
+{
+  EggDesktopFile *desktop_file;
+  GKeyFile *key_file;
+  char *full_path;
+
+  key_file = g_key_file_new ();
+  if (!g_key_file_load_from_data_dirs (key_file, desktop_file_path,
+				       &full_path, 0, error))
+    {
+      g_key_file_free (key_file);
+      return NULL;
+    }
+
+  desktop_file = egg_desktop_file_new_from_key_file (key_file,
+						     full_path,
+						     error);
+  g_free (full_path);
+  return desktop_file;
+}
+
+/**
+ * egg_desktop_file_new_from_dirs:
+ * @desktop_file_path: relative path to a Freedesktop-style Desktop file
+ * @search_dirs: NULL-terminated array of directories to search
+ * @error: error pointer
+ *
+ * Looks for @desktop_file_path in the paths returned from
+ * g_get_user_data_dir() and g_get_system_data_dirs(), and creates
+ * a new #EggDesktopFile from it.
+ *
+ * Return value: the new #EggDesktopFile, or %NULL on error.
+ **/
+EggDesktopFile *
+egg_desktop_file_new_from_dirs (const char  *desktop_file_path,
+				const char **search_dirs,
+				GError     **error)
+{
+  EggDesktopFile *desktop_file;
+  GKeyFile *key_file;
+  char *full_path;
+
+  key_file = g_key_file_new ();
+  if (!g_key_file_load_from_dirs (key_file, desktop_file_path, search_dirs,
+				  &full_path, 0, error))
+    {
+      g_key_file_free (key_file);
+      return NULL;
+    }
+
+  desktop_file = egg_desktop_file_new_from_key_file (key_file,
+						     full_path,
+						     error);
+  g_free (full_path);
+  return desktop_file;
+}
+
+/**
+ * egg_desktop_file_new_from_key_file:
+ * @key_file: a #GKeyFile representing a desktop file
+ * @source: the path or URI that @key_file was loaded from, or %NULL
+ * @error: error pointer
+ *
+ * Creates a new #EggDesktopFile for @key_file. Assumes ownership of
+ * @key_file (on success or failure); you should consider @key_file to
+ * be freed after calling this function.
+ *
+ * Return value: the new #EggDesktopFile, or %NULL on error.
+ **/
+EggDesktopFile *
+egg_desktop_file_new_from_key_file (GKeyFile    *key_file,
+				    const char  *source,
+				    GError     **error)
+{
+  EggDesktopFile *desktop_file;
+  char *version, *type;
+
+  if (!g_key_file_has_group (key_file, EGG_DESKTOP_FILE_GROUP))
+    {
+      g_set_error (error, EGG_DESKTOP_FILE_ERROR,
+		   EGG_DESKTOP_FILE_ERROR_INVALID,
+		   _("File is not a valid .desktop file"));
+      g_key_file_free (key_file);
+      return NULL;
+    }
+
+  version = g_key_file_get_value (key_file, EGG_DESKTOP_FILE_GROUP,
+				  EGG_DESKTOP_FILE_KEY_VERSION,
+				  NULL);
+  if (version)
+    {
+      double version_num;
+      char *end;
+
+      version_num = g_ascii_strtod (version, &end);
+      if (*end)
+	{
+	  g_warning ("Invalid Version string '%s' in %s",
+		     version, source ? source : "(unknown)");
+	}
+      else if (version_num > 1.0)
+	{
+      /* Translators: Version here is capitalized because it refers to a
+       * field in the desktop file */
+	  g_set_error (error, EGG_DESKTOP_FILE_ERROR,
+		       EGG_DESKTOP_FILE_ERROR_INVALID,
+		       _("Unrecognized desktop file Version '%s'"), version);
+	  g_free (version);
+	  g_key_file_free (key_file);
+	  return NULL;
+	}
+      g_free (version);
+    }
+
+  desktop_file = g_new0 (EggDesktopFile, 1);
+  desktop_file->key_file = key_file;
+
+  if (g_path_is_absolute (source))
+    desktop_file->source = g_filename_to_uri (source, NULL, NULL);
+  else
+    desktop_file->source = g_strdup (source);
+
+  desktop_file->name = g_key_file_get_string (key_file, EGG_DESKTOP_FILE_GROUP,
+					      EGG_DESKTOP_FILE_KEY_NAME, error);
+  if (!desktop_file->name)
+    {
+      egg_desktop_file_free (desktop_file);
+      return NULL;
+    }
+
+  type = g_key_file_get_string (key_file, EGG_DESKTOP_FILE_GROUP,
+				EGG_DESKTOP_FILE_KEY_TYPE, error);
+  if (!type)
+    {
+      egg_desktop_file_free (desktop_file);
+      return NULL;
+    }
+
+  if (!strcmp (type, "Application"))
+    {
+      char *exec, *p;
+
+      desktop_file->type = EGG_DESKTOP_FILE_TYPE_APPLICATION;
+
+      exec = g_key_file_get_string (key_file,
+				    EGG_DESKTOP_FILE_GROUP,
+				    EGG_DESKTOP_FILE_KEY_EXEC,
+				    error);
+      if (!exec)
+	{
+	  egg_desktop_file_free (desktop_file);
+	  g_free (type);
+	  return NULL;
+	}
+
+      /* See if it takes paths or URIs or neither */
+      for (p = exec; *p; p++)
+	{
+	  if (*p == '%')
+	    {
+	      if (p[1] == '\0' || strchr ("FfUu", p[1]))
+		{
+		  desktop_file->document_code = p[1];
+		  break;
+		}
+	      p++;
+	    }
+	}
+
+      g_free (exec);
+    }
+  else if (!strcmp (type, "Link"))
+    {
+      char *url;
+
+      desktop_file->type = EGG_DESKTOP_FILE_TYPE_LINK;
+
+      url = g_key_file_get_string (key_file,
+				   EGG_DESKTOP_FILE_GROUP,
+				   EGG_DESKTOP_FILE_KEY_URL,
+				   error);
+      if (!url)
+	{
+	  egg_desktop_file_free (desktop_file);
+	  g_free (type);
+	  return NULL;
+	}
+      g_free (url);
+    }
+  else if (!strcmp (type, "Directory"))
+    desktop_file->type = EGG_DESKTOP_FILE_TYPE_DIRECTORY;
+  else
+    desktop_file->type = EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED;
+
+  g_free (type);
+
+  /* Check the Icon key */
+  desktop_file->icon = g_key_file_get_string (key_file,
+					      EGG_DESKTOP_FILE_GROUP,
+					      EGG_DESKTOP_FILE_KEY_ICON,
+					      NULL);
+  if (desktop_file->icon && !g_path_is_absolute (desktop_file->icon))
+    {
+      char *ext;
+
+      /* Lots of .desktop files still get this wrong */
+      ext = strrchr (desktop_file->icon, '.');
+      if (ext && (!strcmp (ext, ".png") ||
+		  !strcmp (ext, ".xpm") ||
+		  !strcmp (ext, ".svg")))
+	{
+	  g_warning ("Desktop file '%s' has malformed Icon key '%s'"
+		     "(should not include extension)",
+		     source ? source : "(unknown)",
+		     desktop_file->icon);
+	  *ext = '\0';
+	}
+    }
+
+  return desktop_file;
+}
+
+/**
+ * egg_desktop_file_free:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Frees @desktop_file.
+ **/
+void
+egg_desktop_file_free (EggDesktopFile *desktop_file)
+{
+  g_key_file_free (desktop_file->key_file);
+  g_free (desktop_file->source);
+  g_free (desktop_file->name);
+  g_free (desktop_file->icon);
+  g_free (desktop_file);
+}
+
+/**
+ * egg_desktop_file_get_source:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Gets the URI that @desktop_file was loaded from.
+ *
+ * Return value: @desktop_file's source URI
+ **/
+const char *
+egg_desktop_file_get_source (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return desktop_file->source;
+}
+
+/**
+ * egg_desktop_file_get_desktop_file_type:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Gets the desktop file type of @desktop_file.
+ *
+ * Return value: @desktop_file's type
+ **/
+EggDesktopFileType
+egg_desktop_file_get_desktop_file_type (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return desktop_file->type;
+}
+
+/**
+ * egg_desktop_file_get_name:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Gets the (localized) value of @desktop_file's "Name" key.
+ *
+ * Return value: the application/link name
+ **/
+const char *
+egg_desktop_file_get_name (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return desktop_file->name;
+}
+
+/**
+ * egg_desktop_file_get_icon:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Gets the value of @desktop_file's "Icon" key.
+ *
+ * If the icon string is a full path (that is, if g_path_is_absolute()
+ * returns %TRUE when called on it), it points to a file containing an
+ * unthemed icon. If the icon string is not a full path, it is the
+ * name of a themed icon, which can be looked up with %GtkIconTheme,
+ * or passed directly to a theme-aware widget like %GtkImage or
+ * %GtkCellRendererPixbuf.
+ *
+ * Return value: the icon path or name
+ **/
+const char *
+egg_desktop_file_get_icon (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return desktop_file->icon;
+}
+
+gboolean
+egg_desktop_file_has_key (EggDesktopFile  *desktop_file,
+			  const char      *key,
+			  GError         **error)
+{
+  return g_key_file_has_key (desktop_file->key_file,
+			     EGG_DESKTOP_FILE_GROUP, key,
+			     error);
+}
+
+char *
+egg_desktop_file_get_string (EggDesktopFile  *desktop_file,
+			     const char      *key,
+			     GError         **error)
+{
+  return g_key_file_get_string (desktop_file->key_file,
+				EGG_DESKTOP_FILE_GROUP, key,
+				error);
+}
+
+char *
+egg_desktop_file_get_locale_string (EggDesktopFile  *desktop_file,
+				    const char      *key,
+				    const char      *locale,
+				    GError         **error)
+{
+  return g_key_file_get_locale_string (desktop_file->key_file,
+				       EGG_DESKTOP_FILE_GROUP, key, locale,
+				       error);
+}
+
+gboolean
+egg_desktop_file_get_boolean (EggDesktopFile  *desktop_file,
+			      const char      *key,
+			      GError         **error)
+{
+  return g_key_file_get_boolean (desktop_file->key_file,
+				 EGG_DESKTOP_FILE_GROUP, key,
+				 error);
+}
+
+double
+egg_desktop_file_get_numeric (EggDesktopFile  *desktop_file,
+			      const char      *key,
+			      GError         **error)
+{
+  return g_key_file_get_double (desktop_file->key_file,
+				EGG_DESKTOP_FILE_GROUP, key,
+				error);
+}
+
+int
+egg_desktop_file_get_integer (EggDesktopFile *desktop_file,
+                              const char		*key,
+                              GError		   **error)
+{
+  return g_key_file_get_integer (desktop_file->key_file,
+                                 EGG_DESKTOP_FILE_GROUP, key,
+                                 error);
+}
+
+char **
+egg_desktop_file_get_string_list (EggDesktopFile  *desktop_file,
+				  const char      *key,
+				  gsize           *length,
+				  GError         **error)
+{
+  return g_key_file_get_string_list (desktop_file->key_file,
+				     EGG_DESKTOP_FILE_GROUP, key, length,
+				     error);
+}
+
+char **
+egg_desktop_file_get_locale_string_list (EggDesktopFile  *desktop_file,
+					 const char      *key,
+					 const char      *locale,
+					 gsize           *length,
+					 GError         **error)
+{
+  return g_key_file_get_locale_string_list (desktop_file->key_file,
+					    EGG_DESKTOP_FILE_GROUP, key,
+					    locale, length,
+					    error);
+}
+
+/**
+ * egg_desktop_file_can_launch:
+ * @desktop_file: an #EggDesktopFile
+ * @desktop_environment: the name of the running desktop environment,
+ * or %NULL
+ *
+ * Tests if @desktop_file can/should be launched in the current
+ * environment. If @desktop_environment is non-%NULL, @desktop_file's
+ * "OnlyShowIn" and "NotShowIn" keys are checked to make sure that
+ * this desktop_file is appropriate for the named environment.
+ *
+ * Furthermore, if @desktop_file has type
+ * %EGG_DESKTOP_FILE_TYPE_APPLICATION, its "TryExec" key (if any) is
+ * also checked, to make sure the binary it points to exists.
+ *
+ * egg_desktop_file_can_launch() does NOT check the value of the
+ * "Hidden" key.
+ *
+ * Return value: %TRUE if @desktop_file can be launched
+ **/
+gboolean
+egg_desktop_file_can_launch (EggDesktopFile *desktop_file,
+			     const char     *desktop_environment)
+{
+  char *try_exec, *found_program;
+  char **only_show_in, **not_show_in;
+  gboolean found;
+  int i;
+
+  if (desktop_file->type != EGG_DESKTOP_FILE_TYPE_APPLICATION &&
+      desktop_file->type != EGG_DESKTOP_FILE_TYPE_LINK)
+    return FALSE;
+
+  if (desktop_environment)
+    {
+      only_show_in = g_key_file_get_string_list (desktop_file->key_file,
+						 EGG_DESKTOP_FILE_GROUP,
+						 EGG_DESKTOP_FILE_KEY_ONLY_SHOW_IN,
+						 NULL, NULL);
+      if (only_show_in)
+	{
+	  for (i = 0, found = FALSE; only_show_in[i] && !found; i++)
+	    {
+	      if (!strcmp (only_show_in[i], desktop_environment))
+		found = TRUE;
+	    }
+
+	  g_strfreev (only_show_in);
+
+	  if (!found)
+	    return FALSE;
+	}
+
+      not_show_in = g_key_file_get_string_list (desktop_file->key_file,
+						EGG_DESKTOP_FILE_GROUP,
+						EGG_DESKTOP_FILE_KEY_NOT_SHOW_IN,
+						NULL, NULL);
+      if (not_show_in)
+	{
+	  for (i = 0, found = FALSE; not_show_in[i] && !found; i++)
+	    {
+	      if (!strcmp (not_show_in[i], desktop_environment))
+		found = TRUE;
+	    }
+
+	  g_strfreev (not_show_in);
+
+	  if (found)
+	    return FALSE;
+	}
+    }
+
+  if (desktop_file->type == EGG_DESKTOP_FILE_TYPE_APPLICATION)
+    {
+      try_exec = g_key_file_get_string (desktop_file->key_file,
+					EGG_DESKTOP_FILE_GROUP,
+					EGG_DESKTOP_FILE_KEY_TRY_EXEC,
+					NULL);
+      if (try_exec)
+	{
+	  found_program = g_find_program_in_path (try_exec);
+	  g_free (try_exec);
+
+	  if (!found_program)
+	    return FALSE;
+	  g_free (found_program);
+	}
+    }
+
+  return TRUE;
+}
+
+/**
+ * egg_desktop_file_accepts_documents:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Tests if @desktop_file represents an application that can accept
+ * documents on the command line.
+ *
+ * Return value: %TRUE or %FALSE
+ **/
+gboolean
+egg_desktop_file_accepts_documents (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return desktop_file->document_code != 0;
+}
+
+/**
+ * egg_desktop_file_accepts_multiple:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Tests if @desktop_file can accept multiple documents at once.
+ *
+ * If this returns %FALSE, you can still pass multiple documents to
+ * egg_desktop_file_launch(), but that will result in multiple copies
+ * of the application being launched. See egg_desktop_file_launch()
+ * for more details.
+ *
+ * Return value: %TRUE or %FALSE
+ **/
+gboolean
+egg_desktop_file_accepts_multiple (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return (desktop_file->document_code == 'F' ||
+	  desktop_file->document_code == 'U');
+}
+
+/**
+ * egg_desktop_file_accepts_uris:
+ * @desktop_file: an #EggDesktopFile
+ *
+ * Tests if @desktop_file can accept (non-"file:") URIs as documents to
+ * open.
+ *
+ * Return value: %TRUE or %FALSE
+ **/
+gboolean
+egg_desktop_file_accepts_uris (EggDesktopFile *desktop_file)<--- Parameter 'desktop_file' can be declared as pointer to const
+{
+  return (desktop_file->document_code == 'U' ||
+	  desktop_file->document_code == 'u');
+}
+
+static void
+append_quoted_word (GString    *str,
+		    const char *s,
+		    gboolean    in_single_quotes,
+		    gboolean    in_double_quotes)
+{
+  const char *p;
+
+  if (!in_single_quotes && !in_double_quotes)
+    g_string_append_c (str, '\'');
+  else if (!in_single_quotes && in_double_quotes)
+    g_string_append (str, "\"'");
+
+  if (!strchr (s, '\''))
+    g_string_append (str, s);
+  else
+    {
+      for (p = s; *p != '\0'; p++)
+	{
+	  if (*p == '\'')
+	    g_string_append (str, "'\\''");
+	  else
+	    g_string_append_c (str, *p);
+	}
+    }
+
+  if (!in_single_quotes && !in_double_quotes)
+    g_string_append_c (str, '\'');
+  else if (!in_single_quotes && in_double_quotes)
+    g_string_append (str, "'\"");
+}
+
+static void
+do_percent_subst (EggDesktopFile *desktop_file,<--- Parameter 'desktop_file' can be declared as pointer to const
+		  char            code,
+		  GString        *str,
+		  GSList        **documents,
+		  gboolean        in_single_quotes,
+		  gboolean        in_double_quotes)
+{
+  GSList *d;
+  char *doc;<--- Variable 'doc' can be declared as pointer to const
+
+  switch (code)
+    {
+    case '%':
+      g_string_append_c (str, '%');
+      break;
+
+    case 'F':
+    case 'U':
+      for (d = *documents; d; d = d->next)
+	{
+	  doc = d->data;
+	  g_string_append (str, " ");
+	  append_quoted_word (str, doc, in_single_quotes, in_double_quotes);
+	}
+      *documents = NULL;
+      break;
+
+    case 'f':
+    case 'u':
+      if (*documents)
+	{
+	  doc = (*documents)->data;
+	  g_string_append (str, " ");
+	  append_quoted_word (str, doc, in_single_quotes, in_double_quotes);
+	  *documents = (*documents)->next;
+	}
+      break;
+
+    case 'i':
+      if (desktop_file->icon)
+	{
+	  g_string_append (str, "--icon ");
+	  append_quoted_word (str, desktop_file->icon,
+			      in_single_quotes, in_double_quotes);
+	}
+      break;
+
+    case 'c':
+      if (desktop_file->name)
+	{
+	  append_quoted_word (str, desktop_file->name,
+			      in_single_quotes, in_double_quotes);
+	}
+      break;
+
+    case 'k':
+      if (desktop_file->source)
+	{
+	  append_quoted_word (str, desktop_file->source,
+			      in_single_quotes, in_double_quotes);
+	}
+      break;
+
+    case 'D':
+    case 'N':
+    case 'd':
+    case 'n':
+    case 'v':
+    case 'm':
+      /* Deprecated; skip */
+      break;
+
+    default:
+      g_warning ("Unrecognized %%-code '%%%c' in Exec", code);
+      break;
+    }
+}
+
+static char *
+parse_exec (EggDesktopFile  *desktop_file,
+	    GSList         **documents,
+	    GError         **error)
+{
+  char *exec, *p, *command;
+  gboolean escape, single_quot, double_quot;
+  GString *gs;
+
+  exec = g_key_file_get_string (desktop_file->key_file,
+				EGG_DESKTOP_FILE_GROUP,
+				EGG_DESKTOP_FILE_KEY_EXEC,
+				error);
+  if (!exec)
+    return NULL;
+
+  /* Build the command */
+  gs = g_string_new (NULL);
+  escape = single_quot = double_quot = FALSE;
+
+  for (p = exec; *p != '\0'; p++)
+    {
+      if (escape)
+	{
+	  escape = FALSE;
+	  g_string_append_c (gs, *p);
+	}
+      else if (*p == '\\')
+	{
+	  if (!single_quot)
+	    escape = TRUE;
+	  g_string_append_c (gs, *p);
+	}
+      else if (*p == '\'')
+	{
+	  g_string_append_c (gs, *p);
+	  if (!single_quot && !double_quot)
+	    single_quot = TRUE;
+	  else if (single_quot)
+	    single_quot = FALSE;
+	}
+      else if (*p == '"')
+	{
+	  g_string_append_c (gs, *p);
+	  if (!single_quot && !double_quot)
+	    double_quot = TRUE;
+	  else if (double_quot)
+	    double_quot = FALSE;
+	}
+      else if (*p == '%' && p[1])
+	{
+	  do_percent_subst (desktop_file, p[1], gs, documents,
+			    single_quot, double_quot);
+	  p++;
+	}
+      else
+	g_string_append_c (gs, *p);
+    }
+
+  g_free (exec);
+  command = g_string_free (gs, FALSE);
+
+  /* Prepend "xdg-terminal " if needed (FIXME: use gvfs) */
+  if (g_key_file_has_key (desktop_file->key_file,
+			  EGG_DESKTOP_FILE_GROUP,
+			  EGG_DESKTOP_FILE_KEY_TERMINAL,
+			  NULL))
+    {
+      GError *terminal_error = NULL;
+      gboolean use_terminal =
+	g_key_file_get_boolean (desktop_file->key_file,
+				EGG_DESKTOP_FILE_GROUP,
+				EGG_DESKTOP_FILE_KEY_TERMINAL,
+				&terminal_error);
+      if (terminal_error)
+	{
+	  g_free (command);
+	  g_propagate_error (error, terminal_error);
+	  return NULL;
+	}
+
+      if (use_terminal)
+	{
+	  gs = g_string_new ("xdg-terminal ");
+	  append_quoted_word (gs, command, FALSE, FALSE);
+	  g_free (command);
+	  command = g_string_free (gs, FALSE);
+	}
+    }
+
+  return command;
+}
+
+static GSList *
+translate_document_list (EggDesktopFile *desktop_file, GSList *documents)
+{
+  gboolean accepts_uris = egg_desktop_file_accepts_uris (desktop_file);
+  GSList *ret, *d;
+
+  for (d = documents, ret = NULL; d; d = d->next)
+    {
+      const char *document = d->data;
+      gboolean is_uri = !g_path_is_absolute (document);
+      char *translated;
+
+      if (accepts_uris)
+	{
+	  if (is_uri)
+	    translated = g_strdup (document);
+	  else
+	    translated = g_filename_to_uri (document, NULL, NULL);
+	}
+      else
+	{
+	  if (is_uri)
+	    translated = g_filename_from_uri (document, NULL, NULL);
+	  else
+	    translated = g_strdup (document);
+	}
+
+      if (translated)
+	ret = g_slist_prepend (ret, translated);
+    }
+
+  return g_slist_reverse (ret);
+}
+
+static void
+free_document_list (GSList *documents)
+{
+  GSList *d;
+
+  for (d = documents; d; d = d->next)
+    g_free (d->data);
+  g_slist_free (documents);
+}
+
+/**
+ * egg_desktop_file_parse_exec:
+ * @desktop_file: a #EggDesktopFile
+ * @documents: a list of document paths or URIs
+ * @error: error pointer
+ *
+ * Parses @desktop_file's Exec key, inserting @documents into it, and
+ * returns the result.
+ *
+ * If @documents contains non-file: URIs and @desktop_file does not
+ * accept URIs, those URIs will be ignored. Likewise, if @documents
+ * contains more elements than @desktop_file accepts, the extra
+ * documents will be ignored.
+ *
+ * Return value: the parsed Exec string
+ **/
+char *
+egg_desktop_file_parse_exec (EggDesktopFile  *desktop_file,
+			     GSList          *documents,
+			     GError         **error)
+{
+  GSList *translated, *docs;
+  char *command;
+
+  docs = translated = translate_document_list (desktop_file, documents);
+  command = parse_exec (desktop_file, &docs, error);
+  free_document_list (translated);
+
+  return command;
+}
+
+static gboolean
+parse_link (EggDesktopFile  *desktop_file,
+	    EggDesktopFile **app_desktop_file,
+	    GSList         **documents,
+	    GError         **error)
+{
+  char *url;
+  GKeyFile *key_file;
+
+  url = g_key_file_get_string (desktop_file->key_file,
+			       EGG_DESKTOP_FILE_GROUP,
+			       EGG_DESKTOP_FILE_KEY_URL,
+			       error);
+  if (!url)
+    return FALSE;
+  *documents = g_slist_prepend (NULL, url);
+
+  /* FIXME: use gvfs */
+  key_file = g_key_file_new ();
+  g_key_file_set_string (key_file, EGG_DESKTOP_FILE_GROUP,
+			 EGG_DESKTOP_FILE_KEY_NAME,
+			 "xdg-open");
+  g_key_file_set_string (key_file, EGG_DESKTOP_FILE_GROUP,
+			 EGG_DESKTOP_FILE_KEY_TYPE,
+			 "Application");
+  g_key_file_set_string (key_file, EGG_DESKTOP_FILE_GROUP,
+			 EGG_DESKTOP_FILE_KEY_EXEC,
+			 "xdg-open %u");
+  *app_desktop_file = egg_desktop_file_new_from_key_file (key_file, NULL, NULL);
+  return TRUE;
+}
+
+#ifdef GDK_WINDOWING_X11
+static char *
+start_startup_notification (GdkDisplay     *display,
+			    EggDesktopFile *desktop_file,
+			    const char     *argv0,
+			    int             screen,
+			    int             workspace,
+			    guint32         launch_time)
+{
+  static int sequence = 0;
+  char *startup_id;
+  char *description, *wmclass;
+  char *screen_str, *workspace_str;
+
+  g_assert(GDK_IS_X11_DISPLAY (display));
+
+  if (g_key_file_has_key (desktop_file->key_file,
+			  EGG_DESKTOP_FILE_GROUP,
+			  EGG_DESKTOP_FILE_KEY_STARTUP_NOTIFY,
+			  NULL))
+    {
+      if (!g_key_file_get_boolean (desktop_file->key_file,
+				   EGG_DESKTOP_FILE_GROUP,
+				   EGG_DESKTOP_FILE_KEY_STARTUP_NOTIFY,
+				   NULL))
+	return NULL;
+      wmclass = NULL;
+    }
+  else
+    {
+      wmclass = g_key_file_get_string (desktop_file->key_file,
+				       EGG_DESKTOP_FILE_GROUP,
+				       EGG_DESKTOP_FILE_KEY_STARTUP_WM_CLASS,
+				       NULL);
+      if (!wmclass)
+	return NULL;
+    }
+
+  if (launch_time == (guint32)-1)
+    launch_time = gdk_x11_display_get_user_time (display);
+  startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu",
+				g_get_prgname (),
+				(unsigned long)getpid (),
+				g_get_host_name (),
+				argv0,
+				sequence++,
+				(unsigned long)launch_time);
+
+  description = g_strdup_printf (_("Starting %s"), desktop_file->name);
+  screen_str = g_strdup_printf ("%d", screen);
+  workspace_str = workspace == -1 ? NULL : g_strdup_printf ("%d", workspace);
+
+  gdk_x11_display_broadcast_startup_message (display, "new",
+					     "ID", startup_id,
+					     "NAME", desktop_file->name,
+					     "SCREEN", screen_str,
+					     "BIN", argv0,
+					     "ICON", desktop_file->icon,
+					     "DESKTOP", workspace_str,
+					     "DESCRIPTION", description,
+					     "WMCLASS", wmclass,
+					     NULL);
+
+  g_free (description);
+  g_free (wmclass);
+  g_free (screen_str);
+  g_free (workspace_str);
+
+  return startup_id;
+}
+
+static void
+end_startup_notification (GdkDisplay *display,
+			  const char *startup_id)
+{
+  gdk_x11_display_broadcast_startup_message (display, "remove",
+					     "ID", startup_id,
+					     NULL);
+}
+
+#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */)
+
+typedef struct {
+  GdkDisplay *display;
+  char *startup_id;
+} StartupNotificationData;
+
+static gboolean
+startup_notification_timeout (gpointer data)
+{
+  StartupNotificationData *sn_data = data;
+
+  end_startup_notification (sn_data->display, sn_data->startup_id);
+  g_object_unref (sn_data->display);
+  g_free (sn_data->startup_id);
+  g_free (sn_data);
+
+  return FALSE;
+}
+
+static void
+set_startup_notification_timeout (GdkDisplay *display,
+				  const char *startup_id)
+{
+  StartupNotificationData *sn_data;
+
+  sn_data = g_new (StartupNotificationData, 1);
+  sn_data->display = g_object_ref (display);
+  sn_data->startup_id = g_strdup (startup_id);
+
+  g_timeout_add_seconds (EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH,
+			 startup_notification_timeout, sn_data);
+}
+#endif // GDK_WINDOWING_X11
+
+static GPtrArray *
+array_putenv (GPtrArray *env, char *variable)
+{
+  guint i, keylen;
+
+  if (!env)
+    {
+      char **envp;
+
+      env = g_ptr_array_new ();
+
+      envp = g_listenv ();
+      for (i = 0; envp[i]; i++)
+        {
+          const char *value;
+
+          value = g_getenv (envp[i]);
+          g_ptr_array_add (env, g_strdup_printf ("%s=%s", envp[i],
+                                                 value ? value : ""));
+        }
+      g_strfreev (envp);
+    }
+
+  keylen = strcspn (variable, "=");
+
+  /* Remove old value of key */
+  for (i = 0; i < env->len; i++)
+    {
+      char *envvar = env->pdata[i];
+
+      if (!strncmp (envvar, variable, keylen) && envvar[keylen] == '=')
+	{
+	  g_free (envvar);
+	  g_ptr_array_remove_index_fast (env, i);
+	  break;
+	}
+    }
+
+  /* Add new value */
+  g_ptr_array_add (env, g_strdup (variable));
+
+  return env;
+}
+
+static gboolean
+egg_desktop_file_launchv (EggDesktopFile *desktop_file,
+			  GSList *documents, va_list args,
+			  GError **error)
+{
+  EggDesktopFileLaunchOption option;
+  GSList *translated_documents = NULL, *docs = NULL;
+  char *command, **argv;
+  int argc, i;
+  gboolean success, current_success;
+  GdkDisplay *display;
+  char *startup_id;
+
+  GPtrArray   *env = NULL;
+  char       **variables = NULL;
+  GdkScreen   *screen = NULL;
+  int          workspace = -1;
+  const char  *directory = NULL;
+  guint32      launch_time = (guint32)-1;
+  GSpawnFlags  flags = G_SPAWN_SEARCH_PATH;
+  GSpawnChildSetupFunc setup_func = NULL;
+  gpointer     setup_data = NULL;
+
+  GPid        *ret_pid = NULL;
+  int         *ret_stdin = NULL, *ret_stdout = NULL, *ret_stderr = NULL;
+  char       **ret_startup_id = NULL;
+
+  if (documents && desktop_file->document_code == 0)
+    {
+      g_set_error (error, EGG_DESKTOP_FILE_ERROR,
+		   EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
+		   _("Application does not accept documents on command line"));
+      return FALSE;
+    }
+
+  /* Read the options: technically it's incorrect for the caller to
+   * NULL-terminate the list of options (rather than 0-terminating
+   * it), but NULL-terminating lets us use G_GNUC_NULL_TERMINATED,
+   * it's more consistent with other glib/gtk methods, and it will
+   * work as long as sizeof (int) <= sizeof (NULL), and NULL is
+   * represented as 0. (Which is true everywhere we care about.)
+   */
+  while ((option = va_arg (args, EggDesktopFileLaunchOption)))
+    {
+      switch (option)
+	{
+	case EGG_DESKTOP_FILE_LAUNCH_CLEARENV:
+	  if (env)
+	    g_ptr_array_free (env, TRUE);
+	  env = g_ptr_array_new ();
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_PUTENV:
+	  variables = va_arg (args, char **);
+	  for (i = 0; variables[i]; i++)
+	    env = array_putenv (env, variables[i]);
+	  break;
+
+	case EGG_DESKTOP_FILE_LAUNCH_SCREEN:
+	  screen = va_arg (args, GdkScreen *);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_WORKSPACE:
+	  workspace = va_arg (args, int);
+	  break;
+
+	case EGG_DESKTOP_FILE_LAUNCH_DIRECTORY:
+	  directory = va_arg (args, const char *);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_TIME:
+	  launch_time = va_arg (args, guint32);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_FLAGS:
+	  flags |= va_arg (args, GSpawnFlags);
+	  /* Make sure they didn't set any flags that don't make sense. */
+	  flags &= ~G_SPAWN_FILE_AND_ARGV_ZERO;
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC:
+	  setup_func = va_arg (args, GSpawnChildSetupFunc);
+	  setup_data = va_arg (args, gpointer);
+	  break;
+
+	case EGG_DESKTOP_FILE_LAUNCH_RETURN_PID:
+	  ret_pid = va_arg (args, GPid *);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_RETURN_STDIN_PIPE:
+	  ret_stdin = va_arg (args, int *);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_RETURN_STDOUT_PIPE:
+	  ret_stdout = va_arg (args, int *);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_RETURN_STDERR_PIPE:
+	  ret_stderr = va_arg (args, int *);
+	  break;
+	case EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID:
+	  ret_startup_id = va_arg (args, char **);
+	  break;
+
+	default:
+	  g_set_error (error, EGG_DESKTOP_FILE_ERROR,
+		       EGG_DESKTOP_FILE_ERROR_UNRECOGNIZED_OPTION,
+		       _("Unrecognized launch option: %d"),
+		       GPOINTER_TO_INT (option));
+	  success = FALSE;
+	  goto out;
+	}
+    }
+
+  if (screen)
+    {
+      display = gdk_screen_get_display (screen);
+      char *display_name = g_strdup (gdk_display_get_name (display));
+      char *display_env = g_strdup_printf ("DISPLAY=%s", display_name);
+      env = array_putenv (env, display_env);
+      g_free (display_name);
+      g_free (display_env);
+    }
+  else
+    {
+      display = gdk_display_get_default ();
+      screen = gdk_display_get_default_screen (display);
+    }
+
+  translated_documents = translate_document_list (desktop_file, documents);
+  docs = translated_documents;
+
+  success = FALSE;
+
+  do
+    {
+      command = parse_exec (desktop_file, &docs, error);
+      if (!command)
+	goto out;
+
+      if (!g_shell_parse_argv (command, &argc, &argv, error))
+	{
+	  g_free (command);
+	  goto out;
+	}
+      g_free (command);
+
+      startup_id = NULL;
+
+#ifdef GDK_WINDOWING_X11
+      if (GDK_IS_X11_DISPLAY (display))
+        {
+	  int screen_num;
+
+	  screen_num = gdk_x11_screen_get_screen_number (screen);
+      startup_id = start_startup_notification (display, desktop_file,
+					       argv[0], screen_num,
+					       workspace, launch_time);
+      if (startup_id)
+	{
+	  char *startup_id_env = g_strdup_printf ("DESKTOP_STARTUP_ID=%s",
+						  startup_id);
+	  env = array_putenv (env, startup_id_env);
+	  g_free (startup_id_env);
+	}
+        }
+#else
+      // Suppress unused variable warnings when not compiling with X
+      (void)workspace;
+      (void)launch_time;
+#endif
+
+      if (env != NULL)
+	g_ptr_array_add (env, NULL);
+
+      current_success =
+	g_spawn_async_with_pipes (directory,
+				  argv,
+				  env ? (char **)(env->pdata) : NULL,
+				  flags,
+				  setup_func, setup_data,
+				  ret_pid,
+				  ret_stdin, ret_stdout, ret_stderr,
+				  error);
+      g_strfreev (argv);
+
+      if (startup_id)
+	{
+	  if (current_success)
+	    {
+#ifdef GDK_WINDOWING_X11
+	      if (GDK_IS_X11_DISPLAY (display))
+		{
+	      set_startup_notification_timeout (display, startup_id);
+		}
+#endif
+
+	      if (ret_startup_id)
+		*ret_startup_id = startup_id;
+	      else
+		g_free (startup_id);
+	    }
+	  else
+	    g_free (startup_id);
+	}
+      else if (ret_startup_id)
+	*ret_startup_id = NULL;
+
+      if (current_success)
+	{
+	  /* If we successfully launch any instances of the app, make
+	   * sure we return TRUE and don't set @error.
+	   */
+	  success = TRUE;
+	  error = NULL;
+
+	  /* Also, only set the output params on the first one */
+	  ret_pid = NULL;
+	  ret_stdin = ret_stdout = ret_stderr = NULL;
+	  ret_startup_id = NULL;
+	}
+    }
+  while (docs && current_success);
+
+ out:
+  if (env)
+    {
+      g_ptr_array_foreach (env, (GFunc)g_free, NULL);
+      g_ptr_array_free (env, TRUE);
+    }
+  free_document_list (translated_documents);
+
+  return success;
+}
+
+/**
+ * egg_desktop_file_launch:
+ * @desktop_file: an #EggDesktopFile
+ * @documents: a list of URIs or paths to documents to open
+ * @error: error pointer
+ * @...: additional options
+ *
+ * Launches @desktop_file with the given arguments. Additional options
+ * can be specified as follows:
+ *
+ *   %EGG_DESKTOP_FILE_LAUNCH_CLEARENV: (no arguments)
+ *       clears the environment in the child process
+ *   %EGG_DESKTOP_FILE_LAUNCH_PUTENV: (char **variables)
+ *       adds the NAME=VALUE strings in the given %NULL-terminated
+ *       array to the child process's environment
+ *   %EGG_DESKTOP_FILE_LAUNCH_SCREEN: (GdkScreen *screen)
+ *       causes the application to be launched on the given screen
+ *   %EGG_DESKTOP_FILE_LAUNCH_WORKSPACE: (int workspace)
+ *       causes the application to be launched on the given workspace
+ *   %EGG_DESKTOP_FILE_LAUNCH_DIRECTORY: (char *dir)
+ *       causes the application to be launched in the given directory
+ *   %EGG_DESKTOP_FILE_LAUNCH_TIME: (guint32 launch_time)
+ *       sets the "launch time" for the application. If the user
+ *       interacts with another window after @launch_time but before
+ *       the launched application creates its first window, the window
+ *       manager may choose to not give focus to the new application.
+ *       Passing 0 for @launch_time will explicitly request that the
+ *       application not receive focus.
+ *   %EGG_DESKTOP_FILE_LAUNCH_FLAGS (GSpawnFlags flags)
+ *       Sets additional #GSpawnFlags to use. See g_spawn_async() for
+ *       more details.
+ *   %EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC (GSpawnChildSetupFunc, gpointer)
+ *       Sets the child setup callback and the data to pass to it.
+ *       (See g_spawn_async() for more details.)
+ *
+ *   %EGG_DESKTOP_FILE_LAUNCH_RETURN_PID (GPid **pid)
+ *       On a successful launch, sets *@pid to the PID of the launched
+ *       application.
+ *   %EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID (char **startup_id)
+ *       On a successful launch, sets *@startup_id to the Startup
+ *       Notification "startup id" of the launched application.
+ *   %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDIN_PIPE (int *fd)
+ *       On a successful launch, sets *@fd to the file descriptor of
+ *       a pipe connected to the application's stdin.
+ *   %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDOUT_PIPE (int *fd)
+ *       On a successful launch, sets *@fd to the file descriptor of
+ *       a pipe connected to the application's stdout.
+ *   %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDERR_PIPE (int *fd)
+ *       On a successful launch, sets *@fd to the file descriptor of
+ *       a pipe connected to the application's stderr.
+ *
+ * The options should be terminated with a single %NULL.
+ *
+ * If @documents contains multiple documents, but
+ * egg_desktop_file_accepts_multiple() returns %FALSE for
+ * @desktop_file, then egg_desktop_file_launch() will actually launch
+ * multiple instances of the application. In that case, the return
+ * value (as well as any values passed via
+ * %EGG_DESKTOP_FILE_LAUNCH_RETURN_PID, etc) will only reflect the
+ * first instance of the application that was launched (but the
+ * %EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC will be called for each
+ * instance).
+ *
+ * Return value: %TRUE if the application was successfully launched.
+ **/
+gboolean
+egg_desktop_file_launch (EggDesktopFile *desktop_file,
+			 GSList *documents, GError **error,
+			 ...)
+{
+  va_list args;
+  gboolean success;
+  EggDesktopFile *app_desktop_file;
+
+  switch (desktop_file->type)
+    {
+    case EGG_DESKTOP_FILE_TYPE_APPLICATION:
+      va_start (args, error);
+      success = egg_desktop_file_launchv (desktop_file, documents,
+					  args, error);
+      va_end (args);
+      break;
+
+    case EGG_DESKTOP_FILE_TYPE_LINK:
+      if (documents)
+	{
+	  g_set_error (error, EGG_DESKTOP_FILE_ERROR,
+		       EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
+		       _("Can't pass document URIs to a 'Type=Link' desktop entry"));
+	  return FALSE;
+	}
+
+      if (!parse_link (desktop_file, &app_desktop_file, &documents, error))
+	return FALSE;
+
+      va_start (args, error);
+      success = egg_desktop_file_launchv (app_desktop_file, documents,
+					  args, error);
+      va_end (args);
+
+      egg_desktop_file_free (app_desktop_file);
+      free_document_list (documents);
+      break;
+
+    case EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED:
+    case EGG_DESKTOP_FILE_TYPE_DIRECTORY:
+    default:
+      g_set_error (error, EGG_DESKTOP_FILE_ERROR,
+		   EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE,
+		   _("Not a launchable item"));
+      success = FALSE;
+      break;
+    }
+
+  return success;
+}
+
+
+GQuark
+egg_desktop_file_error_quark (void)
+{
+  return g_quark_from_static_string ("egg-desktop_file-error-quark");
+}
+
+
+G_LOCK_DEFINE_STATIC (egg_desktop_file);
+static EggDesktopFile *egg_desktop_file;
+
+static void
+egg_set_desktop_file_internal (const char *desktop_file_path,
+                               gboolean set_defaults)
+{
+  GError *error = NULL;
+
+  G_LOCK (egg_desktop_file);
+  if (egg_desktop_file)
+    egg_desktop_file_free (egg_desktop_file);
+
+  egg_desktop_file = egg_desktop_file_new (desktop_file_path, &error);
+  if (error)
+    {
+      g_warning ("Could not load desktop file '%s': %s",
+		 desktop_file_path, error->message);
+      g_error_free (error);
+    }
+
+  if (set_defaults && egg_desktop_file != NULL) {
+    /* Set localized application name and default window icon */
+    if (egg_desktop_file->name)
+      g_set_application_name (egg_desktop_file->name);
+    if (egg_desktop_file->icon)
+      {
+        if (g_path_is_absolute (egg_desktop_file->icon))
+          gtk_window_set_default_icon_from_file (egg_desktop_file->icon, NULL);
+        else
+          gtk_window_set_default_icon_name (egg_desktop_file->icon);
+      }
+  }
+
+  G_UNLOCK (egg_desktop_file);
+}
+
+/**
+ * egg_set_desktop_file:
+ * @desktop_file_path: path to the application's desktop file
+ *
+ * Creates an #EggDesktopFile for the application from the data at
+ * @desktop_file_path. This will also call g_set_application_name()
+ * with the localized application name from the desktop file, and
+ * gtk_window_set_default_icon_name() or
+ * gtk_window_set_default_icon_from_file() with the application's
+ * icon. Other code may use additional information from the desktop
+ * file.
+ * See egg_set_desktop_file_without_defaults() for a variant of this
+ * function that does not set the application name and default window
+ * icon.
+ *
+ * Note that for thread safety reasons, this function can only
+ * be called once, and is mutually exclusive with calling
+ * egg_set_desktop_file_without_defaults().
+ **/
+void
+egg_set_desktop_file (const char *desktop_file_path)
+{
+  egg_set_desktop_file_internal (desktop_file_path, TRUE);
+}
+
+/**
+ * egg_set_desktop_file_without_defaults:
+ * @desktop_file_path: path to the application's desktop file
+ *
+ * Creates an #EggDesktopFile for the application from the data at
+ * @desktop_file_path.
+ * See egg_set_desktop_file() for a variant of this function that
+ * sets the application name and default window icon from the information
+ * in the desktop file.
+ *
+ * Note that for thread safety reasons, this function can only
+ * be called once, and is mutually exclusive with calling
+ * egg_set_desktop_file().
+ **/
+void
+egg_set_desktop_file_without_defaults (const char *desktop_file_path)
+{
+  egg_set_desktop_file_internal (desktop_file_path, FALSE);
+}
+
+/**
+ * egg_get_desktop_file:
+ *
+ * Gets the application's #EggDesktopFile, as set by
+ * egg_set_desktop_file().
+ *
+ * Return value: the #EggDesktopFile, or %NULL if it hasn't been set.
+ **/
+EggDesktopFile *
+egg_get_desktop_file (void)
+{
+  EggDesktopFile *retval;
+
+  G_LOCK (egg_desktop_file);
+  retval = egg_desktop_file;
+  G_UNLOCK (egg_desktop_file);
+
+  return retval;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/65.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/65.html new file mode 100644 index 0000000..eb7f1a4 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/65.html @@ -0,0 +1,3055 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
+1326
+1327
+1328
+1329
+1330
+1331
+1332
+1333
+1334
+1335
+1336
+1337
+1338
+1339
+1340
+1341
+1342
+1343
+1344
+1345
+1346
+1347
+1348
+1349
+1350
+1351
+1352
+1353
+1354
+1355
+1356
+1357
+1358
+1359
+1360
+1361
+1362
+1363
+1364
+1365
+1366
+1367
+1368
+1369
+1370
+1371
+1372
+1373
+1374
+1375
+1376
+1377
+1378
+1379
+1380
+1381
+1382
+1383
+1384
+1385
+1386
+1387
+1388
+1389
+1390
+1391
+1392
+1393
+1394
+1395
+1396
+1397
+1398
+1399
+1400
+1401
+1402
+1403
+1404
+1405
+1406
+1407
+1408
+1409
/*
+ * Copyright (C) 2007 Novell, Inc.
+ *
+ * Inspired by various other pieces of code including GsmClient (C)
+ * 2001 Havoc Pennington, MateClient (C) 1998 Carsten Schaar, and twm
+ * session code (C) 1998 The Open Group.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include "eggsmclient.h"
+#include "eggsmclient-private.h"
+
+#include "eggdesktopfile.h"
+
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/SM/SMlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#define EGG_TYPE_SM_CLIENT_XSMP            (egg_sm_client_xsmp_get_type ())
+#define EGG_SM_CLIENT_XSMP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP))
+#define EGG_SM_CLIENT_XSMP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass))
+#define EGG_IS_SM_CLIENT_XSMP(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_SM_CLIENT_XSMP))
+#define EGG_IS_SM_CLIENT_XSMP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_SM_CLIENT_XSMP))
+#define EGG_SM_CLIENT_XSMP_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMPClass))
+
+typedef struct _EggSMClientXSMP        EggSMClientXSMP;
+typedef struct _EggSMClientXSMPClass   EggSMClientXSMPClass;
+
+/* These mostly correspond to the similarly-named states in section
+ * 9.1 of the XSMP spec. Some of the states there aren't represented
+ * here, because we don't need them. SHUTDOWN_CANCELLED is slightly
+ * different from the spec; we use it when the client is IDLE after a
+ * ShutdownCancelled message, but the application is still interacting
+ * and doesn't know the shutdown has been cancelled yet.
+ */
+typedef enum
+{
+    XSMP_STATE_IDLE,
+    XSMP_STATE_SAVE_YOURSELF,
+    XSMP_STATE_INTERACT_REQUEST,
+    XSMP_STATE_INTERACT,
+    XSMP_STATE_SAVE_YOURSELF_DONE,
+    XSMP_STATE_SHUTDOWN_CANCELLED,
+    XSMP_STATE_CONNECTION_CLOSED
+} EggSMClientXSMPState;
+
+static const char *state_names[] =
+{
+    "idle",
+    "save-yourself",
+    "interact-request",
+    "interact",
+    "save-yourself-done",
+    "shutdown-cancelled",
+    "connection-closed"
+};
+
+#define EGG_SM_CLIENT_XSMP_STATE(xsmp) (state_names[(xsmp)->state])
+
+struct _EggSMClientXSMP
+{
+    EggSMClient parent;
+
+    SmcConn connection;
+    char *client_id;
+
+    EggSMClientXSMPState state;
+    char **restart_command;
+    gboolean set_restart_command;
+    int restart_style;
+	char **discard_command;
+	gboolean set_discard_command;
+
+    guint idle;
+
+    /* Current SaveYourself state */
+    guint expecting_initial_save_yourself : 1;
+    guint need_save_state : 1;
+    guint need_quit_requested : 1;
+    guint interact_errors : 1;
+    guint shutting_down : 1;
+
+    /* Todo list */
+    guint waiting_to_set_initial_properties : 1;
+    guint waiting_to_emit_quit : 1;
+    guint waiting_to_emit_quit_cancelled : 1;
+    guint waiting_to_save_myself : 1;
+
+};
+
+struct _EggSMClientXSMPClass
+{
+    EggSMClientClass parent_class;
+
+};
+
+static void     sm_client_xsmp_startup (EggSMClient *client,
+                                        const char  *client_id);
+static void     sm_client_xsmp_set_restart_command (EggSMClient  *client,
+        int           argc,
+        const char  **argv);
+static void     sm_client_xsmp_set_discard_command (EggSMClient  *client,
+        int           argc,
+        const char  **argv);
+static void     sm_client_xsmp_will_quit (EggSMClient *client,
+        gboolean     will_quit);
+static gboolean sm_client_xsmp_end_session (EggSMClient         *client,
+        EggSMClientEndStyle  style,
+        gboolean  request_confirmation);
+
+static void xsmp_save_yourself      (SmcConn   smc_conn,
+                                     SmPointer client_data,
+                                     int       save_style,
+                                     Bool      shutdown,
+                                     int       interact_style,
+                                     Bool      fast);
+static void xsmp_die                (SmcConn   smc_conn,
+                                     SmPointer client_data);
+static void xsmp_save_complete      (SmcConn   smc_conn,
+                                     SmPointer client_data);
+static void xsmp_shutdown_cancelled (SmcConn   smc_conn,
+                                     SmPointer client_data);
+static void xsmp_interact           (SmcConn   smc_conn,
+                                     SmPointer client_data);
+
+static SmProp *array_prop        (const char    *name,
+                                  ...);
+static SmProp *ptrarray_prop     (const char    *name,
+                                  GPtrArray     *values);
+static SmProp *string_prop       (const char    *name,
+                                  const char    *value);
+static SmProp *card8_prop        (const char    *name,
+                                  unsigned char  value);
+
+static void set_properties         (EggSMClientXSMP *xsmp, ...);
+static void delete_properties      (EggSMClientXSMP *xsmp, ...);
+
+static GPtrArray *generate_command (char       **restart_command,
+                                    const char  *client_id,
+                                    const char  *state_file);
+
+static void save_state            (EggSMClientXSMP *xsmp);
+static void do_save_yourself      (EggSMClientXSMP *xsmp);
+static void update_pending_events (EggSMClientXSMP *xsmp);
+
+static void     ice_init             (void);
+static gboolean process_ice_messages (IceConn       ice_conn);
+static void     smc_error_handler    (SmcConn       smc_conn,
+                                      Bool          swap,
+                                      int           offending_minor_opcode,
+                                      unsigned long offending_sequence,
+                                      int           error_class,
+                                      int           severity,
+                                      SmPointer     values);
+
+G_DEFINE_TYPE (EggSMClientXSMP, egg_sm_client_xsmp, EGG_TYPE_SM_CLIENT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
+
+static void
+egg_sm_client_xsmp_init (EggSMClientXSMP *xsmp)
+{
+    xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
+    xsmp->connection = NULL;
+    xsmp->restart_style = SmRestartIfRunning;
+}
+
+static void
+egg_sm_client_xsmp_class_init (EggSMClientXSMPClass *klass)
+{
+    EggSMClientClass *sm_client_class = EGG_SM_CLIENT_CLASS (klass);
+
+    sm_client_class->startup             = sm_client_xsmp_startup;
+    sm_client_class->set_restart_command = sm_client_xsmp_set_restart_command;
+	sm_client_class->set_discard_command = sm_client_xsmp_set_discard_command;
+    sm_client_class->will_quit           = sm_client_xsmp_will_quit;
+    sm_client_class->end_session         = sm_client_xsmp_end_session;
+}
+
+EggSMClient *
+egg_sm_client_xsmp_new (void)
+{
+    if (!g_getenv ("SESSION_MANAGER"))
+        return NULL;
+
+    return g_object_new (EGG_TYPE_SM_CLIENT_XSMP, NULL);
+}
+
+static gboolean
+sm_client_xsmp_set_initial_properties (gpointer user_data)
+{
+    EggSMClientXSMP *xsmp = user_data;
+    EggDesktopFile *desktop_file;
+    GPtrArray *clone, *restart;
+    char pid_str[64];
+
+    if (xsmp->idle)
+    {
+        g_source_remove (xsmp->idle);
+        xsmp->idle = 0;
+    }
+    xsmp->waiting_to_set_initial_properties = FALSE;
+
+    if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART)
+        xsmp->restart_style = SmRestartNever;
+
+    /* Parse info out of desktop file */
+    desktop_file = egg_get_desktop_file ();
+    if (desktop_file)
+    {
+        GError *err = NULL;
+        char **argv;
+        int argc;
+
+        if (xsmp->restart_style == SmRestartIfRunning)
+        {
+            if (egg_desktop_file_get_boolean (desktop_file,
+                                              "X-MATE-AutoRestart", NULL))
+                xsmp->restart_style = SmRestartImmediately;
+        }
+
+        if (!xsmp->set_restart_command)
+        {
+            char *cmdline;
+
+            cmdline = egg_desktop_file_parse_exec (desktop_file, NULL, &err);
+            if (cmdline && g_shell_parse_argv (cmdline, &argc, &argv, &err))
+            {
+                egg_sm_client_set_restart_command (EGG_SM_CLIENT (xsmp),
+                                                   argc, (const char **)argv);
+                g_strfreev (argv);
+            }
+            else
+            {
+                g_warning ("Could not parse Exec line in desktop file: %s",
+                           err->message);
+                g_error_free (err);
+            }
+            g_free (cmdline);
+        }
+    }
+
+    if (!xsmp->set_restart_command)
+        xsmp->restart_command = g_strsplit (g_get_prgname (), " ", -1);
+
+    clone = generate_command (xsmp->restart_command, NULL, NULL);
+    restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL);
+
+    g_debug ("Setting initial properties");
+
+    /* Program, CloneCommand, RestartCommand, and UserID are required.
+     * ProcessID isn't required, but the SM may be able to do something
+     * useful with it.
+     */
+    g_snprintf (pid_str, sizeof (pid_str), "%lu", (gulong) getpid ());
+    set_properties (xsmp,
+                    string_prop   (SmProgram, g_get_prgname ()),
+                    ptrarray_prop (SmCloneCommand, clone),
+                    ptrarray_prop (SmRestartCommand, restart),
+                    string_prop   (SmUserID, g_get_user_name ()),
+                    string_prop   (SmProcessID, pid_str),
+                    card8_prop    (SmRestartStyleHint, xsmp->restart_style),
+                    NULL);
+    g_ptr_array_free (clone, TRUE);
+    g_ptr_array_free (restart, TRUE);
+
+    if (desktop_file)
+    {
+        set_properties (xsmp,
+                        string_prop ("_GSM_DesktopFile", egg_desktop_file_get_source (desktop_file)),
+                        NULL);
+    }
+
+    update_pending_events (xsmp);
+    return FALSE;
+}
+
+/* This gets called from two different places: xsmp_die() (when the
+ * server asks us to disconnect) and process_ice_messages() (when the
+ * server disconnects unexpectedly).
+ */
+static void
+sm_client_xsmp_disconnect (EggSMClientXSMP *xsmp)
+{
+    SmcConn connection;
+
+    if (!xsmp->connection)
+        return;
+
+    g_debug ("Disconnecting");
+
+    connection = xsmp->connection;
+    xsmp->connection = NULL;
+    SmcCloseConnection (connection, 0, NULL);
+    xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
+
+    xsmp->waiting_to_save_myself = FALSE;
+    update_pending_events (xsmp);
+}
+
+static void
+sm_client_xsmp_startup (EggSMClient *client,
+                        const char  *client_id)
+{
+    EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+    SmcCallbacks callbacks;
+    char *ret_client_id;
+    char error_string_ret[256];
+
+    xsmp->client_id = g_strdup (client_id);
+
+    ice_init ();
+    SmcSetErrorHandler (smc_error_handler);
+
+    callbacks.save_yourself.callback      = xsmp_save_yourself;
+    callbacks.die.callback                = xsmp_die;
+    callbacks.save_complete.callback      = xsmp_save_complete;
+    callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled;
+
+    callbacks.save_yourself.client_data      = xsmp;
+    callbacks.die.client_data                = xsmp;
+    callbacks.save_complete.client_data      = xsmp;
+    callbacks.shutdown_cancelled.client_data = xsmp;
+
+    client_id = NULL;
+    error_string_ret[0] = '\0';
+    xsmp->connection =
+        SmcOpenConnection (NULL, xsmp, SmProtoMajor, SmProtoMinor,
+                           SmcSaveYourselfProcMask | SmcDieProcMask |
+                           SmcSaveCompleteProcMask |
+                           SmcShutdownCancelledProcMask,
+                           &callbacks,
+                           xsmp->client_id, &ret_client_id,
+                           sizeof (error_string_ret), error_string_ret);
+
+    if (!xsmp->connection)
+    {
+        g_warning ("Failed to connect to the session manager: %s\n",
+                   error_string_ret[0] ?
+                   error_string_ret : "no error message given");
+        xsmp->state = XSMP_STATE_CONNECTION_CLOSED;
+        return;
+    }
+
+    /* We expect a pointless initial SaveYourself if either (a) we
+     * didn't have an initial client ID, or (b) we DID have an initial
+     * client ID, but the server rejected it and gave us a new one.
+     */
+    if (!xsmp->client_id ||
+            (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0))
+        xsmp->expecting_initial_save_yourself = TRUE;
+
+    if (ret_client_id)
+    {
+        g_free (xsmp->client_id);
+        xsmp->client_id = g_strdup (ret_client_id);
+        free (ret_client_id);
+
+#ifdef GDK_WINDOWING_X11
+      if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+        gdk_x11_set_sm_client_id (xsmp->client_id);
+#endif
+
+        g_debug ("Got client ID \"%s\"", xsmp->client_id);
+    }
+
+    xsmp->state = XSMP_STATE_IDLE;
+
+    /* Do not set the initial properties until we reach the main loop,
+     * so that the application has a chance to call
+     * egg_set_desktop_file(). (This may also help the session manager
+     * have a better idea of when the application is fully up and
+     * running.)
+     */
+    xsmp->waiting_to_set_initial_properties = TRUE;
+    xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client);
+}
+
+static void
+sm_client_xsmp_set_restart_command (EggSMClient  *client,
+                                    int           argc,
+                                    const char  **argv)
+{
+    EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+    int i;
+
+    g_strfreev (xsmp->restart_command);
+
+    xsmp->restart_command = g_new (char *, argc + 1);
+    for (i = 0; i < argc; i++)
+        xsmp->restart_command[i] = g_strdup (argv[i]);
+    xsmp->restart_command[i] = NULL;
+
+    xsmp->set_restart_command = TRUE;
+}
+
+static void
+sm_client_xsmp_set_discard_command (EggSMClient  *client,
+                                    int           argc,
+                                    const char  **argv)
+{
+	EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+	int i;
+
+	g_strfreev (xsmp->discard_command);
+
+	xsmp->discard_command = g_new (char *, argc + 1);
+	for (i = 0; i < argc; i++)
+		xsmp->discard_command[i] = g_strdup (argv[i]);
+	xsmp->discard_command[i] = NULL;
+
+	xsmp->set_discard_command = TRUE;
+}
+
+static void
+sm_client_xsmp_will_quit (EggSMClient *client,
+                          gboolean     will_quit)
+{
+    EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+
+    if (xsmp->state == XSMP_STATE_CONNECTION_CLOSED)
+    {
+        /* The session manager has already exited! Schedule a quit
+         * signal.
+         */
+        xsmp->waiting_to_emit_quit = TRUE;
+        update_pending_events (xsmp);
+        return;
+    }
+    else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
+    {
+        /* We received a ShutdownCancelled message while the application
+         * was interacting; Schedule a quit_cancelled signal.
+         */
+        xsmp->waiting_to_emit_quit_cancelled = TRUE;
+        update_pending_events (xsmp);
+        return;
+    }
+
+    g_return_if_fail (xsmp->state == XSMP_STATE_INTERACT);
+
+    g_debug ("Sending InteractDone(%s)", will_quit ? "False" : "True");
+    SmcInteractDone (xsmp->connection, !will_quit);
+
+    if (will_quit && xsmp->need_save_state)
+        save_state (xsmp);
+
+    g_debug ("Sending SaveYourselfDone(%s)", will_quit ? "True" : "False");
+    SmcSaveYourselfDone (xsmp->connection, will_quit);
+    xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
+}
+
+static gboolean
+sm_client_xsmp_end_session (EggSMClient         *client,
+                            EggSMClientEndStyle  style,
+                            gboolean             request_confirmation)
+{
+    EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client;
+    int save_type;
+
+    /* To end the session via XSMP, we have to send a
+     * SaveYourselfRequest. We aren't allowed to do that if anything
+     * else is going on, but we don't want to expose this fact to the
+     * application. So we do our best to patch things up here...
+     *
+     * In the worst case, this method might block for some length of
+     * time in process_ice_messages, but the only time that code path is
+     * honestly likely to get hit is if the application tries to end the
+     * session as the very first thing it does, in which case it
+     * probably won't actually block anyway. It's not worth gunking up
+     * the API to try to deal nicely with the other 0.01% of cases where
+     * this happens.
+     */
+
+    while (xsmp->state != XSMP_STATE_IDLE ||
+            xsmp->expecting_initial_save_yourself)
+    {
+        /* If we're already shutting down, we don't need to do anything. */
+        if (xsmp->shutting_down)
+            return TRUE;
+
+        switch (xsmp->state)
+        {
+        case XSMP_STATE_CONNECTION_CLOSED:
+            return FALSE;
+
+        case XSMP_STATE_SAVE_YOURSELF:
+            /* Trying to log out from the save_state callback? Whatever.
+             * Abort the save_state.
+             */
+            SmcSaveYourselfDone (xsmp->connection, FALSE);
+            xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
+            break;
+
+        case XSMP_STATE_INTERACT_REQUEST:
+        case XSMP_STATE_INTERACT:
+        case XSMP_STATE_SHUTDOWN_CANCELLED:
+            /* Already in a shutdown-related state, just ignore
+             * the new shutdown request...
+             */
+            return TRUE;
+
+        case XSMP_STATE_IDLE:
+            if (xsmp->waiting_to_set_initial_properties)
+                sm_client_xsmp_set_initial_properties (xsmp);
+
+            if (!xsmp->expecting_initial_save_yourself)
+                break;
+            /* else fall through */
+
+        case XSMP_STATE_SAVE_YOURSELF_DONE:
+            /* We need to wait for some response from the server.*/
+            process_ice_messages (SmcGetIceConnection (xsmp->connection));
+            break;
+
+        default:
+            /* Hm... shouldn't happen */
+            return FALSE;
+        }
+    }
+
+    /* xfce4-session will do the wrong thing if we pass SmSaveGlobal and
+     * the user chooses to save the session. But mate-session will do
+     * the wrong thing if we pass SmSaveBoth and the user chooses NOT to
+     * save the session... Sigh.
+     */
+    if (!strcmp (SmcVendor (xsmp->connection), "xfce4-session"))
+        save_type = SmSaveBoth;
+    else
+        save_type = SmSaveGlobal;
+
+    g_debug ("Sending SaveYourselfRequest(SmSaveGlobal, Shutdown, SmInteractStyleAny, %sFast)", request_confirmation ? "!" : "");
+    SmcRequestSaveYourself (xsmp->connection,
+                            save_type,
+                            True, /* shutdown */
+                            SmInteractStyleAny,
+                            !request_confirmation, /* fast */
+                            True /* global */);
+    return TRUE;
+}
+
+static gboolean
+idle_do_pending_events (gpointer data)
+{
+    EggSMClientXSMP *xsmp = data;
+    EggSMClient *client = data;
+
+    xsmp->idle = 0;
+
+    if (xsmp->waiting_to_emit_quit)
+    {
+        xsmp->waiting_to_emit_quit = FALSE;
+        egg_sm_client_quit (client);
+        goto out;
+    }
+
+    if (xsmp->waiting_to_emit_quit_cancelled)
+    {
+        xsmp->waiting_to_emit_quit_cancelled = FALSE;
+        egg_sm_client_quit_cancelled (client);
+        xsmp->state = XSMP_STATE_IDLE;
+    }
+
+    if (xsmp->waiting_to_save_myself)
+    {
+        xsmp->waiting_to_save_myself = FALSE;
+        do_save_yourself (xsmp);
+    }
+
+out:
+    return FALSE;
+}
+
+static void
+update_pending_events (EggSMClientXSMP *xsmp)
+{
+    gboolean want_idle =
+        xsmp->waiting_to_emit_quit ||
+        xsmp->waiting_to_emit_quit_cancelled ||
+        xsmp->waiting_to_save_myself;
+
+    if (want_idle)
+    {
+        if (xsmp->idle == 0)
+            xsmp->idle = g_idle_add (idle_do_pending_events, xsmp);
+    }
+    else
+    {
+        if (xsmp->idle != 0)
+            g_source_remove (xsmp->idle);
+        xsmp->idle = 0;
+    }
+}
+
+static void
+fix_broken_state (EggSMClientXSMP *xsmp, const char *message,
+                  gboolean send_interact_done,
+                  gboolean send_save_yourself_done)
+{
+    g_warning ("Received XSMP %s message in state %s: client or server error",
+               message, EGG_SM_CLIENT_XSMP_STATE (xsmp));
+
+    /* Forget any pending SaveYourself plans we had */
+    xsmp->waiting_to_save_myself = FALSE;
+    update_pending_events (xsmp);
+
+    if (send_interact_done)
+        SmcInteractDone (xsmp->connection, False);
+    if (send_save_yourself_done)
+        SmcSaveYourselfDone (xsmp->connection, True);
+
+    xsmp->state = send_save_yourself_done ? XSMP_STATE_SAVE_YOURSELF_DONE : XSMP_STATE_IDLE;
+}
+
+/* SM callbacks */
+
+static void
+xsmp_save_yourself (SmcConn   smc_conn,
+                    SmPointer client_data,
+                    int       save_type,
+                    Bool      shutdown,
+                    int       interact_style,
+                    Bool      fast)
+{
+    EggSMClientXSMP *xsmp = client_data;
+    gboolean wants_quit_requested;
+
+    g_debug ("Received SaveYourself(%s, %s, %s, %s) in state %s",
+             save_type == SmSaveLocal ? "SmSaveLocal" :
+             save_type == SmSaveGlobal ? "SmSaveGlobal" : "SmSaveBoth",
+             shutdown ? "Shutdown" : "!Shutdown",
+             interact_style == SmInteractStyleAny ? "SmInteractStyleAny" :
+             interact_style == SmInteractStyleErrors ? "SmInteractStyleErrors" :
+             "SmInteractStyleNone", fast ? "Fast" : "!Fast",
+             EGG_SM_CLIENT_XSMP_STATE (xsmp));
+
+    if (xsmp->state != XSMP_STATE_IDLE &&
+            xsmp->state != XSMP_STATE_SHUTDOWN_CANCELLED)
+    {
+        fix_broken_state (xsmp, "SaveYourself", FALSE, TRUE);
+        return;
+    }
+
+    if (xsmp->waiting_to_set_initial_properties)
+        sm_client_xsmp_set_initial_properties (xsmp);
+
+    /* If this is the initial SaveYourself, ignore it; we've already set
+     * properties and there's no reason to actually save state too.
+     */
+    if (xsmp->expecting_initial_save_yourself)
+    {
+        xsmp->expecting_initial_save_yourself = FALSE;
+
+        if (save_type == SmSaveLocal &&
+                interact_style == SmInteractStyleNone &&
+                !shutdown && !fast)
+        {
+            g_debug ("Sending SaveYourselfDone(True) for initial SaveYourself");
+            SmcSaveYourselfDone (xsmp->connection, True);
+            /* As explained in the comment at the end of
+             * do_save_yourself(), SAVE_YOURSELF_DONE is the correct
+             * state here, not IDLE.
+             */
+            xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
+            return;
+        }
+        else
+            g_warning ("First SaveYourself was not the expected one!");
+    }
+
+    /* Even ignoring the "fast" flag completely, there are still 18
+     * different combinations of save_type, shutdown and interact_style.
+     * We interpret them as follows:
+     *
+     *   Type  Shutdown  Interact	 Interpretation
+     *     G      F       A/E/N  	 do nothing (1)
+     *     G      T         N    	 do nothing (1)*
+     *     G      T        A/E   	 quit_requested (2)
+     *    L/B     F       A/E/N  	 save_state (3)
+     *    L/B     T         N    	 save_state (3)*
+     *    L/B     T        A/E   	 quit_requested, then save_state (4)
+     *
+     *   1. Do nothing, because the SM asked us to do something
+     *      uninteresting (save open files, but then don't quit
+     *      afterward) or rude (save open files without asking the user
+     *      for confirmation).
+     *
+     *   2. Request interaction and then emit ::quit_requested. This
+     *      perhaps isn't quite correct for the SmInteractStyleErrors
+     *      case, but we don't care.
+     *
+     *   3. Emit ::save_state. The SmSaveBoth SaveYourselfs in these
+     *      rows essentially get demoted to SmSaveLocal, because their
+     *      Global halves correspond to "do nothing".
+     *
+     *   4. Request interaction, emit ::quit_requested, and then emit
+     *      ::save_state after interacting. This is the SmSaveBoth
+     *      equivalent of #2, but we also promote SmSaveLocal shutdown
+     *      SaveYourselfs to SmSaveBoth here, because we want to give
+     *      the user a chance to save open files before quitting.
+     *
+     * (* It would be nice if we could do something useful when the
+     * session manager sends a SaveYourself with shutdown True and
+     * SmInteractStyleNone. But we can't, so we just pretend it didn't
+     * even tell us it was shutting down. The docs for ::quit mention
+     * that it might not always be preceded by ::quit_requested.)
+     */
+
+    /* As an optimization, we don't actually request interaction and
+     * emit ::quit_requested if the application isn't listening to the
+     * signal.
+     */
+    wants_quit_requested = g_signal_has_handler_pending (xsmp, g_signal_lookup ("quit_requested", EGG_TYPE_SM_CLIENT), 0, FALSE);
+
+    xsmp->need_save_state     = (save_type != SmSaveGlobal);
+    xsmp->need_quit_requested = (shutdown && wants_quit_requested &&
+                                 interact_style != SmInteractStyleNone);
+    xsmp->interact_errors     = (interact_style == SmInteractStyleErrors);
+
+    xsmp->shutting_down       = shutdown;
+
+    do_save_yourself (xsmp);
+}
+
+static void
+do_save_yourself (EggSMClientXSMP *xsmp)
+{
+    if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
+    {
+        /* The SM cancelled a previous SaveYourself, but we haven't yet
+         * had a chance to tell the application, so we can't start
+         * processing this SaveYourself yet.
+         */
+        xsmp->waiting_to_save_myself = TRUE;
+        update_pending_events (xsmp);
+        return;
+    }
+
+    if (xsmp->need_quit_requested)
+    {
+        xsmp->state = XSMP_STATE_INTERACT_REQUEST;
+
+        g_debug ("Sending InteractRequest(%s)",
+                 xsmp->interact_errors ? "Error" : "Normal");
+        SmcInteractRequest (xsmp->connection,
+                            xsmp->interact_errors ? SmDialogError : SmDialogNormal,
+                            xsmp_interact,
+                            xsmp);
+        return;
+    }
+
+    if (xsmp->need_save_state)
+    {
+        save_state (xsmp);
+
+        /* Though unlikely, the client could have been disconnected
+         * while the application was saving its state.
+         */
+        if (!xsmp->connection)
+            return;
+    }
+
+    g_debug ("Sending SaveYourselfDone(True)");
+    SmcSaveYourselfDone (xsmp->connection, True);
+
+    /* The client state diagram in the XSMP spec says that after a
+     * non-shutdown SaveYourself, we go directly back to "idle". But
+     * everything else in both the XSMP spec and the libSM docs
+     * disagrees.
+     */
+    xsmp->state = XSMP_STATE_SAVE_YOURSELF_DONE;
+}
+
+static void
+save_state (EggSMClientXSMP *xsmp)
+{
+    GKeyFile *state_file;
+    char *state_file_path, *data;
+    EggDesktopFile *desktop_file;
+	GPtrArray *restart, *discard;
+    int offset, fd;
+
+    /* We set xsmp->state before emitting save_state, but our caller is
+     * responsible for setting it back afterward.
+     */
+    xsmp->state = XSMP_STATE_SAVE_YOURSELF;
+
+    state_file = egg_sm_client_save_state ((EggSMClient *)xsmp);
+    if (!state_file)
+    {
+        restart = generate_command (xsmp->restart_command, xsmp->client_id, NULL);
+        set_properties (xsmp,
+                        ptrarray_prop (SmRestartCommand, restart),
+                        NULL);
+        g_ptr_array_free (restart, TRUE);
+
+		if (xsmp->set_discard_command)
+		{
+			discard = generate_command (xsmp->discard_command, NULL, NULL);
+			set_properties (xsmp,
+			                ptrarray_prop (SmDiscardCommand, discard),
+			                NULL);
+			g_ptr_array_free (discard, TRUE);
+		}
+		else
+        delete_properties (xsmp, SmDiscardCommand, NULL);
+
+        return;
+    }
+
+    desktop_file = egg_get_desktop_file ();
+    if (desktop_file)
+    {
+        GKeyFile *merged_file;
+        char *desktop_file_path;
+
+        merged_file = g_key_file_new ();
+        desktop_file_path =
+            g_filename_from_uri (egg_desktop_file_get_source (desktop_file),
+                                 NULL, NULL);
+        if (desktop_file_path &&
+                g_key_file_load_from_file (merged_file, desktop_file_path,
+                                           G_KEY_FILE_KEEP_COMMENTS |
+                                           G_KEY_FILE_KEEP_TRANSLATIONS, NULL))
+        {
+            guint g, k, i;
+            char **groups, **keys, *value, *exec;
+
+            groups = g_key_file_get_groups (state_file, NULL);
+            for (g = 0; groups[g]; g++)
+            {
+                keys = g_key_file_get_keys (state_file, groups[g], NULL, NULL);
+                for (k = 0; keys[k]; k++)
+                {
+                    value = g_key_file_get_value (state_file, groups[g],
+                                                  keys[k], NULL);
+                    if (value)
+                    {
+                        g_key_file_set_value (merged_file, groups[g],
+                                              keys[k], value);
+                        g_free (value);
+                    }
+                }
+                g_strfreev (keys);
+            }
+            g_strfreev (groups);
+
+            g_key_file_free (state_file);
+            state_file = merged_file;
+
+            /* Update Exec key using "--sm-client-state-file %k" */
+            restart = generate_command (xsmp->restart_command,
+                                        NULL, "%k");
+            for (i = 0; i < restart->len; i++)
+                restart->pdata[i] = g_shell_quote (restart->pdata[i]);
+            g_ptr_array_add (restart, NULL);
+            exec = g_strjoinv (" ", (char **)restart->pdata);
+            g_strfreev ((char **)restart->pdata);
+            g_ptr_array_free (restart, FALSE);
+
+            g_key_file_set_string (state_file, EGG_DESKTOP_FILE_GROUP,
+                                   EGG_DESKTOP_FILE_KEY_EXEC,
+                                   exec);
+            g_free (exec);
+        }
+        else
+            desktop_file = NULL;
+
+        g_free (desktop_file_path);
+    }
+
+    /* Now write state_file to disk. (We can't use mktemp(), because
+     * that requires the filename to end with "XXXXXX", and we want
+     * it to end with ".desktop".)
+     */
+
+    data = g_key_file_to_data (state_file, NULL, NULL);
+    g_key_file_free (state_file);
+
+    offset = 0;
+    while (1)
+    {
+        state_file_path = g_strdup_printf ("%s%csession-state%c%s-%ld.%s",
+                                           g_get_user_config_dir (),
+                                           G_DIR_SEPARATOR, G_DIR_SEPARATOR,
+                                           g_get_prgname (),
+                                           (long)time (NULL) + offset,
+                                           desktop_file ? "desktop" : "state");
+
+        fd = open (state_file_path, O_WRONLY | O_CREAT | O_EXCL, 0644);
+        if (fd == -1)
+        {
+            if (errno == EEXIST)
+            {
+                offset++;
+                g_free (state_file_path);
+                continue;
+            }
+            else if (errno == ENOTDIR || errno == ENOENT)
+            {
+                char *sep = strrchr (state_file_path, G_DIR_SEPARATOR);
+
+                *sep = '\0';
+                if (g_mkdir_with_parents (state_file_path, 0755) != 0)
+                {
+                    g_warning ("Could not create directory '%s'",
+                               state_file_path);
+                    g_free (state_file_path);
+                    state_file_path = NULL;
+                    break;
+                }
+
+                continue;
+            }
+
+            g_warning ("Could not create file '%s': %s",
+                       state_file_path, g_strerror (errno));
+            g_free (state_file_path);
+            state_file_path = NULL;
+            break;
+        }
+
+        close (fd);
+        g_file_set_contents (state_file_path, data, -1, NULL);
+        break;
+    }
+    g_free (data);
+
+    restart = generate_command (xsmp->restart_command, xsmp->client_id,
+                                state_file_path);
+    set_properties (xsmp,
+                    ptrarray_prop (SmRestartCommand, restart),
+                    NULL);
+    g_ptr_array_free (restart, TRUE);
+
+    if (state_file_path)
+    {
+        set_properties (xsmp,
+                        array_prop (SmDiscardCommand,
+                                    "/bin/rm", "-rf", state_file_path,
+                                    NULL),
+                        NULL);
+        g_free (state_file_path);
+    }
+}
+
+static void
+xsmp_interact (SmcConn   smc_conn,
+               SmPointer client_data)
+{
+    EggSMClientXSMP *xsmp = client_data;
+    EggSMClient *client = client_data;
+
+    g_debug ("Received Interact message in state %s",
+             EGG_SM_CLIENT_XSMP_STATE (xsmp));
+
+    if (xsmp->state != XSMP_STATE_INTERACT_REQUEST)
+    {
+        fix_broken_state (xsmp, "Interact", TRUE, TRUE);
+        return;
+    }
+
+    xsmp->state = XSMP_STATE_INTERACT;
+    egg_sm_client_quit_requested (client);
+}
+
+static void
+xsmp_die (SmcConn   smc_conn,
+          SmPointer client_data)
+{
+    EggSMClientXSMP *xsmp = client_data;
+    EggSMClient *client = client_data;
+
+    g_debug ("Received Die message in state %s",
+             EGG_SM_CLIENT_XSMP_STATE (xsmp));
+
+    sm_client_xsmp_disconnect (xsmp);
+    egg_sm_client_quit (client);
+}
+
+static void
+xsmp_save_complete (SmcConn   smc_conn,
+                    SmPointer client_data)
+{
+    EggSMClientXSMP *xsmp = client_data;
+
+    g_debug ("Received SaveComplete message in state %s",
+             EGG_SM_CLIENT_XSMP_STATE (xsmp));
+
+    if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
+        xsmp->state = XSMP_STATE_IDLE;
+    else
+        fix_broken_state (xsmp, "SaveComplete", FALSE, FALSE);
+}
+
+static void
+xsmp_shutdown_cancelled (SmcConn   smc_conn,
+                         SmPointer client_data)
+{
+    EggSMClientXSMP *xsmp = client_data;
+    EggSMClient *client = client_data;
+
+    g_debug ("Received ShutdownCancelled message in state %s",
+             EGG_SM_CLIENT_XSMP_STATE (xsmp));
+
+    xsmp->shutting_down = FALSE;
+
+    if (xsmp->state == XSMP_STATE_SAVE_YOURSELF_DONE)
+    {
+        /* We've finished interacting and now the SM has agreed to
+         * cancel the shutdown.
+         */
+        xsmp->state = XSMP_STATE_IDLE;
+        egg_sm_client_quit_cancelled (client);
+    }
+    else if (xsmp->state == XSMP_STATE_SHUTDOWN_CANCELLED)
+    {
+        /* Hm... ok, so we got a shutdown SaveYourself, which got
+         * cancelled, but the application was still interacting, so we
+         * didn't tell it yet, and then *another* SaveYourself arrived,
+         * which we must still be waiting to tell the app about, except
+         * that now that SaveYourself has been cancelled too! Dizzy yet?
+         */
+        xsmp->waiting_to_save_myself = FALSE;
+        update_pending_events (xsmp);
+    }
+    else
+    {
+        g_debug ("Sending SaveYourselfDone(False)");
+        SmcSaveYourselfDone (xsmp->connection, False);
+
+        if (xsmp->state == XSMP_STATE_INTERACT)
+        {
+            /* The application is currently interacting, so we can't
+             * tell it about the cancellation yet; we will wait until
+             * after it calls egg_sm_client_will_quit().
+             */
+            xsmp->state = XSMP_STATE_SHUTDOWN_CANCELLED;
+        }
+        else
+        {
+            /* The shutdown was cancelled before the application got a
+             * chance to interact.
+             */
+            xsmp->state = XSMP_STATE_IDLE;
+        }
+    }
+}
+
+/* Utilities */
+
+/* Create a restart/clone/Exec command based on @restart_command.
+ * If @client_id is non-%NULL, add "--sm-client-id @client_id".
+ * If @state_file is non-%NULL, add "--sm-client-state-file @state_file".
+ *
+ * None of the input strings are g_strdup()ed; the caller must keep
+ * them around until it is done with the returned GPtrArray, and must
+ * then free the array, but not its contents.
+ */
+static GPtrArray *
+generate_command (char **restart_command, const char *client_id,
+                  const char *state_file)
+{
+    GPtrArray *cmd;
+    int i;
+
+    cmd = g_ptr_array_new ();
+    g_ptr_array_add (cmd, restart_command[0]);
+
+    if (client_id)
+    {
+        g_ptr_array_add (cmd, (char *)"--sm-client-id");
+        g_ptr_array_add (cmd, (char *)client_id);
+    }
+
+    if (state_file)
+    {
+        g_ptr_array_add (cmd, (char *)"--sm-client-state-file");
+        g_ptr_array_add (cmd, (char *)state_file);
+    }
+
+    for (i = 1; restart_command[i]; i++)
+        g_ptr_array_add (cmd, restart_command[i]);
+
+    return cmd;
+}
+
+/* Takes a NULL-terminated list of SmProp * values, created by
+ * array_prop, ptrarray_prop, string_prop, card8_prop, sets them, and
+ * frees them.
+ */
+static void
+set_properties (EggSMClientXSMP *xsmp, ...)
+{
+    GPtrArray *props;
+    SmProp *prop;
+    va_list ap;
+    guint i;
+
+    props = g_ptr_array_new ();
+
+    va_start (ap, xsmp);
+    while ((prop = va_arg (ap, SmProp *)))
+        g_ptr_array_add (props, prop);
+    va_end (ap);
+
+    if (xsmp->connection)
+    {
+        SmcSetProperties (xsmp->connection, props->len,
+                          (SmProp **)props->pdata);
+    }
+
+    for (i = 0; i < props->len; i++)
+    {
+        prop = props->pdata[i];
+        g_free (prop->vals);
+        g_free (prop);
+    }
+    g_ptr_array_free (props, TRUE);
+}
+
+/* Takes a NULL-terminated list of property names and deletes them. */
+static void
+delete_properties (EggSMClientXSMP *xsmp, ...)
+{
+    GPtrArray *props;
+    char *prop;
+    va_list ap;
+
+    if (!xsmp->connection)
+        return;
+
+    props = g_ptr_array_new ();
+
+    va_start (ap, xsmp);
+    while ((prop = va_arg (ap, char *)))
+        g_ptr_array_add (props, prop);
+    va_end (ap);
+
+    SmcDeleteProperties (xsmp->connection, props->len,
+                         (char **)props->pdata);
+
+    g_ptr_array_free (props, TRUE);
+}
+
+/* Takes an array of strings and creates a LISTofARRAY8 property. The
+ * strings are neither dupped nor freed; they need to remain valid
+ * until you're done with the SmProp.
+ */
+static SmProp *
+array_prop (const char *name, ...)
+{
+    SmProp *prop;
+    SmPropValue pv;
+    GArray *vals;
+    char *value;
+    va_list ap;
+
+    prop = g_new (SmProp, 1);
+    prop->name = (char *)name;
+    prop->type = (char *)SmLISTofARRAY8;
+
+    vals = g_array_new (FALSE, FALSE, sizeof (SmPropValue));
+
+    va_start (ap, name);
+    while ((value = va_arg (ap, char *)))
+    {
+        pv.length = strlen (value);
+        pv.value = value;
+        g_array_append_val (vals, pv);
+    }
+    va_end (ap);
+
+    prop->num_vals = vals->len;
+    prop->vals = (SmPropValue *)vals->data;
+
+    g_array_free (vals, FALSE);
+
+    return prop;
+}
+
+/* Takes a GPtrArray of strings and creates a LISTofARRAY8 property.
+ * The array contents are neither dupped nor freed; they need to
+ * remain valid until you're done with the SmProp.
+ */
+static SmProp *
+ptrarray_prop (const char *name, GPtrArray *values)
+{
+    SmProp *prop;
+    SmPropValue pv;
+    GArray *vals;
+    guint i;
+
+    prop = g_new (SmProp, 1);
+    prop->name = (char *)name;
+    prop->type = (char *)SmLISTofARRAY8;
+
+    vals = g_array_new (FALSE, FALSE, sizeof (SmPropValue));
+
+    for (i = 0; i < values->len; i++)
+    {
+        pv.length = strlen (values->pdata[i]);
+        pv.value = values->pdata[i];
+        g_array_append_val (vals, pv);
+    }
+
+    prop->num_vals = vals->len;
+    prop->vals = (SmPropValue *)vals->data;
+
+    g_array_free (vals, FALSE);
+
+    return prop;
+}
+
+/* Takes a string and creates an ARRAY8 property. The string is
+ * neither dupped nor freed; it needs to remain valid until you're
+ * done with the SmProp.
+ */
+static SmProp *
+string_prop (const char *name, const char *value)
+{
+    SmProp *prop;
+
+    prop = g_new (SmProp, 1);
+    prop->name = (char *)name;
+    prop->type = (char *)SmARRAY8;
+
+    prop->num_vals = 1;
+    prop->vals = g_new (SmPropValue, 1);
+
+    prop->vals[0].length = strlen (value);
+    prop->vals[0].value = (char *)value;
+
+    return prop;
+}
+
+/* Takes a char and creates a CARD8 property. */
+static SmProp *
+card8_prop (const char *name, unsigned char value)
+{
+    SmProp *prop;
+    char *card8val;
+
+    /* To avoid having to allocate and free prop->vals[0], we cheat and
+     * make vals a 2-element-long array and then use the second element
+     * to store value.
+     */
+
+    prop = g_new (SmProp, 1);
+    prop->name = (char *)name;
+    prop->type = (char *)SmCARD8;
+
+    prop->num_vals = 1;
+    prop->vals = g_new (SmPropValue, 2);
+    card8val = (char *)(&prop->vals[1]);
+    card8val[0] = value;
+
+    prop->vals[0].length = 1;
+    prop->vals[0].value = card8val;
+
+    return prop;
+}
+
+/* ICE code. This makes no effort to play nice with anyone else trying
+ * to use libICE. Fortunately, no one uses libICE for anything other
+ * than SM. (DCOP uses ICE, but it has its own private copy of
+ * libICE.)
+ *
+ * When this moves to gtk, it will need to be cleverer, to avoid
+ * tripping over old apps that use MateClient or that use libSM
+ * directly.
+ */
+
+#include <X11/ICE/ICElib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+static void        ice_error_handler    (IceConn        ice_conn,
+        Bool           swap,
+        int            offending_minor_opcode,
+        unsigned long  offending_sequence,
+        int            error_class,
+        int            severity,
+        IcePointer     values);
+static void        ice_io_error_handler (IceConn        ice_conn);
+static void        ice_connection_watch (IceConn        ice_conn,
+        IcePointer     client_data,
+        Bool           opening,
+        IcePointer    *watch_data);
+
+static void
+ice_init (void)
+{
+    IceSetIOErrorHandler (ice_io_error_handler);
+    IceSetErrorHandler (ice_error_handler);
+    IceAddConnectionWatch (ice_connection_watch, NULL);
+}
+
+static gboolean
+process_ice_messages (IceConn ice_conn)
+{
+    IceProcessMessagesStatus status;
+    status = IceProcessMessages (ice_conn, NULL, NULL);
+
+    switch (status)
+    {
+    case IceProcessMessagesSuccess:
+        return TRUE;
+
+    case IceProcessMessagesIOError:
+        sm_client_xsmp_disconnect (IceGetConnectionContext (ice_conn));
+        return FALSE;
+
+    case IceProcessMessagesConnectionClosed:
+        return FALSE;
+
+    default:
+        g_assert_not_reached ();
+    }
+}
+
+static gboolean
+ice_iochannel_watch (GIOChannel   *channel,
+                     GIOCondition  condition,
+                     gpointer      client_data)
+{
+    return process_ice_messages (client_data);
+}
+
+static void
+ice_connection_watch (IceConn     ice_conn,
+                      IcePointer  client_data,
+                      Bool        opening,
+                      IcePointer *watch_data)
+{
+    guint watch_id;
+
+    if (opening)
+    {
+        GIOChannel *channel;
+        int fd = IceConnectionNumber (ice_conn);
+
+        fcntl (fd, F_SETFD, fcntl (fd, F_GETFD, 0) | FD_CLOEXEC);
+        channel = g_io_channel_unix_new (fd);
+        watch_id = g_io_add_watch (channel, G_IO_IN | G_IO_ERR,
+                                   ice_iochannel_watch, ice_conn);
+        g_io_channel_unref (channel);
+
+        *watch_data = GUINT_TO_POINTER (watch_id);
+    }
+    else
+    {
+        watch_id = GPOINTER_TO_UINT (*watch_data);
+        g_source_remove (watch_id);
+    }
+}
+
+static void
+ice_error_handler (IceConn       ice_conn,
+                   Bool          swap,
+                   int           offending_minor_opcode,
+                   unsigned long offending_sequence,
+                   int           error_class,
+                   int           severity,
+                   IcePointer    values)
+{
+    /* Do nothing */
+}
+
+static void
+ice_io_error_handler (IceConn ice_conn)
+{
+    /* Do nothing */
+}
+
+static void
+smc_error_handler (SmcConn       smc_conn,
+                   Bool          swap,
+                   int           offending_minor_opcode,
+                   unsigned long offending_sequence,
+                   int           error_class,
+                   int           severity,
+                   SmPointer     values)
+{
+    /* Do nothing */
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/66.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/66.html new file mode 100644 index 0000000..57bf969 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/66.html @@ -0,0 +1,453 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
/* eggsmclient.h
+ * Copyright (C) 2007 Novell, 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 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, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __EGG_SM_CLIENT_H__
+#define __EGG_SM_CLIENT_H__
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_SM_CLIENT            (egg_sm_client_get_type ())
+G_DECLARE_DERIVABLE_TYPE (EggSMClient, egg_sm_client, EGG, SM_CLIENT, GObject)
+
+typedef enum
+{
+    EGG_SM_CLIENT_END_SESSION_DEFAULT,
+    EGG_SM_CLIENT_LOGOUT,
+    EGG_SM_CLIENT_REBOOT,
+    EGG_SM_CLIENT_SHUTDOWN
+} EggSMClientEndStyle;
+
+typedef enum
+{
+    EGG_SM_CLIENT_MODE_DISABLED,
+    EGG_SM_CLIENT_MODE_NO_RESTART,
+    EGG_SM_CLIENT_MODE_NORMAL
+} EggSMClientMode;
+
+struct _EggSMClientClass
+{
+    GObjectClass parent_class;
+
+    /* signals */
+    void (*save_state)       (EggSMClient *client,
+                              GKeyFile    *state_file);
+
+    void (*quit_requested)   (EggSMClient *client);
+    void (*quit_cancelled)   (EggSMClient *client);
+    void (*quit)             (EggSMClient *client);
+
+    /* virtual methods */
+    void (*startup)             (EggSMClient          *client,
+                                 const char           *client_id);
+    void (*set_restart_command) (EggSMClient          *client,
+                                 int                   argc,
+                                 const char          **argv);
+	void (*set_discard_command) (EggSMClient          *client,
+                                 int                   argc,
+                                 const char          **argv);
+    void (*will_quit)           (EggSMClient          *client,
+                                 gboolean              will_quit);
+    gboolean (*end_session)     (EggSMClient          *client,
+                                 EggSMClientEndStyle   style,
+                                 gboolean              request_confirmation);
+
+    /* Padding for future expansion */
+    void (*_egg_reserved1) (void);
+    void (*_egg_reserved2) (void);
+    void (*_egg_reserved3) (void);
+    void (*_egg_reserved4) (void);
+};
+
+GOptionGroup    *egg_sm_client_get_option_group    (void);
+
+/* Initialization */
+void             egg_sm_client_set_mode            (EggSMClientMode mode);
+EggSMClientMode  egg_sm_client_get_mode            (void);
+EggSMClient     *egg_sm_client_get                 (void);
+
+/* Resuming a saved session */
+gboolean         egg_sm_client_is_resumed          (EggSMClient *client);
+GKeyFile        *egg_sm_client_get_state_file      (EggSMClient *client);
+
+/* Alternate means of saving state */
+void             egg_sm_client_set_restart_command (EggSMClient  *client,
+                                                    int           argc,
+                                                    const char  **argv);
+void             egg_sm_client_set_discard_command (EggSMClient  *client,
+                                                    int           argc,
+                                                    const char  **argv);
+
+/* Handling "quit_requested" signal */
+void             egg_sm_client_will_quit           (EggSMClient *client,
+                                                    gboolean     will_quit);
+
+/* Initiate a logout/reboot/shutdown */
+gboolean         egg_sm_client_end_session         (EggSMClientEndStyle  style,
+                                                    gboolean             request_confirmation);
+
+G_END_DECLS
+
+#endif /* __EGG_SM_CLIENT_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/67.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/67.html new file mode 100644 index 0000000..053c2a2 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/67.html @@ -0,0 +1,327 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* eggsmclient-private.h
+ * Copyright (C) 2007 Novell, 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 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, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __EGG_SM_CLIENT_PRIVATE_H__
+#define __EGG_SM_CLIENT_PRIVATE_H__
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "eggsmclient.h"
+
+G_BEGIN_DECLS
+
+GKeyFile *egg_sm_client_save_state     (EggSMClient *client);
+void      egg_sm_client_quit_requested (EggSMClient *client);
+void      egg_sm_client_quit_cancelled (EggSMClient *client);
+void      egg_sm_client_quit           (EggSMClient *client);
+
+#ifdef EGG_SM_CLIENT_BACKEND_XSMP
+    GType        egg_sm_client_xsmp_get_type (void);
+    EggSMClient *egg_sm_client_xsmp_new      (void);
+#endif
+#ifdef EGG_SM_CLIENT_BACKEND_DBUS
+    GType        egg_sm_client_dbus_get_type (void);
+    EggSMClient *egg_sm_client_dbus_new      (void);
+#endif
+
+G_END_DECLS
+
+#endif /* __EGG_SM_CLIENT_PRIVATE_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/68.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/68.html new file mode 100644 index 0000000..b58397a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/68.html @@ -0,0 +1,1523 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
/*
+ * Copyright (C) 2007 Novell, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "eggsmclient.h"
+#include "eggsmclient-private.h"
+
+static void egg_sm_client_debug_handler (const char *log_domain,
+        GLogLevelFlags log_level,
+        const char *message,
+        gpointer user_data);
+
+enum
+{
+    SAVE_STATE,
+    QUIT_REQUESTED,
+    QUIT_CANCELLED,
+    QUIT,
+    LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+typedef struct {
+    GKeyFile *state_file;
+}EggSMClientPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (EggSMClient, egg_sm_client, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static EggSMClient *global_client;
+static EggSMClientMode global_client_mode = EGG_SM_CLIENT_MODE_NORMAL;
+
+static gboolean
+running_in_mate (void)
+{
+    return (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") == 0)
+        || (g_strcmp0 (g_getenv ("XDG_SESSION_DESKTOP"), "mate") == 0)
+        || (g_strcmp0 (g_getenv ("DESKTOP_SESSION"), "mate") == 0);
+}
+
+static void
+egg_sm_client_init (EggSMClient *client)
+{
+    ;
+}
+
+static void
+egg_sm_client_class_init (EggSMClientClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    /**
+     * EggSMClient::save_state:
+     * @client: the client
+     * @state_file: a #GKeyFile to save state information into
+     *
+     * Emitted when the session manager has requested that the
+     * application save information about its current state. The
+     * application should save its state into @state_file, and then the
+     * session manager may then restart the application in a future
+     * session and tell it to initialize itself from that state.
+     *
+     * You should not save any data into @state_file's "start group"
+     * (ie, the %NULL group). Instead, applications should save their
+     * data into groups with names that start with the application name,
+     * and libraries that connect to this signal should save their data
+     * into groups with names that start with the library name.
+     *
+     * Alternatively, rather than (or in addition to) using @state_file,
+     * the application can save its state by calling
+     * egg_sm_client_set_restart_command() during the processing of this
+     * signal (eg, to include a list of files to open).
+     **/
+    signals[SAVE_STATE] =
+        g_signal_new ("save_state",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (EggSMClientClass, save_state),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__POINTER,
+                      G_TYPE_NONE,
+                      1, G_TYPE_POINTER);
+
+    /**
+     * EggSMClient::quit_requested:
+     * @client: the client
+     *
+     * Emitted when the session manager requests that the application
+     * exit (generally because the user is logging out). The application
+     * should decide whether or not it is willing to quit (perhaps after
+     * asking the user what to do with documents that have unsaved
+     * changes) and then call egg_sm_client_will_quit(), passing %TRUE
+     * or %FALSE to give its answer to the session manager. (It does not
+     * need to give an answer before returning from the signal handler;
+     * it can interact with the user asynchronously and then give its
+     * answer later on.) If the application does not connect to this
+     * signal, then #EggSMClient will automatically return %TRUE on its
+     * behalf.
+     *
+     * The application should not save its session state as part of
+     * handling this signal; if the user has requested that the session
+     * be saved when logging out, then ::save_state will be emitted
+     * separately.
+     *
+     * If the application agrees to quit, it should then wait for either
+     * the ::quit_cancelled or ::quit signals to be emitted.
+     **/
+    signals[QUIT_REQUESTED] =
+        g_signal_new ("quit_requested",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (EggSMClientClass, quit_requested),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+    /**
+     * EggSMClient::quit_cancelled:
+     * @client: the client
+     *
+     * Emitted when the session manager decides to cancel a logout after
+     * the application has already agreed to quit. After receiving this
+     * signal, the application can go back to what it was doing before
+     * receiving the ::quit_requested signal.
+     **/
+    signals[QUIT_CANCELLED] =
+        g_signal_new ("quit_cancelled",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (EggSMClientClass, quit_cancelled),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+
+    /**
+     * EggSMClient::quit:
+     * @client: the client
+     *
+     * Emitted when the session manager wants the application to quit
+     * (generally because the user is logging out). The application
+     * should exit as soon as possible after receiving this signal; if
+     * it does not, the session manager may choose to forcibly kill it.
+     *
+     * Normally a GUI application would only be sent a ::quit if it
+     * agreed to quit in response to a ::quit_requested signal. However,
+     * this is not guaranteed; in some situations the session manager
+     * may decide to end the session without giving applications a
+     * chance to object.
+     **/
+    signals[QUIT] =
+        g_signal_new ("quit",
+                      G_OBJECT_CLASS_TYPE (object_class),
+                      G_SIGNAL_RUN_LAST,
+                      G_STRUCT_OFFSET (EggSMClientClass, quit),
+                      NULL, NULL,
+                      g_cclosure_marshal_VOID__VOID,
+                      G_TYPE_NONE,
+                      0);
+}
+
+static gboolean sm_client_disable = FALSE;
+static char *sm_client_state_file = NULL;
+static char *sm_client_id = NULL;
+static char *sm_config_prefix = NULL;
+
+static gboolean
+sm_client_post_parse_func (GOptionContext  *context,
+                           GOptionGroup    *group,
+                           gpointer         data,
+                           GError         **error)
+{
+    EggSMClient *client = egg_sm_client_get ();
+
+    if (sm_client_id == NULL)
+    {
+        const gchar *desktop_autostart_id;
+
+        desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+
+        if (desktop_autostart_id != NULL)
+            sm_client_id = g_strdup (desktop_autostart_id);
+    }
+
+    /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
+     * use the same client id. */
+    g_unsetenv ("DESKTOP_AUTOSTART_ID");
+
+    if (global_client_mode != EGG_SM_CLIENT_MODE_DISABLED &&
+        EGG_SM_CLIENT_GET_CLASS (client)->startup)
+        EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
+    return TRUE;
+}
+
+/**
+ * egg_sm_client_get_option_group:
+ *
+ * Creates a %GOptionGroup containing the session-management-related
+ * options. You should add this group to the application's
+ * %GOptionContext if you want to use #EggSMClient.
+ *
+ * Return value: the %GOptionGroup
+ **/
+GOptionGroup *
+egg_sm_client_get_option_group (void)
+{
+    const GOptionEntry entries[] =
+    {
+        {
+            "sm-client-disable", 0, 0,
+            G_OPTION_ARG_NONE, &sm_client_disable,
+            N_("Disable connection to session manager"), NULL
+        },
+        {
+            "sm-client-state-file", 0, 0,
+            G_OPTION_ARG_FILENAME, &sm_client_state_file,
+            N_("Specify file containing saved configuration"), N_("FILE")
+        },
+        {
+            "sm-client-id", 0, 0,
+            G_OPTION_ARG_STRING, &sm_client_id,
+            N_("Specify session management ID"), N_("ID")
+        },
+        /* MateClient compatibility option */
+        {
+            "sm-disable", 0, G_OPTION_FLAG_HIDDEN,
+            G_OPTION_ARG_NONE, &sm_client_disable,
+            NULL, NULL
+        },
+        /* MateClient compatibility option. This is a dummy option that only
+         * exists so that sessions saved by apps with MateClient can be restored
+         * later when they've switched to EggSMClient. See bug #575308.
+         */
+        {
+            "sm-config-prefix", 0, G_OPTION_FLAG_HIDDEN,
+            G_OPTION_ARG_STRING, &sm_config_prefix,
+            NULL, NULL
+        },
+        { NULL }
+    };
+    GOptionGroup *group;
+
+    /* Use our own debug handler for the "EggSMClient" domain. */
+    g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
+                       egg_sm_client_debug_handler, NULL);
+
+    group = g_option_group_new ("sm-client",
+                                _("Session management options:"),
+                                _("Show session management options"),
+                                NULL, NULL);
+    g_option_group_add_entries (group, entries);
+    g_option_group_set_parse_hooks (group, NULL, sm_client_post_parse_func);
+
+    return group;
+}
+
+/**
+ * egg_sm_client_set_mode:
+ * @mode: an #EggSMClient mode
+ *
+ * Sets the "mode" of #EggSMClient as follows:
+ *
+ *    %EGG_SM_CLIENT_MODE_DISABLED: Session management is completely
+ *    disabled, until the mode is changed again. The application will
+ *    not even connect to the session manager. (egg_sm_client_get()
+ *    will still return an #EggSMClient object.)
+ *
+ *    %EGG_SM_CLIENT_MODE_NO_RESTART: The application will connect to
+ *    the session manager (and thus will receive notification when the
+ *    user is logging out, etc), but will request to not be
+ *    automatically restarted with saved state in future sessions.
+ *
+ *    %EGG_SM_CLIENT_MODE_NORMAL: The default. #EggSMCLient will
+ *    function normally.
+ *
+ * This must be called before the application's main loop begins and
+ * before any call to egg_sm_client_get(), unless the mode was set
+ * earlier to %EGG_SM_CLIENT_MODE_DISABLED and this call enables
+ * session management. Note that option parsing will call
+ * egg_sm_client_get().
+ **/
+void
+egg_sm_client_set_mode (EggSMClientMode mode)
+{
+    EggSMClientMode old_mode = global_client_mode;
+
+    g_return_if_fail (global_client == NULL || global_client_mode == EGG_SM_CLIENT_MODE_DISABLED);
+    g_return_if_fail (!(global_client != NULL && mode == EGG_SM_CLIENT_MODE_DISABLED));
+
+    global_client_mode = mode;
+
+    if (global_client != NULL && old_mode == EGG_SM_CLIENT_MODE_DISABLED)
+    {
+        if (EGG_SM_CLIENT_GET_CLASS (global_client)->startup)
+            EGG_SM_CLIENT_GET_CLASS (global_client)->startup (global_client, sm_client_id);
+    }
+}
+
+/**
+ * egg_sm_client_get_mode:
+ *
+ * Gets the global #EggSMClientMode. See egg_sm_client_set_mode()
+ * for details.
+ *
+ * Return value: the global #EggSMClientMode
+ **/
+EggSMClientMode
+egg_sm_client_get_mode (void)
+{
+    return global_client_mode;
+}
+
+/**
+ * egg_sm_client_get:
+ *
+ * Returns the master #EggSMClient for the application.
+ *
+ * On platforms that support saved sessions (ie, POSIX/X11), the
+ * application will only request to be restarted by the session
+ * manager if you call egg_set_desktop_file() to set an application
+ * desktop file. In particular, if the desktop file contains the key
+ * "X
+ *
+ * Return value: the master #EggSMClient.
+ **/
+EggSMClient *
+egg_sm_client_get (void)
+{
+    if (!global_client)
+    {
+        if (!sm_client_disable)
+        {
+            /* If both D-Bus and XSMP are compiled in, try XSMP first
+             * (since it supports state saving) and fall back to D-Bus
+             * if XSMP isn't available.
+             */
+#ifdef EGG_SM_CLIENT_BACKEND_XSMP
+            global_client = egg_sm_client_xsmp_new ();
+#endif
+#ifdef EGG_SM_CLIENT_BACKEND_DBUS
+            if (!global_client)
+                global_client = egg_sm_client_dbus_new ();
+#endif
+        }
+
+        /* Fallback: create a dummy client, so that callers don't have
+         * to worry about a %NULL return value.
+         */
+        if (!global_client)
+            global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL);
+        /*FIXME
+          Disabling when root/not in MATE in GtkApplication builds
+          as egg_sm_client_set_mode must be called prior to start of main loop
+          to stop caja restart but this is diffcult in GtkApplication */
+
+		if (geteuid () == 0 || !running_in_mate ()){
+            global_client = g_object_new (EGG_TYPE_SM_CLIENT, NULL);
+        }
+    }
+
+    return global_client;
+}
+
+/**
+ * egg_sm_client_is_resumed:
+ * @client: the client
+ *
+ * Checks whether or not the current session has been resumed from
+ * a previous saved session. If so, the application should call
+ * egg_sm_client_get_state_file() and restore its state from the
+ * returned #GKeyFile.
+ *
+ * Return value: %TRUE if the session has been resumed
+ **/
+gboolean
+egg_sm_client_is_resumed (EggSMClient *client)
+{
+    g_return_val_if_fail (client == global_client, FALSE);
+
+    return sm_client_state_file != NULL;
+}
+
+/**
+ * egg_sm_client_get_state_file:
+ * @client: the client
+ *
+ * If the application was resumed by the session manager, this will
+ * return the #GKeyFile containing its state from the previous
+ * session.
+ *
+ * Note that other libraries and #EggSMClient itself may also store
+ * state in the key file, so if you call egg_sm_client_get_groups(),
+ * on it, the return value will likely include groups that you did not
+ * put there yourself. (It is also not guaranteed that the first
+ * group created by the application will still be the "start group"
+ * when it is resumed.)
+ *
+ * Return value: the #GKeyFile containing the application's earlier
+ * state, or %NULL on error. You should not free this key file; it
+ * is owned by @client.
+ **/
+GKeyFile *
+egg_sm_client_get_state_file (EggSMClient *client)
+{
+    EggSMClientPrivate *priv = egg_sm_client_get_instance_private (client);
+    char *state_file_path;
+    GError *err = NULL;
+
+    g_return_val_if_fail (client == global_client, NULL);
+
+    if (!sm_client_state_file)
+        return NULL;
+    if (priv->state_file)
+        return priv->state_file;
+
+    if (!strncmp (sm_client_state_file, "file://", 7))
+        state_file_path = g_filename_from_uri (sm_client_state_file, NULL, NULL);
+    else
+        state_file_path = g_strdup (sm_client_state_file);
+
+    priv->state_file = g_key_file_new ();
+    if (!g_key_file_load_from_file (priv->state_file, state_file_path, 0, &err))
+    {
+        g_warning ("Could not load SM state file '%s': %s",
+                   sm_client_state_file, err->message);
+        g_clear_error (&err);
+        g_key_file_free (priv->state_file);
+        priv->state_file = NULL;
+    }
+
+    g_free (state_file_path);
+    return priv->state_file;
+}
+
+/**
+ * egg_sm_client_set_restart_command:
+ * @client: the client
+ * @argc: the length of @argv
+ * @argv: argument vector
+ *
+ * Sets the command used to restart @client if it does not have a
+ * .desktop file that can be used to find its restart command.
+ *
+ * This can also be used when handling the ::save_state signal, to
+ * save the current state via an updated command line. (Eg, providing
+ * a list of filenames to open when the application is resumed.)
+ **/
+void
+egg_sm_client_set_restart_command (EggSMClient  *client,
+                                   int           argc,
+                                   const char  **argv)
+{
+    g_return_if_fail (EGG_IS_SM_CLIENT (client));
+
+    if (EGG_SM_CLIENT_GET_CLASS (client)->set_restart_command)
+        EGG_SM_CLIENT_GET_CLASS (client)->set_restart_command (client, argc, argv);
+}
+
+/**
+ * egg_sm_client_set_discard_command:
+ * @client: the client
+ * @argc: the length of @argv
+ * @argv: argument vector
+ *
+ * Sets the command used to discard a custom state file if using
+ * egg_sm_client_set_restart_command(), which must be called before
+ * using this function.
+ **/
+void
+egg_sm_client_set_discard_command (EggSMClient  *client,
+                                   int           argc,
+                                   const char  **argv)
+{
+	g_return_if_fail (EGG_IS_SM_CLIENT (client));
+
+	if (EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command)
+		EGG_SM_CLIENT_GET_CLASS (client)->set_discard_command (client, argc, argv);
+}
+
+/**
+ * egg_sm_client_will_quit:
+ * @client: the client
+ * @will_quit: whether or not the application is willing to quit
+ *
+ * This MUST be called in response to the ::quit_requested signal, to
+ * indicate whether or not the application is willing to quit. The
+ * application may call it either directly from the signal handler, or
+ * at some later point (eg, after asynchronously interacting with the
+ * user).
+ *
+ * If the application does not connect to ::quit_requested,
+ * #EggSMClient will call this method on its behalf (passing %TRUE
+ * for @will_quit).
+ *
+ * After calling this method, the application should wait to receive
+ * either ::quit_cancelled or ::quit.
+ **/
+void
+egg_sm_client_will_quit (EggSMClient *client,
+                         gboolean     will_quit)
+{
+    g_return_if_fail (EGG_IS_SM_CLIENT (client));
+
+    if (EGG_SM_CLIENT_GET_CLASS (client)->will_quit)
+        EGG_SM_CLIENT_GET_CLASS (client)->will_quit (client, will_quit);
+}
+
+/**
+ * egg_sm_client_end_session:
+ * @style: a hint at how to end the session
+ * @request_confirmation: whether or not the user should get a chance
+ * to confirm the action
+ *
+ * Requests that the session manager end the current session. @style
+ * indicates how the session should be ended, and
+ * @request_confirmation indicates whether or not the user should be
+ * given a chance to confirm the logout/reboot/shutdown. Both of these
+ * flags are merely hints though; the session manager may choose to
+ * ignore them.
+ *
+ * Return value: %TRUE if the request was sent; %FALSE if it could not
+ * be (eg, because it could not connect to the session manager).
+ **/
+gboolean
+egg_sm_client_end_session (EggSMClientEndStyle  style,
+                           gboolean             request_confirmation)
+{
+    EggSMClient *client = egg_sm_client_get ();
+
+    g_return_val_if_fail (EGG_IS_SM_CLIENT (client), FALSE);
+
+    if (EGG_SM_CLIENT_GET_CLASS (client)->end_session)
+    {
+        return EGG_SM_CLIENT_GET_CLASS (client)->end_session (client, style,
+                request_confirmation);
+    }
+    else
+        return FALSE;
+}
+
+/* Signal-emitting callbacks from platform-specific code */
+
+GKeyFile *
+egg_sm_client_save_state (EggSMClient *client)
+{
+    GKeyFile *state_file;
+    char *group;
+
+    g_return_val_if_fail (client == global_client, NULL);
+
+    state_file = g_key_file_new ();
+
+    g_debug ("Emitting save_state");
+    g_signal_emit (client, signals[SAVE_STATE], 0, state_file);
+    g_debug ("Done emitting save_state");
+
+    group = g_key_file_get_start_group (state_file);
+    if (group)
+    {
+        g_free (group);
+        return state_file;
+    }
+    else
+    {
+        g_key_file_free (state_file);
+        return NULL;
+    }
+}
+
+void
+egg_sm_client_quit_requested (EggSMClient *client)
+{
+    g_return_if_fail (client == global_client);
+
+    if (!g_signal_has_handler_pending (client, signals[QUIT_REQUESTED], 0, FALSE))
+    {
+        g_debug ("Not emitting quit_requested because no one is listening");
+        egg_sm_client_will_quit (client, TRUE);
+        return;
+    }
+
+    g_debug ("Emitting quit_requested");
+    g_signal_emit (client, signals[QUIT_REQUESTED], 0);
+    g_debug ("Done emitting quit_requested");
+}
+
+void
+egg_sm_client_quit_cancelled (EggSMClient *client)
+{
+    g_return_if_fail (client == global_client);
+
+    g_debug ("Emitting quit_cancelled");
+    g_signal_emit (client, signals[QUIT_CANCELLED], 0);
+    g_debug ("Done emitting quit_cancelled");
+}
+
+void
+egg_sm_client_quit (EggSMClient *client)
+{
+    g_return_if_fail (client == global_client);
+
+    g_debug ("Emitting quit");
+    g_signal_emit (client, signals[QUIT], 0);
+    g_debug ("Done emitting quit");
+
+    /* FIXME: should we just call gtk_main_quit() here? */
+}
+
+static void
+egg_sm_client_debug_handler (const char *log_domain,
+                             GLogLevelFlags log_level,
+                             const char *message,
+                             gpointer user_data)
+{
+    static int debug = -1;
+
+    if (debug < 0)
+        debug = (g_getenv ("EGG_SM_CLIENT_DEBUG") != NULL);
+
+    if (debug)
+        g_log_default_handler (log_domain, log_level, message, NULL);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/69.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/69.html new file mode 100644 index 0000000..ee6c37b --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/69.html @@ -0,0 +1,1071 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
/* eggtreemultidnd.c
+ * Copyright (C) 2001  Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "eggtreemultidnd.h"
+
+#define EGG_TREE_MULTI_DND_STRING "EggTreeMultiDndString"
+
+typedef struct
+{
+    guint pressed_button;
+    gint x;
+    gint y;
+    guint motion_notify_handler;
+    guint button_release_handler;
+    guint drag_data_get_handler;
+    GSList *event_list;
+} EggTreeMultiDndData;
+
+/* CUT-N-PASTE from gtktreeview.c */
+typedef struct _TreeViewDragInfo TreeViewDragInfo;
+struct _TreeViewDragInfo
+{
+    GdkModifierType start_button_mask;
+    GtkTargetList *source_target_list;<--- struct member '_TreeViewDragInfo::source_target_list' is never used.
+    GdkDragAction source_actions;
+
+    GtkTargetList *dest_target_list;<--- struct member '_TreeViewDragInfo::dest_target_list' is never used.
+
+    guint source_set : 1;
+    guint dest_set : 1;
+};
+
+
+GType
+egg_tree_multi_drag_source_get_type (void)
+{
+    static GType our_type = 0;
+
+    if (!our_type)
+    {
+        const GTypeInfo our_info =
+        {
+            sizeof (EggTreeMultiDragSourceIface), /* class_size */
+            NULL,		/* base_init */
+            NULL,		/* base_finalize */
+            NULL,
+            NULL,		/* class_finalize */
+            NULL,		/* class_data */
+            0,
+            0,              /* n_preallocs */
+            NULL
+        };
+
+        our_type = g_type_register_static (G_TYPE_INTERFACE, "EggTreeMultiDragSource", &our_info, 0);
+    }
+
+    return our_type;
+}
+
+
+/**
+ * egg_tree_multi_drag_source_row_draggable:
+ * @drag_source: a #EggTreeMultiDragSource
+ * @path: row on which user is initiating a drag
+ *
+ * Asks the #EggTreeMultiDragSource whether a particular row can be used as
+ * the source of a DND operation. If the source doesn't implement
+ * this interface, the row is assumed draggable.
+ *
+ * Return value: %TRUE if the row can be dragged
+ **/
+gboolean
+egg_tree_multi_drag_source_row_draggable (EggTreeMultiDragSource *drag_source,
+        GList                  *path_list)
+{
+    EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
+
+    g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
+    g_return_val_if_fail (iface->row_draggable != NULL, FALSE);
+    g_return_val_if_fail (path_list != NULL, FALSE);
+
+    if (iface->row_draggable)
+        return (* iface->row_draggable) (drag_source, path_list);
+    else
+        return TRUE;
+}
+
+
+/**
+ * egg_tree_multi_drag_source_drag_data_delete:
+ * @drag_source: a #EggTreeMultiDragSource
+ * @path: row that was being dragged
+ *
+ * Asks the #EggTreeMultiDragSource to delete the row at @path, because
+ * it was moved somewhere else via drag-and-drop. Returns %FALSE
+ * if the deletion fails because @path no longer exists, or for
+ * some model-specific reason. Should robustly handle a @path no
+ * longer found in the model!
+ *
+ * Return value: %TRUE if the row was successfully deleted
+ **/
+gboolean
+egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
+        GList                  *path_list)
+{
+    EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
+
+    g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
+    g_return_val_if_fail (iface->drag_data_delete != NULL, FALSE);
+    g_return_val_if_fail (path_list != NULL, FALSE);
+
+    return (* iface->drag_data_delete) (drag_source, path_list);
+}
+
+/**
+ * egg_tree_multi_drag_source_drag_data_get:
+ * @drag_source: a #EggTreeMultiDragSource
+ * @path: row that was dragged
+ * @selection_data: a #EggSelectionData to fill with data from the dragged row
+ *
+ * Asks the #EggTreeMultiDragSource to fill in @selection_data with a
+ * representation of the row at @path. @selection_data->target gives
+ * the required type of the data.  Should robustly handle a @path no
+ * longer found in the model!
+ *
+ * Return value: %TRUE if data of the required type was provided
+ **/
+gboolean
+egg_tree_multi_drag_source_drag_data_get    (EggTreeMultiDragSource *drag_source,
+        GList                  *path_list,
+        GtkSelectionData  *selection_data)
+{
+    EggTreeMultiDragSourceIface *iface = EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE (drag_source);
+
+    g_return_val_if_fail (EGG_IS_TREE_MULTI_DRAG_SOURCE (drag_source), FALSE);
+    g_return_val_if_fail (iface->drag_data_get != NULL, FALSE);
+    g_return_val_if_fail (path_list != NULL, FALSE);
+    g_return_val_if_fail (selection_data != NULL, FALSE);
+
+    return (* iface->drag_data_get) (drag_source, path_list, selection_data);
+}
+
+static void
+stop_drag_check (GtkWidget *widget)
+{
+    EggTreeMultiDndData *priv_data;
+    GSList *l;
+
+    priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
+
+    for (l = priv_data->event_list; l != NULL; l = l->next)
+        gdk_event_free (l->data);
+
+    g_slist_free (priv_data->event_list);
+    priv_data->event_list = NULL;
+    g_signal_handler_disconnect (widget, priv_data->motion_notify_handler);
+    g_signal_handler_disconnect (widget, priv_data->button_release_handler);
+}
+
+static gboolean
+egg_tree_multi_drag_button_release_event (GtkWidget      *widget,
+        GdkEventButton *event,
+        gpointer        data)
+{
+    EggTreeMultiDndData *priv_data;<--- Variable 'priv_data' can be declared as pointer to const
+    GSList *l;
+
+    priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
+
+    for (l = priv_data->event_list; l != NULL; l = l->next)
+        gtk_propagate_event (widget, l->data);
+
+    stop_drag_check (widget);
+
+    return FALSE;
+}
+
+static void
+selection_foreach (GtkTreeModel *model,
+                   GtkTreePath  *path,
+                   GtkTreeIter  *iter,
+                   gpointer      data)
+{
+    GList **list_ptr;
+
+    list_ptr = (GList **) data;
+
+    *list_ptr = g_list_prepend (*list_ptr, gtk_tree_row_reference_new (model, path));
+}
+
+static void
+path_list_free (GList *path_list)
+{
+    g_list_foreach (path_list, (GFunc) gtk_tree_row_reference_free, NULL);
+    g_list_free (path_list);
+}
+
+static void
+set_context_data (GdkDragContext *context,
+                  GList          *path_list)
+{
+    g_object_set_data_full (G_OBJECT (context),
+                            "egg-tree-view-multi-source-row",
+                            path_list,
+                            (GDestroyNotify) path_list_free);
+}
+
+static GList *
+get_context_data (GdkDragContext *context)
+{
+    return g_object_get_data (G_OBJECT (context),
+                              "egg-tree-view-multi-source-row");
+}
+
+/* CUT-N-PASTE from gtktreeview.c */
+static TreeViewDragInfo*
+get_info (GtkTreeView *tree_view)
+{
+    return g_object_get_data (G_OBJECT (tree_view), "gtk-tree-view-drag-info");
+}
+
+
+static void
+egg_tree_multi_drag_drag_data_get (GtkWidget        *widget,
+                                   GdkDragContext   *context,
+                                   GtkSelectionData *selection_data,
+                                   guint             info,
+                                   guint             time)
+{
+    GtkTreeView *tree_view;
+    GtkTreeModel *model;
+    TreeViewDragInfo *di;<--- Variable 'di' can be declared as pointer to const
+    GList *path_list;
+
+    tree_view = GTK_TREE_VIEW (widget);
+
+    model = gtk_tree_view_get_model (tree_view);
+
+    if (model == NULL)
+        return;
+
+    di = get_info (GTK_TREE_VIEW (widget));
+
+    if (di == NULL)
+        return;
+
+    path_list = get_context_data (context);
+
+    if (path_list == NULL)
+        return;
+
+    /* We can implement the GTK_TREE_MODEL_ROW target generically for
+     * any model; for DragSource models there are some other targets
+     * we also support.
+     */
+
+    if (EGG_IS_TREE_MULTI_DRAG_SOURCE (model))
+    {
+        egg_tree_multi_drag_source_drag_data_get (EGG_TREE_MULTI_DRAG_SOURCE (model),
+                path_list,
+                selection_data);
+    }
+}
+
+static gboolean
+egg_tree_multi_drag_motion_event (GtkWidget      *widget,
+                                  GdkEventMotion *event,
+                                  gpointer        data)
+{
+    EggTreeMultiDndData *priv_data;
+
+    priv_data = g_object_get_data (G_OBJECT (widget), EGG_TREE_MULTI_DND_STRING);
+
+    if (gtk_drag_check_threshold (widget,
+                                  priv_data->x,
+                                  priv_data->y,
+                                  event->x,
+                                  event->y))
+    {
+        GList *path_list = NULL;
+        GtkTreeSelection *selection;
+        GtkTreeModel *model;
+        TreeViewDragInfo *di;
+
+        di = get_info (GTK_TREE_VIEW (widget));
+
+        if (di == NULL)
+            return FALSE;
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+        stop_drag_check (widget);
+        gtk_tree_selection_selected_foreach (selection, selection_foreach, &path_list);
+        path_list = g_list_reverse (path_list);
+        model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
+        if (egg_tree_multi_drag_source_row_draggable (EGG_TREE_MULTI_DRAG_SOURCE (model), path_list))
+        {
+            GdkDragContext *context;
+
+            context = gtk_drag_begin_with_coordinates (widget,
+                                                       gtk_drag_source_get_target_list (widget),
+                                                       di->source_actions,
+                                                       priv_data->pressed_button,
+                                                       (GdkEvent*)event,
+                                                       event->x,
+                                                       event->y);
+            set_context_data (context, path_list);
+            gtk_drag_set_icon_default (context);
+
+        }
+        else
+        {
+            path_list_free (path_list);
+        }
+    }
+
+    return TRUE;
+}
+
+static gboolean
+egg_tree_multi_drag_button_press_event (GtkWidget      *widget,
+                                        GdkEventButton *event,
+                                        gpointer        data)
+{
+    GtkTreeView *tree_view;
+    GtkTreePath *path = NULL;
+    GtkTreeViewColumn *column = NULL;
+    gint cell_x, cell_y;
+    GtkTreeSelection *selection;
+    EggTreeMultiDndData *priv_data;
+
+    tree_view = GTK_TREE_VIEW (widget);
+    priv_data = g_object_get_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING);
+    if (priv_data == NULL)
+    {
+        priv_data = g_new0 (EggTreeMultiDndData, 1);
+        g_object_set_data (G_OBJECT (tree_view), EGG_TREE_MULTI_DND_STRING, priv_data);
+    }
+
+    if (g_slist_find (priv_data->event_list, event))
+        return FALSE;
+
+    if (priv_data->event_list)
+    {
+        /* save the event to be propagated in order */
+        priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
+        return TRUE;
+    }
+
+    if (event->type == GDK_2BUTTON_PRESS)
+        return FALSE;
+
+    gtk_tree_view_get_path_at_pos (tree_view,
+                                   event->x, event->y,
+                                   &path, &column,
+                                   &cell_x, &cell_y);
+
+    selection = gtk_tree_view_get_selection (tree_view);
+
+    if (path && gtk_tree_selection_path_is_selected (selection, path))
+    {
+        priv_data->pressed_button = event->button;
+        priv_data->x = event->x;
+        priv_data->y = event->y;
+        priv_data->event_list = g_slist_append (priv_data->event_list, gdk_event_copy ((GdkEvent*)event));
+        priv_data->motion_notify_handler =
+            g_signal_connect (G_OBJECT (tree_view), "motion_notify_event", G_CALLBACK (egg_tree_multi_drag_motion_event), NULL);
+        priv_data->button_release_handler =
+            g_signal_connect (G_OBJECT (tree_view), "button_release_event", G_CALLBACK (egg_tree_multi_drag_button_release_event), NULL);
+
+        if (priv_data->drag_data_get_handler == 0)
+        {
+            priv_data->drag_data_get_handler =
+                g_signal_connect (G_OBJECT (tree_view), "drag_data_get", G_CALLBACK (egg_tree_multi_drag_drag_data_get), NULL);
+        }
+
+        gtk_tree_path_free (path);
+
+        return TRUE;
+    }
+
+    if (path)
+    {
+        gtk_tree_path_free (path);
+    }
+
+    return FALSE;
+}
+
+void
+egg_tree_multi_drag_add_drag_support (GtkTreeView *tree_view)
+{
+    g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
+    g_signal_connect (G_OBJECT (tree_view), "button_press_event", G_CALLBACK (egg_tree_multi_drag_button_press_event), NULL);
+}
+
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/7.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/7.html new file mode 100644 index 0000000..18a755a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/7.html @@ -0,0 +1,1477 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ * Copyright (C) 2007, 2009 Vincent Untz.
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-util.h"<--- Include file: "gsm-util.h" not found.
+#include "gsp-app.h"
+
+#include "gsp-app-manager.h"
+
+typedef struct {
+        char         *dir;
+        int           index;
+        GFileMonitor *monitor;
+} GspXdgDir;
+
+typedef struct {
+        GSList *apps;
+        GSList *dirs;
+} GspAppManagerPrivate;
+
+enum {
+        ADDED,
+        REMOVED,
+        LAST_SIGNAL
+};
+
+static guint gsp_app_manager_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GspAppManager, gsp_app_manager, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void     gsp_app_manager_dispose      (GObject       *object);
+static void     gsp_app_manager_finalize     (GObject       *object);
+static void     _gsp_app_manager_app_unref   (GspApp        *app,
+                                              GspAppManager *manager);
+static void     _gsp_app_manager_app_removed (GspAppManager *manager,
+                                              GspApp        *app);
+
+static GspXdgDir *
+_gsp_xdg_dir_new (const char *dir,
+                  int         index)
+{
+        GspXdgDir *xdgdir;
+
+        xdgdir = g_slice_new (GspXdgDir);
+
+        xdgdir->dir = g_strdup (dir);
+        xdgdir->index = index;
+        xdgdir->monitor = NULL;
+
+        return xdgdir;
+}
+
+static void
+_gsp_xdg_dir_free (GspXdgDir *xdgdir)
+{
+        if (xdgdir->dir) {
+                g_free (xdgdir->dir);
+                xdgdir->dir = NULL;
+        }
+
+        if (xdgdir->monitor) {
+                g_file_monitor_cancel (xdgdir->monitor);
+                g_object_unref (xdgdir->monitor);
+                xdgdir->monitor = NULL;
+        }
+
+        g_slice_free (GspXdgDir, xdgdir);
+}
+
+static void
+gsp_app_manager_class_init (GspAppManagerClass *class)
+{
+        GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+        gobject_class->dispose  = gsp_app_manager_dispose;
+        gobject_class->finalize = gsp_app_manager_finalize;
+
+        gsp_app_manager_signals[ADDED] =
+                g_signal_new ("added",
+                              G_TYPE_FROM_CLASS (gobject_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GspAppManagerClass,
+                                               added),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__OBJECT,
+                              G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+        gsp_app_manager_signals[REMOVED] =
+                g_signal_new ("removed",
+                              G_TYPE_FROM_CLASS (gobject_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GspAppManagerClass,
+                                               removed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__OBJECT,
+                              G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
+}
+
+static void
+gsp_app_manager_init (GspAppManager *manager)
+{
+        GspAppManagerPrivate *priv;
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        // is needed?
+        memset (priv, 0, sizeof (GspAppManagerPrivate));
+}
+
+static void
+gsp_app_manager_dispose (GObject *object)
+{
+        GspAppManager *manager;
+        GspAppManagerPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSP_IS_APP_MANAGER (object));
+
+        manager = GSP_APP_MANAGER (object);
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        /* we unref GspApp objects in dispose since they might need to
+         * reference us during their dispose/finalize */
+        g_slist_foreach (priv->apps,
+                         (GFunc) _gsp_app_manager_app_unref, manager);
+        g_slist_free (priv->apps);
+        priv->apps = NULL;
+
+        G_OBJECT_CLASS (gsp_app_manager_parent_class)->dispose (object);
+}
+
+static void
+gsp_app_manager_finalize (GObject *object)
+{
+        GspAppManager *manager;
+        GspAppManagerPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSP_IS_APP_MANAGER (object));
+
+        manager = GSP_APP_MANAGER (object);
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        g_slist_foreach (priv->dirs,
+                         (GFunc) _gsp_xdg_dir_free, NULL);
+        g_slist_free (priv->dirs);
+        priv->dirs = NULL;
+
+        G_OBJECT_CLASS (gsp_app_manager_parent_class)->finalize (object);
+
+        manager = NULL;
+}
+
+static void
+_gsp_app_manager_emit_added (GspAppManager *manager,
+                             GspApp        *app)
+{
+        g_signal_emit (G_OBJECT (manager), gsp_app_manager_signals[ADDED],
+                       0, app);
+}
+
+static void
+_gsp_app_manager_emit_removed (GspAppManager *manager,
+                               GspApp        *app)
+{
+        g_signal_emit (G_OBJECT (manager), gsp_app_manager_signals[REMOVED],
+                       0, app);
+}
+
+/*
+ * Directories
+ */
+
+static int
+gsp_app_manager_get_dir_index (GspAppManager *manager,
+                               const char    *dir)
+{
+        GSList    *l;
+        GspXdgDir *xdgdir;
+        GspAppManagerPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP_MANAGER (manager), -1);
+        g_return_val_if_fail (dir != NULL, -1);
+
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        for (l = priv->dirs; l != NULL; l = l->next) {
+                xdgdir = l->data;
+                if (strcmp (dir, xdgdir->dir) == 0) {
+                        return xdgdir->index;
+                }
+        }
+
+        return -1;
+}
+
+const char *
+gsp_app_manager_get_dir (GspAppManager *manager,
+                         unsigned int   index)
+{
+        GSList    *l;
+        GspXdgDir *xdgdir;
+        GspAppManagerPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP_MANAGER (manager), NULL);
+
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        for (l = priv->dirs; l != NULL; l = l->next) {
+                xdgdir = l->data;
+                if (index == xdgdir->index) {
+                        return xdgdir->dir;
+                }
+        }
+
+        return NULL;
+}
+
+static int
+_gsp_app_manager_find_dir_with_basename (GspAppManager *manager,
+                                         const char    *basename,
+                                         int            minimum_index)
+{
+        GSList    *l;
+        GspXdgDir *xdgdir;
+        char      *path;
+        GKeyFile  *keyfile;
+        int        result = -1;
+        GspAppManagerPrivate *priv;
+
+        path = NULL;
+        keyfile = g_key_file_new ();
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        for (l = priv->dirs; l != NULL; l = l->next) {
+                xdgdir = l->data;
+
+                if (xdgdir->index <= minimum_index) {
+                        continue;
+                }
+
+                g_free (path);
+                path = g_build_filename (xdgdir->dir, basename, NULL);
+                if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
+                        continue;
+                }
+
+                if (!g_key_file_load_from_file (keyfile, path,
+                                                G_KEY_FILE_NONE, NULL)) {
+                        continue;
+                }
+
+                /* the file exists and is readable */
+                if (result == -1) {
+                        result = xdgdir->index;
+                } else {
+                        result = MIN (result, xdgdir->index);
+                }
+        }
+
+        g_key_file_free (keyfile);
+        g_free (path);
+
+        return result;
+}
+
+static void
+_gsp_app_manager_handle_delete (GspAppManager *manager,
+                                GspApp        *app,
+                                const char    *basename,
+                                int            index)
+{
+        unsigned int position;
+        unsigned int system_position;
+
+        position = gsp_app_get_xdg_position (app);
+        system_position = gsp_app_get_xdg_system_position (app);
+
+        if (system_position < index) {
+                /* it got deleted, but we don't even care about it */
+                return;
+        }
+
+        if (index < position) {
+                /* it got deleted, but in a position earlier than the current
+                 * one. This happens when the user file was changed and became
+                 * identical to the system file; in this case, the user file is
+                 * simply removed. */
+                 g_assert (index == 0);
+                 return;
+        }
+
+        if (position == index &&
+            (system_position == index || system_position == G_MAXUINT)) {
+                /* the file used by the user was deleted, and there's no other
+                 * file in system directories. So it really got deleted. */
+                _gsp_app_manager_app_removed (manager, app);
+                return;
+        }
+
+        if (system_position == index) {
+                /* then we know that position != index; we just hae to tell
+                 * GspApp if there's still a system directory containing this
+                 * basename */
+                int new_system;
+
+                new_system = _gsp_app_manager_find_dir_with_basename (manager,
+                                                                      basename,
+                                                                      index);
+                if (new_system < 0) {
+                        gsp_app_set_xdg_system_position (app, G_MAXUINT);
+                } else {
+                        gsp_app_set_xdg_system_position (app, new_system);
+                }
+
+                return;
+        }
+
+        if (position == index) {
+                /* then we know that system_position != G_MAXUINT; we need to
+                 * tell GspApp to change position to system_position */
+                const char *dir;
+
+                dir = gsp_app_manager_get_dir (manager, system_position);
+                if (dir) {
+                        char *path;
+
+                        path = g_build_filename (dir, basename, NULL);
+                        gsp_app_reload_at (app, path,
+                                           (unsigned int) system_position);
+                        g_free (path);
+                } else {
+                        _gsp_app_manager_app_removed (manager, app);
+                }
+
+                return;
+        }
+
+        g_assert_not_reached ();
+}
+
+static gboolean
+gsp_app_manager_xdg_dir_monitor (GFileMonitor      *monitor,
+                                 GFile             *child,
+                                 GFile             *other_file,
+                                 GFileMonitorEvent  flags,
+                                 gpointer           data)
+{
+        GspAppManager *manager;
+        GspApp        *old_app;
+        GspApp        *app;
+        GFile         *parent;
+        char          *basename;
+        char          *dir;
+        char          *path;
+        int            index;
+
+        manager = GSP_APP_MANAGER (data);
+
+        basename = g_file_get_basename (child);
+        if (!g_str_has_suffix (basename, ".desktop")) {
+                /* not a desktop file, we can ignore */
+                g_free (basename);
+                return TRUE;
+        }
+        old_app = gsp_app_manager_find_app_with_basename (manager, basename);
+
+        parent = g_file_get_parent (child);
+        dir = g_file_get_path (parent);
+        g_object_unref (parent);
+
+        index = gsp_app_manager_get_dir_index (manager, dir);
+        if (index < 0) {
+                /* not a directory we know; should never happen, though */
+                g_free (dir);
+                return TRUE;
+        }
+
+        path = g_file_get_path (child);
+
+        switch (flags) {
+        case G_FILE_MONITOR_EVENT_CHANGED:
+        case G_FILE_MONITOR_EVENT_CREATED:
+                /* we just do as if it was a new file: GspApp is clever enough
+                 * to do the right thing */
+                app = gsp_app_new (path, (unsigned int) index);
+
+                /* we didn't have this app before, so add it */
+                if (old_app == NULL && app != NULL) {
+                        gsp_app_manager_add (manager, app);
+                        g_object_unref (app);
+                }
+                /* else: it was just updated, GspApp took care of
+                 * sending the event */
+                break;
+        case G_FILE_MONITOR_EVENT_DELETED:
+                if (!old_app) {
+                        /* it got deleted, but we don't know about it, so
+                         * nothing to do */
+                        break;
+                }
+
+                _gsp_app_manager_handle_delete (manager, old_app,
+                                                basename, index);
+                break;
+        default:
+                break;
+        }
+
+        g_free (path);
+        g_free (dir);
+        g_free (basename);
+
+        return TRUE;
+}
+
+/*
+ * Initialization
+ */
+
+static void
+_gsp_app_manager_fill_from_dir (GspAppManager *manager,
+                                GspXdgDir     *xdgdir)
+{
+        GFile      *file;
+        GDir       *dir;
+        const char *name;
+
+        file = g_file_new_for_path (xdgdir->dir);
+        xdgdir->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE,
+                                                    NULL, NULL);
+        g_object_unref (file);
+
+        if (xdgdir->monitor) {
+                g_signal_connect (xdgdir->monitor, "changed",
+                                  G_CALLBACK (gsp_app_manager_xdg_dir_monitor),
+                                  manager);
+        }
+
+        dir = g_dir_open (xdgdir->dir, 0, NULL);
+        if (!dir) {
+                return;
+        }
+
+        while ((name = g_dir_read_name (dir))) {
+                GspApp *app;
+                char   *desktop_file_path;
+
+                if (!g_str_has_suffix (name, ".desktop")) {
+                        continue;
+                }
+
+                desktop_file_path = g_build_filename (xdgdir->dir, name, NULL);
+                app = gsp_app_new (desktop_file_path, xdgdir->index);
+
+                if (app != NULL) {
+                        gsp_app_manager_add (manager, app);
+                        g_object_unref (app);
+                }
+
+                g_free (desktop_file_path);
+        }
+
+        g_dir_close (dir);
+}
+
+void
+gsp_app_manager_fill (GspAppManager *manager)
+{
+        char **autostart_dirs;
+        int    i;
+        GspAppManagerPrivate *priv;
+
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        if (priv->apps != NULL)
+                return;
+
+        autostart_dirs = gsm_util_get_autostart_dirs ();
+        /* we always assume that the first directory is the user one */
+        g_assert (g_str_has_prefix (autostart_dirs[0],
+                                    g_get_user_config_dir ()));
+
+        for (i = 0; autostart_dirs[i] != NULL; i++) {
+                GspXdgDir *xdgdir;
+
+                if (gsp_app_manager_get_dir_index (manager,
+                                                   autostart_dirs[i]) >= 0) {
+                        continue;
+                }
+
+                xdgdir = _gsp_xdg_dir_new (autostart_dirs[i], i);
+                priv->dirs = g_slist_prepend (priv->dirs,
+                                                       xdgdir);
+
+                _gsp_app_manager_fill_from_dir (manager, xdgdir);
+        }
+
+        g_strfreev (autostart_dirs);
+}
+
+/*
+ * App handling
+ */
+
+static void
+_gsp_app_manager_app_unref (GspApp        *app,
+                            GspAppManager *manager)
+{
+        g_signal_handlers_disconnect_by_func (app,
+                                              _gsp_app_manager_app_removed,
+                                              manager);
+        g_object_unref (app);
+}
+
+static void
+_gsp_app_manager_app_removed (GspAppManager *manager,
+                              GspApp        *app)
+{
+        GspAppManagerPrivate *priv;
+
+        _gsp_app_manager_emit_removed (manager, app);
+        priv = gsp_app_manager_get_instance_private (manager);
+        priv->apps = g_slist_remove (priv->apps, app);
+        _gsp_app_manager_app_unref (app, manager);
+}
+
+void
+gsp_app_manager_add (GspAppManager *manager,
+                     GspApp        *app)
+{
+        GspAppManagerPrivate *priv;
+
+        g_return_if_fail (GSP_IS_APP_MANAGER (manager));
+        g_return_if_fail (GSP_IS_APP (app));
+
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        priv->apps = g_slist_prepend (priv->apps,
+                                      g_object_ref (app));
+        g_signal_connect_swapped (app, "removed",
+                                  G_CALLBACK (_gsp_app_manager_app_removed),
+                                  manager);
+        _gsp_app_manager_emit_added (manager, app);
+}
+
+GspApp *
+gsp_app_manager_find_app_with_basename (GspAppManager *manager,
+                                        const char    *basename)
+{
+        GSList *l;
+        GspApp *app;
+        GspAppManagerPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP_MANAGER (manager), NULL);
+        g_return_val_if_fail (basename != NULL, NULL);
+
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        for (l = priv->apps; l != NULL; l = l->next) {
+                app = GSP_APP (l->data);
+                if (strcmp (basename, gsp_app_get_basename (app)) == 0)
+                        return app;
+        }
+
+        return NULL;
+}
+
+/*
+ * Singleton
+ */
+
+GspAppManager *
+gsp_app_manager_get (void)
+{
+        static GspAppManager *manager = NULL;
+
+        if (manager == NULL) {
+                manager = g_object_new (GSP_TYPE_APP_MANAGER, NULL);
+                return manager;
+        } else {
+                return g_object_ref (manager);
+        }
+}
+
+GSList *
+gsp_app_manager_get_apps (GspAppManager *manager)
+{
+        GspAppManagerPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP_MANAGER (manager), NULL);
+
+        priv = gsp_app_manager_get_instance_private (manager);
+
+        return g_slist_copy (priv->apps);
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/70.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/70.html new file mode 100644 index 0000000..99b40f6 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/70.html @@ -0,0 +1,381 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/* eggtreednd.h
+ * Copyright (C) 2001  Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __EGG_TREE_MULTI_DND_H__
+#define __EGG_TREE_MULTI_DND_H__
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_TREE_MULTI_DRAG_SOURCE            (egg_tree_multi_drag_source_get_type ())
+#define EGG_TREE_MULTI_DRAG_SOURCE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSource))
+#define EGG_IS_TREE_MULTI_DRAG_SOURCE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE))
+#define EGG_TREE_MULTI_DRAG_SOURCE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), EGG_TYPE_TREE_MULTI_DRAG_SOURCE, EggTreeMultiDragSourceIface))
+
+typedef struct _EggTreeMultiDragSource      EggTreeMultiDragSource; /* Dummy typedef */
+typedef struct _EggTreeMultiDragSourceIface EggTreeMultiDragSourceIface;
+
+struct _EggTreeMultiDragSourceIface
+{
+    GTypeInterface g_iface;
+
+    /* VTable - not signals */
+    gboolean     (* row_draggable)        (EggTreeMultiDragSource   *drag_source,
+                                           GList                    *path_list);
+
+    gboolean     (* drag_data_get)        (EggTreeMultiDragSource   *drag_source,
+                                           GList                    *path_list,
+                                           GtkSelectionData         *selection_data);
+
+    gboolean     (* drag_data_delete)     (EggTreeMultiDragSource *drag_source,
+                                           GList                  *path_list);
+};
+
+GType    egg_tree_multi_drag_source_get_type         (void) G_GNUC_CONST;
+
+/* Returns whether the given row can be dragged */
+gboolean egg_tree_multi_drag_source_row_draggable    (EggTreeMultiDragSource *drag_source,
+        GList                  *path_list);
+
+/* Deletes the given row, or returns FALSE if it can't */
+gboolean egg_tree_multi_drag_source_drag_data_delete (EggTreeMultiDragSource *drag_source,
+        GList                  *path_list);
+
+
+/* Fills in selection_data with type selection_data->target based on the row
+ * denoted by path, returns TRUE if it does anything
+ */
+gboolean egg_tree_multi_drag_source_drag_data_get    (EggTreeMultiDragSource *drag_source,
+        GList                  *path_list,
+        GtkSelectionData       *selection_data);
+void     egg_tree_multi_drag_add_drag_support        (GtkTreeView            *tree_view);
+
+G_END_DECLS
+
+#endif /* __EGG_TREE_MULTI_DND_H__ */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/71.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/71.html new file mode 100644 index 0000000..2541fe2 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/71.html @@ -0,0 +1,1271 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
/*
+ * Copyright (C) 2010      Novell, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author:
+ *   Vincent Untz <vuntz@gnome.org>
+ *
+ * Most of the code comes from desktop-effects [1], released under GPLv2+.
+ * desktop-effects was written by:
+ *   Soren Sandmann <sandmann@redhat.com>
+ *
+ * [1] http://git.fedorahosted.org/git/?p=desktop-effects.git;a=blob_plain;f=desktop-effects.c;hb=HEAD
+ */
+
+/*
+ * Here's the rationale behind this helper, quoting Owen, in his mail to the
+ * release team:
+ * (http://mail.gnome.org/archives/release-team/2010-June/msg00079.html)
+ *
+ * """
+ * There are some limits to what we can do here automatically without
+ * knowing anything about the driver situation on the system. The basic
+ * problem is that there are all sorts of suck:
+ *
+ *  * No GL at all. This typically only happens if a system is
+ *    misconfigured.
+ *
+ *  * Only software GL. This one is easy to detect. We have code in
+ *    the Fedora desktop-effects tool, etc.
+ *
+ *  * GL that isn't featureful enough. (Tiny texture size limits, no
+ *    texture-from-pixmap, etc.) Possible to detect with more work, but
+ *    largely a fringe case.
+ *
+ *  * Buggy GL. This isn't possible to detect. Except for the case where
+ *    all GL programs crash. For that reason, we probably don't want
+ *    gnome-session to directly try and do any GL detection; better to
+ *    use a helper binary.
+ *
+ *  * Horribly slow hardware GL. We could theoretically develop some sort
+ *    of benchmark, but it's a tricky area. And how slow is too slow?
+ * """
+ *
+ * Some other tools are doing similar checks:
+ *  - desktop-effects (Fedora Config Tool) [1]
+ *  - drak3d (Mandriva Config Tool) [2]
+ *  - compiz-manager (Compiz wrapper) [3]
+ *
+ * [1] http://git.fedorahosted.org/git/?p=desktop-effects.git;a=blob_plain;f=desktop-effects.c;hb=HEAD
+ * [2] http://svn.mandriva.com/cgi-bin/viewvc.cgi/soft/drak3d/trunk/lib/Xconfig/glx.pm?view=markup
+ * [3] http://git.compiz.org/fusion/misc/compiz-manager/tree/compiz-manager
+ */
+
+/* for strcasestr */
+#define _GNU_SOURCE
+
+#include <ctype.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <regex.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __FreeBSD__
+#include <kenv.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/extensions/Xcomposite.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <GL/gl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <GL/glx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-session-check-accelerated-common.h"
+
+#define SIZE_UNSET 0
+#define SIZE_ERROR -1
+static int max_texture_size = SIZE_UNSET;
+static int max_renderbuffer_size = SIZE_UNSET;
+static gboolean has_llvmpipe = FALSE;
+
+static inline void
+_print_error (const char *str)
+{
+        fprintf (stderr, "mate-session-is-accelerated: %s\n", str);
+}
+
+#define CMDLINE_UNSET -1
+#define CMDLINE_NON_FALLBACK_FORCED 0
+#define CMDLINE_FALLBACK_FORCED 1
+
+#if defined(__linux__)
+static int
+_parse_kcmdline (void)
+{
+        int ret = CMDLINE_UNSET;
+        GRegex *regex;
+        GMatchInfo *match;
+        char *contents;
+        char *word;
+        const char *arg;
+
+        if (!g_file_get_contents ("/proc/cmdline", &contents, NULL, NULL))
+                return ret;
+
+        regex = g_regex_new ("mate.fallback=(\\S+)", 0, G_REGEX_MATCH_NOTEMPTY, NULL);
+        if (!g_regex_match (regex, contents, G_REGEX_MATCH_NOTEMPTY, &match))
+                goto out;
+
+        word = g_match_info_fetch (match, 0);
+        g_debug ("Found command-line match '%s'", word);
+        arg = word + strlen ("mate.fallback=");
+        if (*arg != '0' && *arg != '1')
+                fprintf (stderr, "mate-session-check-accelerated: Invalid value '%s' for mate.fallback passed in kernel command line.\n", arg);
+        else
+                ret = atoi (arg);
+        g_free (word);
+
+out:
+        g_match_info_free (match);
+        g_regex_unref (regex);
+        g_free (contents);
+
+        g_debug ("Command-line parsed to %d", ret);
+
+        return ret;
+}
+#elif defined(__FreeBSD__)
+static int
+_parse_kcmdline (void)
+{
+        int ret = CMDLINE_UNSET;
+        char value[KENV_MVALLEN];
+
+        /* a compile time check to avoid unexpected stack overflow */
+        _Static_assert(KENV_MVALLEN < 1024 * 1024, "KENV_MVALLEN is too large");
+
+        if (kenv (KENV_GET, "mate.fallback", value, KENV_MVALLEN) == -1)
+                return ret;
+
+        if (*value != '0' && *value != '1')
+                fprintf (stderr, "mate-session-is-accelerated: Invalid value '%s' for mate.fallback passed in kernel environment.\n", value);
+        else
+                ret = atoi (value);
+
+        g_debug ("Kernel environment parsed to %d", ret);
+
+        return ret;
+}
+#else
+static int
+_parse_kcmdline (void)
+{
+        return CMDLINE_UNSET;
+}
+#endif
+
+static gboolean
+_has_composite (Display *display)
+{
+        int dummy1, dummy2;
+
+        return XCompositeQueryExtension (display, &dummy1, &dummy2);
+}
+
+static gboolean
+_is_comment (const char *line)
+{
+        while (*line && isspace(*line))
+                line++;
+
+        if (*line == '#' || *line == '\0')
+                return TRUE;
+        return FALSE;
+}
+
+static gboolean
+_is_gl_renderer_blacklisted (const char *renderer)
+{
+        FILE *blacklist;
+        char *line = NULL;
+        size_t line_len = 0;
+        gboolean ret = TRUE;
+
+        blacklist = fopen(PKGDATADIR "/hardware-compatibility", "r");
+        if (blacklist == NULL)
+                goto out;
+
+        while (getline (&line, &line_len, blacklist) != -1) {
+                int whitelist = 0;
+                const char *re_str;
+                regex_t re;
+                int status;
+
+                if (line == NULL)
+                        break;
+
+                /* Drop trailing \n */
+                line[strlen(line) - 1] = '\0';
+
+                if (_is_comment (line)) {
+                        free (line);
+                        line = NULL;
+                        continue;
+                }
+
+                if (line[0] == '+')
+                        whitelist = 1;
+                else if (line[0] == '-')
+                        whitelist = 0;
+                else {
+                        _print_error ("Invalid syntax in this line for hardware compatibility:");
+                        _print_error (line);
+                        free (line);
+                        line = NULL;
+                        continue;
+                }
+
+                re_str = line + 1;
+
+                if (regcomp (&re, re_str, REG_EXTENDED|REG_ICASE|REG_NOSUB) != 0) {
+                        _print_error ("Cannot use this regular expression for hardware compatibility:");
+                        _print_error (re_str);
+                } else {
+                        status = regexec (&re, renderer, 0, NULL, 0);
+                        regfree(&re);
+
+                        if (status == 0) {
+                                if (whitelist)
+                                        ret = FALSE;
+                                goto out;
+                        }
+                }
+
+                free (line);
+                line = NULL;
+        }
+
+        ret = FALSE;
+
+out:
+        if (line != NULL)
+                free (line);
+
+        if (blacklist != NULL)
+                fclose (blacklist);
+
+        return ret;
+}
+
+static char *
+_get_hardware_gl (Display *display)
+{
+        int screen;
+        Window root;
+        XVisualInfo *visual = NULL;
+        GLXContext context = NULL;
+        XSetWindowAttributes cwa = { 0 };
+        Window window = None;
+        char *renderer = NULL;
+
+        int attrlist[] = {
+                GLX_RGBA,
+                GLX_RED_SIZE, 1,
+                GLX_GREEN_SIZE, 1,
+                GLX_BLUE_SIZE, 1,
+                GLX_DOUBLEBUFFER,
+                None
+        };
+
+        screen = DefaultScreen (display);
+        root = RootWindow (display, screen);
+
+        visual = glXChooseVisual (display, screen, attrlist);
+        if (!visual)
+                goto out;
+
+        context = glXCreateContext (display, visual, NULL, True);
+        if (!context)
+                goto out;
+
+        cwa.colormap = XCreateColormap (display, root,
+                                        visual->visual, AllocNone);
+        cwa.background_pixel = 0;
+        cwa.border_pixel = 0;
+        window = XCreateWindow (display, root,
+                                0, 0, 1, 1, 0,
+                                visual->depth, InputOutput, visual->visual,
+                                CWColormap | CWBackPixel | CWBorderPixel,
+                                &cwa);
+
+        if (!glXMakeCurrent (display, window, context))
+                goto out;
+
+        renderer = g_strdup ((const char *) glGetString (GL_RENDERER));
+        if (_is_gl_renderer_blacklisted (renderer)) {
+                g_clear_pointer (&renderer, g_free);
+                goto out;
+        }
+        if (renderer && strcasestr (renderer, "llvmpipe"))
+		has_llvmpipe = TRUE;
+
+        /* we need to get the max texture and renderbuffer sizes while we have
+         * a context, but we'll check their values later */
+
+        glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size);
+        if (glGetError() != GL_NO_ERROR)
+                max_texture_size = SIZE_ERROR;
+
+        glGetIntegerv (GL_MAX_RENDERBUFFER_SIZE_EXT, &max_renderbuffer_size);
+        if (glGetError() != GL_NO_ERROR)
+                max_renderbuffer_size = SIZE_ERROR;
+
+out:
+        glXMakeCurrent (display, None, None);
+        if (context)
+                glXDestroyContext (display, context);
+        if (window)
+                XDestroyWindow (display, window);
+        if (cwa.colormap)
+                XFreeColormap (display, cwa.colormap);
+
+        return renderer;
+}
+
+static gboolean
+_has_extension (const char *extension_list,
+                const char *extension)
+{
+        char **extensions;
+        guint i;
+        gboolean ret;
+
+        g_return_val_if_fail (extension != NULL, TRUE);
+
+        /* Extension_list is one big string, containing extensions
+         * separated by spaces. */
+        if (extension_list == NULL)
+                return FALSE;
+
+        ret = FALSE;
+
+        extensions = g_strsplit (extension_list, " ", -1);
+        if (extensions == NULL)
+                return FALSE;
+
+        for (i = 0; extensions[i] != NULL; i++) {
+                if (g_str_equal (extensions[i], extension)) {
+                        ret = TRUE;
+                        break;
+                }
+        }
+
+        g_strfreev (extensions);
+
+        return ret;
+}
+
+static gboolean
+_has_texture_from_pixmap (Display *display)
+{
+        int screen;
+        const char *server_extensions;
+        const char *client_extensions;
+        gboolean ret = FALSE;
+
+        screen = DefaultScreen (display);
+
+        server_extensions = glXQueryServerString (display, screen,
+                                                  GLX_EXTENSIONS);
+        if (!_has_extension (server_extensions,
+                            "GLX_EXT_texture_from_pixmap"))
+                goto out;
+
+        client_extensions = glXGetClientString (display, GLX_EXTENSIONS);
+        if (!_has_extension (client_extensions,
+                            "GLX_EXT_texture_from_pixmap"))
+                goto out;
+
+        ret = TRUE;
+
+out:
+        return ret;
+}
+
+static void
+_set_max_screen_size_property (Display *display, int screen, int size)
+{
+        Atom max_screen_size_atom;
+
+        max_screen_size_atom = XInternAtom (display, "_GNOME_MAX_SCREEN_SIZE",
+                                            False);
+
+        /* Will be read by gnome-settings-daemon and
+         * gnome-control-center to avoid display configurations where 3D
+         * is not available (and would break gnome-shell) */
+        XChangeProperty (display, RootWindow(display, screen),
+                         max_screen_size_atom,
+                         XA_CARDINAL, 32, PropModeReplace,
+                         (unsigned char *)&size, 1);
+
+        XSync(display, False);
+}
+
+static gboolean
+_is_max_texture_size_big_enough (Display *display)
+{
+        int screen, size;
+
+        screen = DefaultScreen (display);
+        size = MIN(max_renderbuffer_size, max_texture_size);
+        if (size < DisplayWidth (display, screen) ||
+            size < DisplayHeight (display, screen))
+                return FALSE;
+
+        _set_max_screen_size_property (display, screen, size);
+
+        return TRUE;
+}
+
+static gboolean print_renderer = FALSE;
+
+static const GOptionEntry entries[] = {
+        { "print-renderer", 'p', 0, G_OPTION_ARG_NONE, &print_renderer, "Print GL renderer name", NULL },
+        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL },
+};
+
+int
+main (int argc, char **argv)
+{
+        int             kcmdline_parsed;
+        Display        *display = NULL;
+        int             ret = HELPER_NO_ACCEL;
+        GOptionContext *context;
+        GError         *error = NULL;
+        char           *renderer = NULL;
+
+        setlocale (LC_ALL, "");
+
+        context = g_option_context_new (NULL);
+        g_option_context_add_main_entries (context, entries, NULL);
+
+        if (!g_option_context_parse (context, &argc, &argv, &error)) {
+                g_error ("Can't parse command line: %s\n", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+        kcmdline_parsed = _parse_kcmdline ();
+        if (kcmdline_parsed > CMDLINE_UNSET) {
+                if (kcmdline_parsed == CMDLINE_NON_FALLBACK_FORCED) {
+                        _print_error ("Non-fallback mode forced by kernel command line.");
+                        ret = HELPER_ACCEL;
+                        goto out;
+                } else if (kcmdline_parsed == CMDLINE_FALLBACK_FORCED) {
+                        _print_error ("Fallback mode forced by kernel command line.");
+                        goto out;
+                }
+        }
+
+        display = XOpenDisplay (NULL);
+        if (!display) {
+                _print_error ("No X display.");
+                goto out;
+        }
+
+        if (!_has_composite (display)) {
+                _print_error ("No composite extension.");
+                goto out;
+        }
+
+        renderer = _get_hardware_gl (display);
+        if (!renderer) {
+                _print_error ("No hardware 3D support.");
+                goto out;
+        }
+
+        if (!_has_texture_from_pixmap (display)) {
+                _print_error ("No GLX_EXT_texture_from_pixmap support.");
+                goto out;
+        }
+
+        if (!_is_max_texture_size_big_enough (display)) {
+                _print_error ("GL_MAX_{TEXTURE,RENDERBUFFER}_SIZE is too small.");
+                goto out;
+        }
+
+        ret = has_llvmpipe ? HELPER_SOFTWARE_RENDERING : HELPER_ACCEL;
+
+        if (print_renderer)
+                g_print ("%s", renderer);
+
+out:
+        if (display)
+                XCloseDisplay (display);
+        g_option_context_free (context);
+        g_free (renderer);
+
+        return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/72.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/72.html new file mode 100644 index 0000000..83de92a --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/72.html @@ -0,0 +1,707 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */
+/*
+ *
+ * Copyright (C) 2016 Endless Mobile, Inc
+ * Copyright (C) 2016-2021 MATE Developers
+ *
+ * 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Author:
+ *   Cosimo Cecchi <cosimo@endlessm.com>
+ */
+
+/* for strcasestr */
+#define _GNU_SOURCE
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef GDK_WINDOWING_X11
+#define GL_GLEXT_PROTOTYPES
+
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <GLES2/gl2.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <GLES2/gl2ext.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <EGL/egl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <EGL/eglext.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "mate-session-check-accelerated-common.h"
+
+#ifdef GDK_WINDOWING_X11
+static EGLDisplay
+get_display (void *native)
+{
+        EGLDisplay dpy = NULL;
+        const char *client_exts = eglQueryString (NULL, EGL_EXTENSIONS);
+
+        if (g_strstr_len (client_exts, -1, "EGL_KHR_platform_base")) {
+                PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
+                        (void *) eglGetProcAddress ("eglGetPlatformDisplay");
+
+                if (get_platform_display)
+                        dpy = get_platform_display (EGL_PLATFORM_X11_KHR, native, NULL);
+
+                if (dpy)
+                        return dpy;
+        }
+
+        if (g_strstr_len (client_exts, -1, "EGL_EXT_platform_base")) {
+                PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display =
+                        (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT");
+
+                if (get_platform_display)
+                        dpy = get_platform_display (EGL_PLATFORM_X11_KHR, native, NULL);
+
+                if (dpy)
+                        return dpy;
+        }
+
+        return eglGetDisplay ((EGLNativeDisplayType) native);
+}
+
+static char *
+get_gles_renderer (void)
+{
+        /* Select GLESv2 config */
+        EGLint attribs[] = {
+                EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+                EGL_RED_SIZE, 1,
+                EGL_GREEN_SIZE, 1,
+                EGL_BLUE_SIZE, 1,
+                EGL_NONE
+        };
+
+        EGLint ctx_attribs[] = {
+                EGL_CONTEXT_CLIENT_VERSION, 2,
+                EGL_NONE
+        };
+
+        gboolean egl_inited = FALSE;
+        GdkDisplay *gdk_dpy;
+        Display *display;
+        Window win = None;
+        EGLContext egl_ctx = NULL;
+        EGLDisplay egl_dpy = NULL;
+        EGLSurface egl_surf = NULL;
+        char *renderer = NULL;
+
+        gdk_dpy = gdk_display_get_default ();
+        gdk_x11_display_error_trap_push (gdk_dpy);
+        display = GDK_DISPLAY_XDISPLAY (gdk_dpy);
+        egl_dpy = get_display (display);
+        if (!egl_dpy) {
+                g_warning ("eglGetDisplay() failed");
+                goto out;
+        }
+
+        EGLint egl_major, egl_minor;
+        if (!eglInitialize (egl_dpy, &egl_major, &egl_minor)) {
+                g_warning ("eglInitialize() failed");
+                goto out;
+        }
+
+        egl_inited = TRUE;
+
+        EGLint num_configs;
+        EGLConfig config;
+        if (!eglChooseConfig (egl_dpy, attribs, &config, 1, &num_configs)) {
+                g_warning ("Failed to get EGL configuration");
+                goto out;
+        }
+
+        EGLint vid;
+        if (!eglGetConfigAttrib (egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
+                g_warning ("Failed to get EGL visual");
+                goto out;
+        }
+
+        /* The X window visual must match the EGL config */
+        XVisualInfo *vis_info, vis_template;
+        int num_visuals;
+        vis_template.visualid = vid;
+        vis_info = XGetVisualInfo (display, VisualIDMask, &vis_template, &num_visuals);
+        if (!vis_info) {
+                g_warning ("Failed to get X visual");
+                goto out;
+        }
+
+        XSetWindowAttributes attr;
+        attr.colormap = XCreateColormap (display, DefaultRootWindow (display),
+                                         vis_info->visual, AllocNone);
+        win = XCreateWindow (display, DefaultRootWindow (display),
+                             0, 0, /* x, y */
+                             1, 1, /* width, height */
+                             0,    /* border_width */
+                             vis_info->depth, InputOutput,
+                             vis_info->visual, CWColormap, &attr);
+        XFree (vis_info);
+
+        eglBindAPI (EGL_OPENGL_ES_API);
+
+        egl_ctx = eglCreateContext (egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs);
+        if (!egl_ctx) {
+                g_warning ("Failed to create EGL context");
+                goto out;
+        }
+
+        egl_surf = eglCreateWindowSurface (egl_dpy, config, win, NULL);
+        if (!egl_surf) {
+                g_warning ("Failed to create EGL surface");
+                goto out;
+        }
+
+        if (!eglMakeCurrent (egl_dpy, egl_surf, egl_surf, egl_ctx)) {
+                g_warning ("eglMakeCurrent() failed");
+                goto out;
+        }
+
+        renderer = g_strdup ((const char *) glGetString (GL_RENDERER));
+
+ out:
+        if (egl_ctx)
+                eglDestroyContext (egl_dpy, egl_ctx);
+        if (egl_surf)
+                eglDestroySurface (egl_dpy, egl_surf);
+        if (egl_inited)
+                eglTerminate (egl_dpy);
+        if (win != None)
+                XDestroyWindow (display, win);
+
+        gdk_x11_display_error_trap_pop_ignored (gdk_dpy);
+        return renderer;
+}
+#endif
+
+static gboolean print_renderer = FALSE;
+
+static const GOptionEntry entries[] = {
+        { "print-renderer", 'p', 0, G_OPTION_ARG_NONE, &print_renderer, "Print EGL renderer name", NULL },
+        { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL },
+};
+
+int
+main (int argc,
+      char **argv)
+{
+        GOptionContext *context;
+        int ret = HELPER_NO_ACCEL;
+        GError *error = NULL;
+
+        setlocale (LC_ALL, "");
+
+        context = g_option_context_new (NULL);
+        g_option_context_add_group (context, gtk_get_option_group (TRUE));
+        g_option_context_add_main_entries (context, entries, NULL);
+
+        if (!g_option_context_parse (context, &argc, &argv, &error)) {
+                g_error ("Can't parse command line: %s\n", error->message);
+                g_error_free (error);
+                goto out;
+        }
+
+#ifdef GDK_WINDOWING_X11
+        char *renderer = get_gles_renderer ();
+        if (renderer != NULL) {
+                if (print_renderer)
+                        g_print ("%s", renderer);
+                if (strcasestr (renderer, "llvmpipe"))
+                        ret = HELPER_SOFTWARE_RENDERING;
+                else
+                        ret = HELPER_ACCEL;
+        }
+        g_free (renderer);
+#endif
+
+out:
+        g_option_context_free (context);
+        return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/73.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/73.html new file mode 100644 index 0000000..e26b0e8 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/73.html @@ -0,0 +1,893 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
/* -*- mode:c; c-basic-offset: 8; indent-tabs-mode: nil; -*- */
+/* Tool to set the property _GNOME_SESSION_ACCELERATED on the root window */
+/*
+ * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author:
+ *   Colin Walters <walters@verbum.org>
+ */
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <epoxy/gl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <X11/Xatom.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "mate-session-check-accelerated-common.h"
+
+/* Wait up to this long for a running check to finish */
+#define PROPERTY_CHANGE_TIMEOUT 5000
+
+/* Values used for the _GNOME_SESSION_ACCELERATED root window property */
+#define NO_ACCEL            0
+#define HAVE_ACCEL          1
+#define ACCEL_CHECK_RUNNING 2
+
+static Atom is_accelerated_atom;
+static Atom is_software_rendering_atom;
+static Atom renderer_atom;
+static gboolean property_changed;
+
+static gboolean
+on_property_notify_timeout (gpointer data)
+{
+        gtk_main_quit ();
+        return FALSE;
+}
+
+static GdkFilterReturn
+property_notify_filter (GdkXEvent *xevent,
+                        GdkEvent  *event,
+                        gpointer   data)
+{
+        XPropertyEvent *ev = xevent;<--- Variable 'ev' can be declared as pointer to const
+
+        if (ev->type == PropertyNotify && ev->atom == is_accelerated_atom) {
+                property_changed = TRUE;
+                gtk_main_quit ();
+        }
+
+        return GDK_FILTER_CONTINUE;
+}
+
+static gboolean
+wait_for_property_notify (void)
+{
+        GdkDisplay *display;
+        GdkScreen *screen;
+        GdkWindow *root;
+        Window rootwin;
+
+        property_changed = FALSE;
+
+        display = gdk_display_get_default ();
+        screen = gdk_display_get_default_screen (display);
+        root = gdk_screen_get_root_window (screen);
+        rootwin = gdk_x11_window_get_xid (root);
+
+        XSelectInput (GDK_DISPLAY_XDISPLAY (display), rootwin, PropertyChangeMask);
+        gdk_window_add_filter (root, property_notify_filter, NULL);
+        g_timeout_add (PROPERTY_CHANGE_TIMEOUT, on_property_notify_timeout, NULL);
+
+        gtk_main ();
+
+        return property_changed;
+}
+
+static char *
+get_gtk_gles_renderer (void)
+{
+        GtkWidget *win;
+        GdkGLContext *context;
+        char *renderer = NULL;
+
+        win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+        gtk_widget_realize (win);
+        context = gdk_window_create_gl_context (gtk_widget_get_window (win), NULL);
+        if (!context)
+                return NULL;
+        gdk_gl_context_make_current (context);
+        renderer = g_strdup ((char *) glGetString (GL_RENDERER));
+        gdk_gl_context_clear_current ();
+        g_object_unref (context);
+
+        return renderer;
+}
+
+static gboolean
+is_discrete_gpu_check (void)
+{
+	const char *dri_prime;
+
+	dri_prime = g_getenv ("DRI_PRIME");
+	if (!dri_prime)
+		return FALSE;
+	if (*dri_prime != '1')
+		return FALSE;
+	return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+        GdkDisplay *display = NULL;
+        int estatus;
+        char *gl_helper_argv[] = { LIBEXECDIR "/mate-session-check-accelerated-gl-helper", "--print-renderer", NULL };
+#ifdef HAVE_GLESV2
+        char *gles_helper_argv[] = { LIBEXECDIR "/mate-session-check-accelerated-gles-helper", "--print-renderer", NULL };
+        GError *gles_error = NULL;
+        char *gles_renderer_string = NULL;
+#endif
+        char *renderer_string = NULL;
+        char *gl_renderer_string = NULL;
+        gboolean gl_software_rendering = FALSE, gles_software_rendering = FALSE;
+        Window rootwin;
+        glong is_accelerated, is_software_rendering;
+        GError *gl_error = NULL;
+
+        gtk_init (NULL, NULL);
+
+        /* mate-session-check-accelerated gets run before X is started in the wayland
+         * case, and it currently requires X. Until we have that working, just always
+         * assume wayland will work.
+         * Also make sure that we don't read cached information about the first GPU
+         * when requesting information about the second.
+         */
+        if (is_discrete_gpu_check () || g_strcmp0 (g_getenv ("XDG_SESSION_TYPE"), "x11") != 0) {
+                renderer_string = get_gtk_gles_renderer ();
+                if (renderer_string) {
+                        g_print ("%s", renderer_string);
+                        g_free (renderer_string);
+                        return 0;
+                }
+                return 1;
+        }
+
+        display = gdk_display_get_default ();
+        /* when running on X11 with a nested wayland GDK will default to wayland
+         * so looking for X11 atoms will not work (and crash).
+         */
+        if (!GDK_IS_X11_DISPLAY (display)) {
+                g_printerr ("mate-session-check-accelerated: no X11 display found\n");
+                return 1;
+        }
+
+        rootwin = gdk_x11_get_default_root_xwindow ();
+
+        is_accelerated_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_SESSION_ACCELERATED");
+        is_software_rendering_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_IS_SOFTWARE_RENDERING");
+        renderer_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_SESSION_RENDERER");
+
+        {
+                Atom type;
+                gint format;
+                gulong nitems;
+                gulong bytes_after;
+                guchar *data;
+
+ read:
+                gdk_x11_display_error_trap_push (display);
+                XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), rootwin,
+                                    is_accelerated_atom,
+                                    0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+                                    &bytes_after, &data);
+                gdk_x11_display_error_trap_pop_ignored (display);
+
+                if (type == XA_CARDINAL) {
+                        glong *is_accelerated_ptr = (glong*) data;<--- Variable 'is_accelerated_ptr' can be declared as pointer to const
+
+                        if (*is_accelerated_ptr == ACCEL_CHECK_RUNNING) {
+                                /* Test in progress, wait */
+                                if (wait_for_property_notify ())
+                                        goto read;
+                                /* else fall through and do the check ourselves */
+
+                        } else {
+                                gdk_x11_display_error_trap_push (display);
+                                XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), rootwin,
+                                                    renderer_atom,
+                                                    0, G_MAXLONG, False, XA_STRING, &type, &format, &nitems,
+                                                    &bytes_after, &data);
+                                gdk_x11_display_error_trap_pop_ignored (display);
+
+                                if (type == XA_STRING) {
+                                        g_print ("%s", data);
+                                }
+
+                                return (*is_accelerated_ptr == 0 ? 1 : 0);
+                        }
+                }
+        }
+
+        /* We don't have the property or it's the wrong type.
+         * Try to compute it now.
+         */
+
+        /* First indicate that a test is in progress */
+        is_accelerated = ACCEL_CHECK_RUNNING;
+        is_software_rendering = FALSE;
+        estatus = 1;
+
+        XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+                         rootwin,
+                         is_accelerated_atom,
+                         XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_accelerated, 1);
+
+        gdk_display_sync (display);
+
+        /* First, try the GL helper */
+        if (g_spawn_sync (NULL, (char **) gl_helper_argv, NULL, 0,
+                           NULL, NULL, &gl_renderer_string, NULL, &estatus, &gl_error)) {
+                is_accelerated = (WEXITSTATUS(estatus) == HELPER_ACCEL);
+                gl_software_rendering = (WEXITSTATUS(estatus) == HELPER_SOFTWARE_RENDERING);
+                if (is_accelerated) {
+                        renderer_string = gl_renderer_string;
+                        goto finish;
+                }
+
+                g_printerr ("mate-session-check-accelerated: GL Helper exited with code %d\n", estatus);
+        }
+
+#ifdef HAVE_GLESV2
+        /* Then, try the GLES helper */
+        if (g_spawn_sync (NULL, (char **) gles_helper_argv, NULL, 0,
+                           NULL, NULL, &gles_renderer_string, NULL, &estatus, &gles_error)) {
+                is_accelerated = (WEXITSTATUS(estatus) == HELPER_ACCEL);
+                gles_software_rendering = (WEXITSTATUS(estatus) == HELPER_SOFTWARE_RENDERING);
+                if (is_accelerated) {
+                        renderer_string = gles_renderer_string;
+                        goto finish;
+                }
+
+                g_printerr ("mate-session-check-accelerated: GLES Helper exited with code %d\n", estatus);
+        }
+#endif
+
+        /* If we got here, GL software rendering is our best bet */
+        if (gl_software_rendering || gles_software_rendering) {
+                is_software_rendering = TRUE;
+                is_accelerated = TRUE;
+
+                if (gl_software_rendering)
+                        renderer_string = gl_renderer_string;
+#ifdef HAVE_GLESV2
+                else if (gles_software_rendering)
+                        renderer_string = gles_renderer_string;
+#endif
+
+                goto finish;
+        }
+
+        /* Both helpers failed; print their error messages */
+        if (gl_error != NULL) {
+                g_printerr ("mate-session-check-accelerated: Failed to run GL helper: %s\n", gl_error->message);
+                g_clear_error (&gl_error);
+        }
+
+#ifdef HAVE_GLESV2
+        if (gles_error != NULL) {
+                g_printerr ("mate-session-check-accelerated: Failed to run GLES helper: %s\n", gles_error->message);
+                g_clear_error (&gles_error);
+        }
+#endif
+
+ finish:
+	if (is_accelerated) {
+		XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+				rootwin,
+				is_accelerated_atom,
+				XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_accelerated, 1);
+	}
+
+	if (is_software_rendering) {
+		XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+				rootwin,
+				is_software_rendering_atom,
+				XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_software_rendering, 1);
+	}
+
+        if (renderer_string != NULL) {
+                XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
+				rootwin,
+				renderer_atom,
+				XA_STRING, 8, PropModeReplace, (guchar *) renderer_string, strlen (renderer_string));
+
+                /* Print the renderer */
+                g_print ("%s", renderer_string);
+        }
+
+        gdk_display_sync (display);
+
+        g_free (gl_renderer_string);
+#ifdef HAVE_GLESV2
+        g_free (gles_renderer_string);
+#endif
+
+        return is_accelerated ? 0 : 1;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/74.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/74.html new file mode 100644 index 0000000..f0bd2fa --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/74.html @@ -0,0 +1,733 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
/*
+ * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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, 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 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., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/wait.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#ifdef ENABLE_NLS
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* ENABLE_NLS */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+typedef enum {
+        GSM_INHIBITOR_FLAG_LOGOUT      = 1 << 0,
+        GSM_INHIBITOR_FLAG_SWITCH_USER = 1 << 1,
+        GSM_INHIBITOR_FLAG_SUSPEND     = 1 << 2,
+        GSM_INHIBITOR_FLAG_IDLE        = 1 << 3,
+        GSM_INHIBITOR_FLAG_AUTOMOUNT   = 1 << 4
+} GsmInhibitorFlags;
+
+static GsmInhibitorFlags parse_flags (const gchar *arg)
+{
+  GsmInhibitorFlags flags;
+  gchar **args;
+  gint i;
+
+  flags = 0;
+
+  args = g_strsplit (arg, ":", 0);
+  for (i = 0; args[i]; i++)
+    {
+      if (strcmp (args[i], "logout") == 0)
+        flags |= GSM_INHIBITOR_FLAG_LOGOUT;
+      else if (strcmp (args[i], "switch-user") == 0)
+        flags |= GSM_INHIBITOR_FLAG_SWITCH_USER;
+      else if (strcmp (args[i], "suspend") == 0)
+        flags |= GSM_INHIBITOR_FLAG_SUSPEND;
+      else if (strcmp (args[i], "idle") == 0)
+        flags |= GSM_INHIBITOR_FLAG_IDLE;
+      else if (strcmp (args[i], "automount") == 0)
+        flags |= GSM_INHIBITOR_FLAG_AUTOMOUNT;
+      else
+        g_print ("Ignoring inhibit argument: %s\n", args[i]);
+    }
+
+  g_strfreev (args);
+
+  return flags;
+}
+
+static gboolean inhibit (const gchar       *app_id,
+                         const gchar       *reason,
+                         GsmInhibitorFlags flags)
+{
+  GDBusConnection *bus;
+  GVariant *ret;
+  GError *error = NULL;
+
+  bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+
+  if (bus == NULL)
+    {
+      g_warning ("Failed to connect to session bus: %s", error->message);
+      g_error_free (error);
+      return FALSE;
+    }
+
+  ret = g_dbus_connection_call_sync (bus,
+                               "org.gnome.SessionManager",
+                               "/org/gnome/SessionManager",
+                               "org.gnome.SessionManager",
+                               "Inhibit",
+                               g_variant_new ("(susu)",
+                                              app_id, 0, reason, flags),
+                               G_VARIANT_TYPE ("(u)"),
+                               0,
+                               G_MAXINT,
+                               NULL,
+                               &error);
+
+  if (ret == NULL)
+    {
+      g_warning ("Failed to call Inhibit: %s\n", error->message);
+      g_error_free (error);
+      return FALSE;
+    }
+
+  g_variant_unref (ret);
+
+  return TRUE;
+}
+
+static void usage (void)
+{
+  g_print (_("%s [OPTION...] COMMAND\n"
+             "\n"
+             "Execute COMMAND while inhibiting some session functionality.\n"
+             "\n"
+             "  -h, --help        Show this help\n"
+             "  --version         Show program version\n"
+             "  --app-id ID       The application id to use\n"
+             "                    when inhibiting (optional)\n"
+             "  --reason REASON   The reason for inhibiting (optional)\n"
+             "  --inhibit ARG     Things to inhibit, colon-separated list of:\n"
+             "                    logout, switch-user, suspend, idle, automount\n"
+             "\n"
+             "If no --inhibit option is specified, idle is assumed.\n"),
+           g_get_prgname ());
+}
+
+static void version (void)
+{
+  g_print ("%s %s\n", g_get_prgname (), PACKAGE_VERSION);
+}
+
+int main (int argc, char *argv[])
+{
+  gchar *prgname;
+  GsmInhibitorFlags inhibit_flags = 0;
+  gboolean show_help = FALSE;
+  gboolean show_version = FALSE;
+  gint i;
+  pid_t pid;
+  int status;
+  const gchar *app_id = "unknown";
+  const gchar *reason = "not specified";
+
+  prgname = g_path_get_basename (argv[0]);
+  g_set_prgname (prgname);
+  g_free (prgname);
+
+#ifdef ENABLE_NLS
+  setlocale (LC_ALL, "");
+  bindtextdomain (GETTEXT_PACKAGE, LOCALE_DIR);
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+#endif /* ENABLE_NLS */
+
+  for (i = 1; i < argc; i++)
+    {
+      if (strcmp (argv[i], "--help") == 0 ||
+          strcmp (argv[i], "-h") == 0)
+        show_help = TRUE;
+      else if (strcmp (argv[i], "--version") == 0)
+        show_version = TRUE;
+      else if (strcmp (argv[i], "--app-id") == 0)
+        {
+          i++;
+          if (i == argc)
+            {
+              g_print (_("%s requires an argument\n"), argv[i]);
+              exit (1);
+            }
+          app_id = argv[i];
+        }
+      else if (strcmp (argv[i], "--reason") == 0)
+        {
+          i++;
+          if (i == argc)
+            {
+              g_print (_("%s requires an argument\n"), argv[i]);
+              exit (1);
+            }
+          reason = argv[i];
+        }
+      else if (strcmp (argv[i], "--inhibit") == 0)
+        {
+          i++;
+          if (i == argc)
+            {
+              g_print (_("%s requires an argument\n"), argv[i]);
+              exit (1);
+            }
+          inhibit_flags |= parse_flags (argv[i]);
+        }
+      else
+        break;
+    }
+
+  if (show_version)
+    {
+      version ();
+      return 0;
+    }
+
+  if (show_help || i == argc)
+    {
+      usage ();
+      return 0;
+    }
+
+  if (inhibit_flags == 0)
+    inhibit_flags = GSM_INHIBITOR_FLAG_IDLE;
+
+  inhibit (app_id, reason, inhibit_flags);
+
+  pid = fork ();
+  if (pid < 0)
+    {
+      g_print ("fork failed\n");
+      exit (1);
+    }
+
+  if (pid == 0)
+    {
+      execvp (argv[i], argv + i);
+      g_print (_("Failed to execute %s\n"), argv[i]);
+      exit (1);
+    }
+
+  do
+    {
+      if (waitpid (pid, &status, 0) == -1)
+        {
+          g_print ("waitpid failed\n");
+          exit (1);
+        }
+
+      if (WIFEXITED (status))
+        exit (WEXITSTATUS (status));
+
+    } while (!WIFEXITED (status) && ! WIFSIGNALED(status));
+
+  return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/75.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/75.html new file mode 100644 index 0000000..38ed720 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/75.html @@ -0,0 +1,811 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
  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
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ * save-session.c - Small program to talk to session manager.
+
+   Copyright (C) 1998 Tom Tromey
+   Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+
+   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, 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 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.
+*/
+
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define GSM_SERVICE_DBUS "org.gnome.SessionManager"
+#define GSM_PATH_DBUS "/org/gnome/SessionManager"
+#define GSM_INTERFACE_DBUS "org.gnome.SessionManager"
+
+#define GSM_SERVICE_DBUS_OLD "org.mate.SessionManager"
+#define GSM_PATH_DBUS_OLD "/org/mate/SessionManager"
+#define GSM_INTERFACE_DBUS_OLD "org.mate.SessionManager"
+
+enum {
+	GSM_LOGOUT_MODE_NORMAL = 0,
+	GSM_LOGOUT_MODE_NO_CONFIRMATION,
+	GSM_LOGOUT_MODE_FORCE
+};
+
+/* True if killing. This is deprecated, but we keep it for compatibility
+ * reasons. */
+static gboolean kill_session = FALSE;
+
+/* The real options that should be used now. They are not ambiguous. */
+static gboolean logout = FALSE;
+static gboolean force_logout = FALSE;
+static gboolean logout_dialog = FALSE;
+static gboolean shutdown_dialog = FALSE;
+
+/* True if we should use dialog boxes */
+static gboolean show_error_dialogs = FALSE;
+
+/* True if we should do the requested action without confirmation */
+static gboolean no_interaction = FALSE;
+
+static char* session_name = NULL;
+
+static GOptionEntry options[] = {
+	{"logout", '\0', 0, G_OPTION_ARG_NONE, &logout, N_("Log out"), NULL},
+	{"force-logout", '\0', 0, G_OPTION_ARG_NONE, &force_logout, N_("Log out, ignoring any existing inhibitors"), NULL},
+	{"logout-dialog", '\0', 0, G_OPTION_ARG_NONE, &logout_dialog, N_("Show logout dialog"), NULL},
+	{"shutdown-dialog", '\0', 0, G_OPTION_ARG_NONE, &shutdown_dialog, N_("Show shutdown dialog"), NULL},
+	{"gui",  '\0', 0, G_OPTION_ARG_NONE, &show_error_dialogs, N_("Use dialog boxes for errors"), NULL},
+	/* deprecated options */
+	{"session-name", 's', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &session_name, N_("Set the current session name"), N_("NAME")},
+	{"kill", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &kill_session, N_("Kill session"), NULL},
+	{"silent", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &no_interaction, N_("Do not require confirmation"), NULL},
+	{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}
+};
+
+static void display_error(const char* message)
+{
+	if (show_error_dialogs && !no_interaction)
+	{
+		GtkWidget* dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", message);
+
+		gtk_window_set_default_icon_name ("dialog-error");
+
+		gtk_dialog_run(GTK_DIALOG(dialog));
+		gtk_widget_destroy(dialog);
+	}
+	else
+	{
+		g_printerr("%s\n", message);
+	}
+}
+
+static GDBusProxy* get_sm_proxy(void)
+{
+	GError *error = NULL;
+	GDBusProxy *sm_proxy = NULL;
+
+	sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+	                                          G_DBUS_PROXY_FLAGS_NONE,
+	                                          NULL,
+	                                          GSM_SERVICE_DBUS,
+	                                          GSM_PATH_DBUS,
+	                                          GSM_INTERFACE_DBUS,
+	                                          NULL,
+	                                          &error);
+	if (sm_proxy == NULL)
+	{
+		g_warning ("Couldn't create DBus proxy: %s", error->message);
+		g_error_free (error);
+
+		/* Try the old name - for the case when we've just upgraded from 1.10
+		 * so the old m-s-m is currently running */
+		sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+		                                          G_DBUS_PROXY_FLAGS_NONE,
+		                                          NULL,
+		                                          GSM_SERVICE_DBUS_OLD,
+		                                          GSM_PATH_DBUS_OLD,
+		                                          GSM_INTERFACE_DBUS_OLD,
+		                                          NULL,
+		                                          NULL);
+		if (sm_proxy == NULL)
+		{
+			/* Okay, it wasn't the upgrade case, so now we can give up. */
+			display_error (_("Could not connect to the session manager"));
+			return NULL;
+		}
+	}
+
+	return sm_proxy;
+}
+
+static void do_logout(unsigned int mode)
+{
+	GDBusProxy* sm_proxy;
+	GError* error;
+	GVariant *ret;
+
+	sm_proxy = get_sm_proxy ();
+
+	if (sm_proxy == NULL)
+	{
+		return;
+	}
+
+	error = NULL;
+	ret = g_dbus_proxy_call_sync (sm_proxy, "Logout",
+	                              g_variant_new ("(u)", mode),
+	                              G_DBUS_CALL_FLAGS_NONE,
+	                              -1,
+	                              NULL,
+	                              &error);
+
+	if (ret == NULL)
+	{
+		g_warning ("Failed to call logout: %s", error->message);
+		g_error_free (error);
+	} else {
+		g_variant_unref (ret);
+	}
+
+	if (sm_proxy != NULL)
+	{
+		g_object_unref (sm_proxy);
+	}
+}
+
+static void do_shutdown_dialog(void)
+{
+	GDBusProxy* sm_proxy;
+	GError* error;
+	GVariant *ret;
+
+	sm_proxy = get_sm_proxy ();
+
+	if (sm_proxy == NULL)
+	{
+		return;
+	}
+
+	error = NULL;
+	ret = g_dbus_proxy_call_sync (sm_proxy, "Shutdown",
+	                              g_variant_new ("()"),
+	                              G_DBUS_CALL_FLAGS_NONE,
+	                              -1,
+	                              NULL,
+	                              &error);
+	if (ret == NULL)
+	{
+		g_warning ("Failed to call shutdown: %s", error->message);
+		g_error_free (error);
+	} else {
+		g_variant_unref (ret);
+	}
+
+	if (sm_proxy != NULL)
+	{
+		g_object_unref (sm_proxy);
+	}
+}
+
+int main(int argc, char* argv[])
+{
+	GError* error;
+	int conflicting_options;
+
+	/* Initialize the i18n stuff */
+#ifdef ENABLE_NLS
+	bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
+	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+	textdomain(GETTEXT_PACKAGE);
+#endif /* ENABLE_NLS */
+
+	error = NULL;
+
+	if (!gtk_init_with_args(&argc, &argv, NULL, options, NULL, &error))
+	{
+		g_warning("Unable to start: %s", error->message);
+		g_error_free(error);
+		exit(1);
+	}
+
+	conflicting_options = 0;
+
+	if (kill_session)
+	{
+		conflicting_options++;
+	}
+
+	if (logout)
+	{
+		conflicting_options++;
+	}
+
+	if (force_logout)
+	{
+		conflicting_options++;
+	}
+
+	if (logout_dialog)
+	{
+		conflicting_options++;
+	}
+
+	if (shutdown_dialog)
+	{
+		conflicting_options++;
+	}
+
+	if (conflicting_options > 1)
+	{
+		display_error(_("Program called with conflicting options"));
+	}
+
+	if (kill_session)
+	{
+		if (no_interaction)
+		{
+			force_logout = TRUE;
+		}
+		else
+		{
+			logout_dialog = TRUE;
+		}
+	}
+
+	if (logout)
+	{
+		do_logout(GSM_LOGOUT_MODE_NO_CONFIRMATION);
+	}
+	else if (force_logout)
+	{
+		do_logout(GSM_LOGOUT_MODE_FORCE);
+	}
+	else if (logout_dialog)
+	{
+		do_logout(GSM_LOGOUT_MODE_NORMAL);
+	}
+	else if (shutdown_dialog)
+	{
+		do_shutdown_dialog();
+	}
+
+	return 0;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/8.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/8.html new file mode 100644 index 0000000..8ac8a3d --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/8.html @@ -0,0 +1,2633 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
   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
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 1999 Free Software Foundation, Inc.
+ * Copyright (C) 2007, 2009 Vincent Untz.
+ * Copyright (C) 2008 Lucas Rocha.
+ * Copyright (C) 2008 William Jon McCann <jmccann@redhat.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gstdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "gsm-app-dialog.h"
+#include "gsm-properties-dialog.h"
+#include "gsm-util.h"<--- Include file: "gsm-util.h" not found.
+#include "gsp-app-manager.h"
+#include "gsp-keyfile.h"
+
+#include "gsp-app.h"
+
+#define GSP_APP_SAVE_DELAY 2
+
+#define GSP_ASP_SAVE_MASK_HIDDEN   0x0001
+#define GSP_ASP_SAVE_MASK_NAME     0x0002
+#define GSP_ASP_SAVE_MASK_EXEC     0x0004
+#define GSP_ASP_SAVE_MASK_COMMENT  0x0008
+#define GSP_ASP_SAVE_MASK_DELAY    0x0010
+#define GSP_ASP_SAVE_MASK_ALL      0xffff
+
+typedef struct {
+        char         *basename;
+        char         *path;
+
+        gboolean      hidden;
+        gboolean      nodisplay;
+
+        char         *name;
+        char         *exec;
+        char         *comment;
+        char         *icon;
+        gint         delay;
+
+        GIcon        *gicon;
+        char         *description;
+
+        /* position of the directory in the XDG environment variable */
+        unsigned int  xdg_position;
+        /* position of the first system directory in the XDG env var containing
+         * this autostart app too (G_MAXUINT means none) */
+        unsigned int  xdg_system_position;
+
+        unsigned int  save_timeout;
+        /* mask of what has changed */
+        unsigned int  save_mask;
+        /* path that contains the original file that needs to be saved */
+        char         *old_system_path;
+        /* after writing to file, we skip the next file monitor event of type
+         * CHANGED */
+        gboolean      skip_next_monitor_event;
+} GspAppPrivate;
+
+enum {
+        CHANGED,
+        REMOVED,
+        LAST_SIGNAL
+};
+
+static guint gsp_app_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE_WITH_PRIVATE (GspApp, gsp_app, G_TYPE_OBJECT)<--- There is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
+
+static void     gsp_app_dispose  (GObject *object);
+static void     gsp_app_finalize (GObject *object);
+static gboolean _gsp_app_save    (gpointer data);
+
+static gboolean
+_gsp_str_equal (const char *a,
+                const char *b)
+{
+        if (g_strcmp0 (a, b) == 0) {
+                return TRUE;
+        }
+
+        if (a && !b && a[0] == '\0') {
+                return TRUE;
+        }
+
+        if (b && !a && b[0] == '\0') {
+                return TRUE;
+        }
+
+        return FALSE;
+}
+
+static void
+gsp_app_class_init (GspAppClass *class)
+{
+        GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+        gobject_class->dispose  = gsp_app_dispose;
+        gobject_class->finalize = gsp_app_finalize;
+
+        gsp_app_signals[CHANGED] =
+                g_signal_new ("changed",
+                              G_TYPE_FROM_CLASS (gobject_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GspAppClass,
+                                               changed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE, 0);
+
+        gsp_app_signals[REMOVED] =
+                g_signal_new ("removed",
+                              G_TYPE_FROM_CLASS (gobject_class),
+                              G_SIGNAL_RUN_LAST,
+                              G_STRUCT_OFFSET (GspAppClass,
+                                               removed),
+                              NULL,
+                              NULL,
+                              g_cclosure_marshal_VOID__VOID,
+                              G_TYPE_NONE, 0);
+
+}
+
+static void
+gsp_app_init (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        priv = gsp_app_get_instance_private (app);
+
+        memset (priv, 0, sizeof (GspAppPrivate));
+        priv->xdg_position        = G_MAXUINT;
+        priv->xdg_system_position = G_MAXUINT;
+}
+
+static void
+_gsp_app_free_reusable_data (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        priv = gsp_app_get_instance_private (app);
+        if (priv->path) {
+                g_free (priv->path);
+                priv->path = NULL;
+        }
+
+        if (priv->name) {
+                g_free (priv->name);
+                priv->name = NULL;
+        }
+
+        if (priv->exec) {
+                g_free (priv->exec);
+                priv->exec = NULL;
+        }
+
+        if (priv->comment) {
+                g_free (priv->comment);
+                priv->comment = NULL;
+        }
+
+        if (priv->icon) {
+                g_free (priv->icon);
+                priv->icon = NULL;
+        }
+
+        if (priv->gicon) {
+                g_object_unref (priv->gicon);
+                priv->gicon = NULL;
+        }
+
+        if (priv->description) {
+                g_free (priv->description);
+                priv->description = NULL;
+        }
+
+        if (priv->old_system_path) {
+                g_free (priv->old_system_path);
+                priv->old_system_path = NULL;
+        }
+}
+
+static void
+gsp_app_dispose (GObject *object)
+{
+        GspApp *app;
+        GspAppPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSP_IS_APP (object));
+
+        app = GSP_APP (object);
+        priv = gsp_app_get_instance_private (app);
+
+        /* we save in dispose since we might need to reference GspAppManager */
+        if (priv->save_timeout) {
+                g_source_remove (priv->save_timeout);
+                priv->save_timeout = 0;
+
+                /* save now */
+                _gsp_app_save (app);
+        }
+
+        G_OBJECT_CLASS (gsp_app_parent_class)->dispose (object);
+}
+
+static void
+gsp_app_finalize (GObject *object)
+{
+        GspApp *app;
+        GspAppPrivate *priv;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSP_IS_APP (object));
+
+        app = GSP_APP (object);
+        priv = gsp_app_get_instance_private (app);
+
+        if (priv->basename) {
+                g_free (priv->basename);
+                priv->basename = NULL;
+        }
+
+        _gsp_app_free_reusable_data (app);
+
+        G_OBJECT_CLASS (gsp_app_parent_class)->finalize (object);
+}
+
+static void
+_gsp_app_emit_changed (GspApp *app)
+{
+        g_signal_emit (G_OBJECT (app), gsp_app_signals[CHANGED], 0);
+}
+
+static void
+_gsp_app_emit_removed (GspApp *app)
+{
+        g_signal_emit (G_OBJECT (app), gsp_app_signals[REMOVED], 0);
+}
+
+static void
+_gsp_app_update_description (GspApp *app)
+{
+        const char *primary;
+        const char *secondary;
+        GspAppPrivate *priv;
+
+        priv = gsp_app_get_instance_private (app);
+
+        if (!gsm_util_text_is_blank (priv->name)) {
+                primary = priv->name;
+        } else if (!gsm_util_text_is_blank (priv->exec)) {
+                primary = priv->exec;
+        } else {
+                primary = _("No name");
+        }
+
+        if (!gsm_util_text_is_blank (priv->comment)) {
+                secondary = priv->comment;
+        } else {
+                secondary = _("No description");
+        }
+
+        g_free (priv->description);
+        priv->description = g_markup_printf_escaped ("<b>%s</b>\n%s",
+                                                     primary,
+                                                     secondary);
+}
+
+/*
+ * Saving
+ */
+
+static void
+_gsp_ensure_user_autostart_dir (void)
+{
+        char *dir;
+
+        dir = g_build_filename (g_get_user_config_dir (), "autostart", NULL);
+        g_mkdir_with_parents (dir, S_IRWXU);
+
+        g_free (dir);
+}
+
+static gboolean
+_gsp_app_user_equal_system (GspApp  *app,
+                            char   **system_path)
+{
+        GspAppManager *manager;
+        GspAppPrivate *priv;
+        const char    *system_dir;
+        char          *path;
+        char          *str;
+        GKeyFile      *keyfile;
+        guint          delay;
+
+        manager = gsp_app_manager_get ();
+        priv = gsp_app_get_instance_private (app);
+        system_dir = gsp_app_manager_get_dir (manager,
+                                              priv->xdg_system_position);
+        g_object_unref (manager);
+        if (!system_dir) {
+                return FALSE;
+        }
+
+        path = g_build_filename (system_dir, priv->basename, NULL);
+
+        keyfile = g_key_file_new ();
+        if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL)) {
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+
+        if (gsp_key_file_get_boolean (keyfile,
+                                      G_KEY_FILE_DESKTOP_KEY_HIDDEN,
+                                      FALSE) != priv->hidden) {
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+
+        str = gsp_key_file_get_locale_string (keyfile,
+                                              G_KEY_FILE_DESKTOP_KEY_NAME);
+        if (!_gsp_str_equal (str, priv->name)) {
+                g_free (str);
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+        g_free (str);
+
+        str = gsp_key_file_get_locale_string (keyfile,
+                                              G_KEY_FILE_DESKTOP_KEY_COMMENT);
+        if (!_gsp_str_equal (str, priv->comment)) {
+                g_free (str);
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+        g_free (str);
+
+        str = gsp_key_file_get_string (keyfile,
+                                       G_KEY_FILE_DESKTOP_KEY_EXEC);
+        if (!_gsp_str_equal (str, priv->exec)) {
+                g_free (str);
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+        g_free (str);
+
+        str = gsp_key_file_get_locale_string (keyfile,
+                                              G_KEY_FILE_DESKTOP_KEY_ICON);
+        if (!_gsp_str_equal (str, priv->icon)) {
+                g_free (str);
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+        g_free (str);
+
+        delay = gsp_key_file_get_delay(keyfile);
+        if (delay != priv->delay) {
+                g_free (path);
+                g_key_file_free (keyfile);
+                return FALSE;
+        }
+
+        g_key_file_free (keyfile);
+
+        *system_path = path;
+
+        return TRUE;
+}
+
+static inline void
+_gsp_app_save_done_success (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        priv = gsp_app_get_instance_private (app);
+        priv->save_mask = 0;
+
+        if (priv->old_system_path) {
+                g_free (priv->old_system_path);
+                priv->old_system_path = NULL;
+        }
+}
+
+static gboolean
+_gsp_app_save (gpointer data)
+{
+        GspApp   *app;
+        char     *use_path;
+        GKeyFile *keyfile;
+        GError   *error;
+        GspAppPrivate *priv;
+
+        app = GSP_APP (data);
+        priv = gsp_app_get_instance_private (app);
+
+        /* first check if removing the data from the user dir and using the
+         * data from the system dir is enough -- this helps us keep clean the
+         * user config dir by removing unneeded files */
+        if (_gsp_app_user_equal_system (app, &use_path)) {
+                if (g_file_test (priv->path, G_FILE_TEST_EXISTS)) {
+                        g_remove (priv->path);
+                }
+
+                g_free (priv->path);
+                priv->path = use_path;
+
+                priv->xdg_position = priv->xdg_system_position;
+
+                _gsp_app_save_done_success (app);
+                return FALSE;
+        }
+
+        if (priv->old_system_path)
+                use_path = priv->old_system_path;
+        else
+                use_path = priv->path;
+
+        keyfile = g_key_file_new ();
+
+        error = NULL;
+        g_key_file_load_from_file (keyfile, use_path,
+                                   G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+                                   &error);
+
+        if (error) {
+                g_error_free (error);
+                gsp_key_file_populate (keyfile);
+        }
+
+        if (priv->save_mask & GSP_ASP_SAVE_MASK_HIDDEN) {
+                gsp_key_file_set_boolean (keyfile,
+                                          G_KEY_FILE_DESKTOP_KEY_HIDDEN,
+                                          priv->hidden);
+        }
+
+        if (priv->save_mask & GSP_ASP_SAVE_MASK_NAME) {
+                gsp_key_file_set_locale_string (keyfile,
+                                                G_KEY_FILE_DESKTOP_KEY_NAME,
+                                                priv->name);
+                gsp_key_file_ensure_C_key (keyfile, G_KEY_FILE_DESKTOP_KEY_NAME);
+        }
+
+        if (priv->save_mask & GSP_ASP_SAVE_MASK_COMMENT) {
+                gsp_key_file_set_locale_string (keyfile,
+                                                G_KEY_FILE_DESKTOP_KEY_COMMENT,
+                                                priv->comment);
+                gsp_key_file_ensure_C_key (keyfile, G_KEY_FILE_DESKTOP_KEY_COMMENT);
+        }
+
+        if (priv->save_mask & GSP_ASP_SAVE_MASK_EXEC) {
+                gsp_key_file_set_string (keyfile,
+                                         G_KEY_FILE_DESKTOP_KEY_EXEC,
+                                         priv->exec);
+        }
+
+        if (priv->save_mask & GSP_ASP_SAVE_MASK_DELAY) {
+                gsp_key_file_set_delay (keyfile, priv->delay);
+        }
+
+        _gsp_ensure_user_autostart_dir ();
+        if (g_key_file_save_to_file (keyfile, priv->path, NULL)) {
+                priv->skip_next_monitor_event = TRUE;
+                _gsp_app_save_done_success (app);
+        } else {
+                g_warning ("Could not save %s file", priv->path);
+        }
+
+        g_key_file_free (keyfile);
+
+        priv->save_timeout = 0;
+        return FALSE;
+}
+
+static void
+_gsp_app_queue_save (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        priv = gsp_app_get_instance_private (app);
+        if (priv->save_timeout) {
+                g_source_remove (priv->save_timeout);
+                priv->save_timeout = 0;
+        }
+
+        /* if the file was not in the user directory, then we'll create a copy
+         * there */
+        if (priv->xdg_position != 0) {
+                priv->xdg_position = 0;
+
+                if (priv->old_system_path == NULL) {
+                        priv->old_system_path = priv->path;
+                        /* if old_system_path was not NULL, then it means we
+                         * tried to save and we failed; in that case, we want
+                         * to try again and use the old file as a basis again */
+                }
+
+                priv->path = g_build_filename (g_get_user_config_dir (),
+                                               "autostart",
+                                               priv->basename, NULL);
+        }
+
+        priv->save_timeout = g_timeout_add_seconds (GSP_APP_SAVE_DELAY,
+                                                    _gsp_app_save,
+                                                    app);
+}
+
+/*
+ * Accessors
+ */
+
+const char *
+gsp_app_get_basename (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->basename;
+}
+
+const char *
+gsp_app_get_path (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->path;
+}
+
+gboolean
+gsp_app_get_hidden (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), FALSE);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->hidden;
+}
+
+void
+gsp_app_set_hidden (GspApp   *app,
+                    gboolean  hidden)
+{
+        GspAppPrivate *priv;
+
+        g_return_if_fail (GSP_IS_APP (app));
+
+        priv = gsp_app_get_instance_private (app);
+
+        if (hidden == priv->hidden) {
+                return;
+        }
+
+        priv->hidden = hidden;
+        priv->save_mask |= GSP_ASP_SAVE_MASK_HIDDEN;
+
+        _gsp_app_queue_save (app);
+        _gsp_app_emit_changed (app);
+}
+
+gboolean
+gsp_app_get_nodisplay (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), FALSE);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->nodisplay;
+}
+
+const char *
+gsp_app_get_name (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->name;
+}
+
+const char *
+gsp_app_get_exec (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->exec;
+}
+
+const char *
+gsp_app_get_comment (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->comment;
+}
+
+guint
+gsp_app_get_delay (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), 0);
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->delay;
+}
+
+GIcon *
+gsp_app_get_icon (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        if (priv->gicon) {
+                return g_object_ref (priv->gicon);
+        } else {
+                return NULL;
+        }
+}
+
+unsigned int
+gsp_app_get_xdg_position (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), G_MAXUINT);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->xdg_position;
+}
+
+unsigned int
+gsp_app_get_xdg_system_position (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), G_MAXUINT);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->xdg_system_position;
+}
+
+void
+gsp_app_set_xdg_system_position (GspApp       *app,
+                                 unsigned int  position)
+{
+        GspAppPrivate *priv;
+
+        g_return_if_fail (GSP_IS_APP (app));
+
+        priv = gsp_app_get_instance_private (app);
+
+        priv->xdg_system_position = position;
+}
+
+const char *
+gsp_app_get_description (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_val_if_fail (GSP_IS_APP (app), NULL);
+
+        priv = gsp_app_get_instance_private (app);
+
+        return priv->description;
+}
+
+/*
+ * High-level edition
+ */
+
+void
+gsp_app_update (GspApp     *app,
+                const char *name,
+                const char *comment,
+                const char *exec,
+                guint       delay)
+{
+        gboolean    changed;
+        GspAppPrivate *priv;
+
+        g_return_if_fail (GSP_IS_APP (app));
+
+        changed = FALSE;
+        priv = gsp_app_get_instance_private (app);
+
+        if (!_gsp_str_equal (name, priv->name)) {
+                changed = TRUE;
+                g_free (priv->name);
+                priv->name = g_strdup (name);
+                priv->save_mask |= GSP_ASP_SAVE_MASK_NAME;
+        }
+
+        if (!_gsp_str_equal (comment, priv->comment)) {
+                changed = TRUE;
+                g_free (priv->comment);
+                priv->comment = g_strdup (comment);
+                priv->save_mask |= GSP_ASP_SAVE_MASK_COMMENT;
+        }
+
+        if (changed) {
+                _gsp_app_update_description (app);
+        }
+
+        if (!_gsp_str_equal (exec, priv->exec)) {
+                changed = TRUE;
+                g_free (priv->exec);
+                priv->exec = g_strdup (exec);
+                priv->save_mask |= GSP_ASP_SAVE_MASK_EXEC;
+        }
+
+        if ( delay != priv->delay) {
+                changed = TRUE;
+                priv->delay = delay;
+                priv->save_mask |= GSP_ASP_SAVE_MASK_DELAY;
+        }
+
+        if (changed) {
+                _gsp_app_queue_save (app);
+                _gsp_app_emit_changed (app);
+        }
+}
+
+void
+gsp_app_delete (GspApp *app)
+{
+        GspAppPrivate *priv;
+
+        g_return_if_fail (GSP_IS_APP (app));
+
+        priv = gsp_app_get_instance_private (app);
+        if (priv->xdg_position == 0 &&
+            priv->xdg_system_position == G_MAXUINT) {
+                /* exists in user directory only */
+                if (priv->save_timeout) {
+                        g_source_remove (priv->save_timeout);
+                        priv->save_timeout = 0;
+                }
+
+                if (g_file_test (priv->path, G_FILE_TEST_EXISTS)) {
+                        g_remove (priv->path);
+                }
+
+                /* for extra safety */
+                priv->hidden = TRUE;
+                priv->save_mask |= GSP_ASP_SAVE_MASK_HIDDEN;
+
+                _gsp_app_emit_removed (app);
+        } else {
+                /* also exists in system directory, so we have to keep a file
+                 * in the user directory */
+                priv->hidden = TRUE;
+                priv->save_mask |= GSP_ASP_SAVE_MASK_HIDDEN;
+
+                _gsp_app_queue_save (app);
+                _gsp_app_emit_changed (app);
+        }
+}
+
+/*
+ * New autostart app
+ */
+
+void
+gsp_app_reload_at (GspApp       *app,
+                   const char   *path,
+                   unsigned int  xdg_position)
+{
+        GspAppPrivate *priv;
+
+        g_return_if_fail (GSP_IS_APP (app));
+
+        priv = gsp_app_get_instance_private (app);
+
+        priv->xdg_position = G_MAXUINT;
+        gsp_app_new (path, xdg_position);
+}
+
+static gboolean
+gsp_app_can_launch (GKeyFile *keyfile)
+{
+        char **only_show_in, **not_show_in;
+        gboolean found;
+        int i;
+
+        only_show_in = g_key_file_get_string_list (keyfile,
+                                                   G_KEY_FILE_DESKTOP_GROUP,
+                                                   G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN,
+                                                   NULL, NULL);
+        if (only_show_in) {
+                for (i = 0, found = FALSE; only_show_in[i] && !found; i++) {
+                        if (!strcmp (only_show_in[i], "MATE"))
+                                found = TRUE;
+                }
+                g_strfreev (only_show_in);
+                if (!found)
+                    return FALSE;
+        }
+        not_show_in = g_key_file_get_string_list (keyfile,
+                                                  G_KEY_FILE_DESKTOP_GROUP,
+                                                  G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN,
+                                                  NULL, NULL);
+        if (not_show_in) {
+                for (i = 0, found = FALSE; not_show_in[i] && !found; i++) {
+                        if (!strcmp (not_show_in[i], "MATE"))
+                                found = TRUE;
+                }
+                g_strfreev (not_show_in);
+                if (found)
+                        return FALSE;
+        }
+        return TRUE;
+}
+
+GspApp *
+gsp_app_new (const char   *path,
+             unsigned int  xdg_position)
+{
+        GspAppManager *manager;
+        GspApp        *app;
+        GKeyFile      *keyfile;
+        char          *basename;
+        gboolean       new;
+        GspAppPrivate *priv;
+
+        basename = g_path_get_basename (path);
+
+        manager = gsp_app_manager_get ();
+        app = gsp_app_manager_find_app_with_basename (manager, basename);
+        priv = gsp_app_get_instance_private (app);
+        g_object_unref (manager);
+
+        new = (app == NULL);
+
+        if (!new) {
+                if (priv->xdg_position == xdg_position) {
+                        if (priv->skip_next_monitor_event) {
+                                priv->skip_next_monitor_event = FALSE;
+                                return NULL;
+                        }
+                        /* else: the file got changed but not by us, we'll
+                         * update our data from disk */
+                }
+
+                if (priv->xdg_position < xdg_position ||
+                    priv->save_timeout != 0) {
+                        /* we don't really care about this file, since we
+                         * already have something with a higher priority, or
+                         * we're going to write something in the user config
+                         * anyway.
+                         * Note: xdg_position >= 1 so it's a system dir */
+                        priv->xdg_system_position = MIN (xdg_position,
+                                                              priv->xdg_system_position);
+                        return NULL;
+                }
+        }
+
+        keyfile = g_key_file_new ();
+        if (!g_key_file_load_from_file (keyfile, path, G_KEY_FILE_NONE, NULL)) {
+                g_key_file_free (keyfile);
+                g_free (basename);
+                return NULL;
+        }
+
+        if (!gsp_app_can_launch (keyfile)) {
+                g_key_file_free (keyfile);
+                g_free (basename);
+                return NULL;
+        }
+
+        if (new) {
+                app = g_object_new (GSP_TYPE_APP, NULL);
+                priv = gsp_app_get_instance_private (app);
+                priv->basename = basename;
+        } else {
+                g_free (basename);
+                _gsp_app_free_reusable_data (app);
+        }
+
+        priv->path = g_strdup (path);
+
+        priv->hidden = gsp_key_file_get_boolean (keyfile,
+                                                 G_KEY_FILE_DESKTOP_KEY_HIDDEN,
+                                                 FALSE);
+        priv->nodisplay = gsp_key_file_get_boolean (keyfile,
+                                                    G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY,
+                                                    FALSE);
+        priv->name = gsp_key_file_get_locale_string (keyfile,
+                                                     G_KEY_FILE_DESKTOP_KEY_NAME);
+        priv->exec = gsp_key_file_get_string (keyfile,
+                                              G_KEY_FILE_DESKTOP_KEY_EXEC);
+        priv->comment = gsp_key_file_get_locale_string (keyfile,
+                                                        G_KEY_FILE_DESKTOP_KEY_COMMENT);
+        priv->delay = gsp_key_file_get_delay (keyfile);
+
+        if (gsm_util_text_is_blank (priv->name)) {
+                g_free (priv->name);
+                priv->name = g_strdup (priv->exec);
+        }
+
+        priv->icon = gsp_key_file_get_locale_string (keyfile,
+                                                     G_KEY_FILE_DESKTOP_KEY_ICON);
+
+        if (priv->icon) {
+                /* look at icon and see if it's a themed icon or not */
+                if (g_path_is_absolute (priv->icon)) {
+                        GFile *iconfile;
+
+                        iconfile = g_file_new_for_path (priv->icon);
+                        priv->gicon = g_file_icon_new (iconfile);
+                        g_object_unref (iconfile);
+                } else {
+                        priv->gicon = g_themed_icon_new (priv->icon);
+                }
+        } else {
+                priv->gicon = NULL;
+        }
+
+        g_key_file_free (keyfile);
+
+        _gsp_app_update_description (app);
+
+        if (xdg_position > 0) {
+                g_assert (xdg_position <= priv->xdg_system_position);
+                priv->xdg_system_position = xdg_position;
+        }
+        /* else we keep the old value (which is G_MAXUINT if it wasn't set) */
+        priv->xdg_position = xdg_position;
+
+        g_assert (!new || priv->save_timeout == 0);
+        priv->save_timeout = 0;
+        priv->old_system_path = NULL;
+        priv->skip_next_monitor_event = FALSE;
+
+        if (!new) {
+                _gsp_app_emit_changed (app);
+        }
+
+        return app;
+}
+
+static char *
+_gsp_find_free_basename (const char *suggested_basename)
+{
+        GspAppManager *manager;
+        char          *base_path;
+        char          *filename;
+        char          *basename;
+        int            i;
+
+        if (g_str_has_suffix (suggested_basename, ".desktop")) {
+                char *basename_no_ext;
+
+                basename_no_ext = g_strndup (suggested_basename,
+                                             strlen (suggested_basename) - strlen (".desktop"));
+                base_path = g_build_filename (g_get_user_config_dir (),
+                                              "autostart",
+                                              basename_no_ext, NULL);
+                g_free (basename_no_ext);
+        } else {
+                base_path = g_build_filename (g_get_user_config_dir (),
+                                              "autostart",
+                                              suggested_basename, NULL);
+        }
+
+        filename = g_strdup_printf ("%s.desktop", base_path);
+        basename = g_path_get_basename (filename);
+
+        manager = gsp_app_manager_get ();
+
+        i = 1;
+#define _GSP_FIND_MAX_TRY 10000
+        while (gsp_app_manager_find_app_with_basename (manager,
+                                                       basename) != NULL &&
+               g_file_test (filename, G_FILE_TEST_EXISTS) &&
+               i < _GSP_FIND_MAX_TRY) {
+                g_free (filename);
+                g_free (basename);
+
+                filename = g_strdup_printf ("%s-%d.desktop", base_path, i);
+                basename = g_path_get_basename (filename);
+
+                i++;
+        }
+
+        g_object_unref (manager);
+
+        g_free (base_path);
+        g_free (filename);
+
+        if (i == _GSP_FIND_MAX_TRY) {
+                g_free (basename);
+                return NULL;
+        }
+
+        return basename;
+}
+
+void
+gsp_app_create (const char *name,
+                const char *comment,
+                const char *exec,
+                guint       delay)
+{
+        GspAppManager  *manager;
+        GspAppPrivate *priv;
+        GspApp         *app;
+        char           *basename;
+        char          **argv;
+        int             argc;
+
+        g_return_if_fail (!gsm_util_text_is_blank (exec));
+
+        if (!g_shell_parse_argv (exec, &argc, &argv, NULL)) {
+                return;
+        }
+
+        basename = _gsp_find_free_basename (argv[0]);
+        g_strfreev (argv);
+        if (basename == NULL) {
+                return;
+        }
+
+        app = g_object_new (GSP_TYPE_APP, NULL);
+        priv = gsp_app_get_instance_private (app);
+
+        priv->basename = basename;
+        priv->path = g_build_filename (g_get_user_config_dir (),
+                                       "autostart",
+                                       priv->basename, NULL);
+
+        priv->hidden = FALSE;
+        priv->nodisplay = FALSE;
+
+        if (!gsm_util_text_is_blank (name)) {
+                priv->name = g_strdup (name);
+        } else {
+                priv->name = g_strdup (exec);
+        }
+        priv->exec = g_strdup (exec);
+        priv->comment = g_strdup (comment);
+        priv->delay = delay;
+        priv->icon = NULL;
+
+        priv->gicon = NULL;
+        _gsp_app_update_description (app);
+
+        /* by definition */
+        priv->xdg_position = 0;
+        priv->xdg_system_position = G_MAXUINT;
+
+        priv->save_timeout = 0;
+        priv->save_mask |= GSP_ASP_SAVE_MASK_ALL;
+        priv->old_system_path = NULL;
+        priv->skip_next_monitor_event = FALSE;
+
+        _gsp_app_queue_save (app);
+
+        manager = gsp_app_manager_get ();
+        gsp_app_manager_add (manager, app);
+        g_object_unref (app);
+        g_object_unref (manager);
+}
+
+gboolean
+gsp_app_copy_desktop_file (const char *uri)
+{
+        GspAppManager *manager;
+        GspAppPrivate *priv;
+        GspApp        *app;
+        GFile         *src_file;
+        char          *src_basename;
+        char          *dst_basename;
+        char          *dst_path;
+        GFile         *dst_file;
+        gboolean       changed;
+
+        g_return_val_if_fail (uri != NULL, FALSE);
+
+        src_file = g_file_new_for_uri (uri);
+        src_basename = g_file_get_basename (src_file);
+
+        if (src_basename == NULL) {
+                g_object_unref (src_file);
+                return FALSE;
+        }
+
+        dst_basename = _gsp_find_free_basename (src_basename);
+        g_free (src_basename);
+
+        if (dst_basename == NULL) {
+                g_object_unref (src_file);
+                return FALSE;
+        }
+
+        dst_path = g_build_filename (g_get_user_config_dir (),
+                                     "autostart",
+                                     dst_basename, NULL);
+        g_free (dst_basename);
+
+        dst_file = g_file_new_for_path (dst_path);
+
+        _gsp_ensure_user_autostart_dir ();
+        if (!g_file_copy (src_file, dst_file, G_FILE_COPY_NONE,
+                          NULL, NULL, NULL, NULL)) {
+                g_object_unref (src_file);
+                g_object_unref (dst_file);
+                g_free (dst_path);
+                return FALSE;
+        }
+
+        g_object_unref (src_file);
+        g_object_unref (dst_file);
+
+        app = gsp_app_new (dst_path, 0);
+        priv = gsp_app_get_instance_private (app);
+        if (!app) {
+                g_remove (dst_path);
+                g_free (dst_path);
+                return FALSE;
+        }
+
+        g_free (dst_path);
+
+        changed = FALSE;
+        if (priv->hidden) {
+                changed = TRUE;
+                priv->hidden = FALSE;
+                priv->save_mask |= GSP_ASP_SAVE_MASK_HIDDEN;
+        }
+
+        if (changed) {
+                _gsp_app_queue_save (app);
+        }
+
+        manager = gsp_app_manager_get ();
+        gsp_app_manager_add (manager, app);
+        g_object_unref (app);
+        g_object_unref (manager);
+
+        return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/9.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/9.html new file mode 100644 index 0000000..b6ba0e0 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/9.html @@ -0,0 +1,373 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+
 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
/*
+ * gsp-keyfile.h: GKeyFile extensions
+ *
+ * Copyright (C) 2008, 2009 Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * Based on code from panel-keyfile.h (from mate-panel)
+ *
+ * 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
+ * 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.
+ *
+ * Authors:
+ *        Vincent Untz <vuntz@gnome.org>
+ */
+
+#ifndef GSP_KEYFILE_H
+#define GSP_KEYFILE_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GSP_KEY_FILE_DESKTOP_KEY_DELAY             "X-MATE-Autostart-Delay"
+
+void      gsp_key_file_populate        (GKeyFile *keyfile);
+
+gboolean gsp_key_file_get_boolean      (GKeyFile       *keyfile,
+                                        const gchar    *key,
+                                        gboolean        default_value);
+#define gsp_key_file_get_string(key_file, key) \
+         g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, key, NULL)
+#define gsp_key_file_get_delay(key_file) \
+         g_key_file_get_integer (key_file, G_KEY_FILE_DESKTOP_GROUP, GSP_KEY_FILE_DESKTOP_KEY_DELAY, NULL)
+#define gsp_key_file_get_locale_string(key_file, key) \
+         g_key_file_get_locale_string(key_file, G_KEY_FILE_DESKTOP_GROUP, key, NULL, NULL)
+
+#define gsp_key_file_set_boolean(key_file, key, value) \
+         g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, key, value)
+#define gsp_key_file_set_string(key_file, key, value) \
+         g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, key, value)
+#define gsp_key_file_set_delay(key_file, value) \
+        g_key_file_set_integer(key_file, G_KEY_FILE_DESKTOP_GROUP, GSP_KEY_FILE_DESKTOP_KEY_DELAY, value)
+void    gsp_key_file_set_locale_string (GKeyFile    *keyfile,
+                                        const gchar *key,
+                                        const gchar *value);
+
+void gsp_key_file_ensure_C_key         (GKeyFile   *keyfile,
+                                        const char *key);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GSP_KEYFILE_H */
+
+ +
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/index.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/index.html new file mode 100644 index 0000000..6611465 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/index.html @@ -0,0 +1,793 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: There was critical errors (use --checkers-report=<filename> to see details)
capplet/gsm-app-dialog.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeinformationInclude file: "gsm-util.h" not found.
68unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
capplet/gsm-app-dialog.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
capplet/gsm-properties-dialog.c
25missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeinformationInclude file: "gsm-util.h" not found.
86unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
capplet/gsm-properties-dialog.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
capplet/gsp-app-manager.c
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeinformationInclude file: "gsm-util.h" not found.
51unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
capplet/gsp-app-manager.h
28missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gsp-app.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
capplet/gsp-app.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeinformationInclude file: "gsm-util.h" not found.
92unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
capplet/gsp-app.h
28missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
capplet/gsp-keyfile.c
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
102variableScope398styleThe scope of the variable 'buffer' can be reduced.
capplet/gsp-keyfile.h
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
capplet/main.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
capplet/msm-desktop-app-dialog.c
1missingIncludeinformationInclude file: "config.h" not found.
2missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
3missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
15unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
capplet/msm-desktop-app-dialog.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
5missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
6missingIncludeSysteminformationInclude file: <gio/gdesktopappinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gs-idle-monitor.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <X11/extensions/sync.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <X11/keysym.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <X11/extensions/XTest.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
70unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-session/gs-idle-monitor.h
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29syntaxErrorerrorsyntax error
mate-session/gsm-app-glue.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
102missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-app.c
24missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
60unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-session/gsm-app.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeinformationInclude file: "eggdesktopfile.h" not found.
mate-session/gsm-autostart-app.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
96unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-session/gsm-autostart-app.h
28missingIncludeSysteminformationInclude file: <X11/SM/SMlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-client-glue.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
150missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-client.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeinformationInclude file: "eggdesktopfile.h" not found.
60unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-session/gsm-client.h
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-consolekit.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-consolekit.h
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-dbus-client.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <dbus/dbus.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
59unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-session/gsm-inhibit-dialog.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <cairo-xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeinformationInclude file: "eggdesktopfile.h" not found.
44missingIncludeSysteminformationInclude file: <X11/extensions/Xrender.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
90unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-session/gsm-inhibit-dialog.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-inhibitor-glue.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
102missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-inhibitor.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
63unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-session/gsm-inhibitor.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-logout-dialog.c
26missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-logout-dialog.h
28missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
50syntaxErrorerrorsyntax error
mate-session/gsm-manager-glue.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
564missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-manager.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
43missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
191unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-session/gsm-manager.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
184syntaxErrorerrorsyntax error
mate-session/gsm-marshal.c
3missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-marshal.h
5missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37syntaxErrorerrorsyntax error
mate-session/gsm-presence-glue.h
4missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
152missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-presence.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-presence.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-session-save.c
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-session-save.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-store.c
22missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
57unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-session/gsm-store.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-systemd.c
21missingIncludeinformationInclude file: "config.h" not found.
23missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <systemd/sd-login.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-systemd.h
27missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-util.c
22missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
190variableScope398styleThe scope of the variable 'filename' can be reduced.
mate-session/gsm-util.h
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-xsmp-client.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-session/gsm-xsmp-client.h
27missingIncludeSysteminformationInclude file: <X11/SM/SMlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/gsm-xsmp-server.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <X11/ICE/ICElib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <X11/ICE/ICEutil.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <X11/ICE/ICEconn.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <X11/SM/SMlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
47missingIncludeSysteminformationInclude file: <X11/Xtrans/Xtrans.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
85unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-session/gsm-xsmp-server.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/main.c
23missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <dbus/dbus.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <dbus/dbus-glib-bindings.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <dbus/dbus-glib-lowlevel.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/mdm-log.c
24missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <syslog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/mdm-log.h
27missingIncludeSysteminformationInclude file: <stdarg.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/mdm-signal-handler.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <execinfo.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <syslog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <glib/gstdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
76unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
mate-session/mdm-signal-handler.h
25missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27syntaxErrorerrorsyntax error
mate-session/mdm.c
31missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <sys/un.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <X11/Xauth.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/mdm.h
32missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/msm-gnome.c
25missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <signal.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/test-client-dbus.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-session/test-inhibit.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <dbus/dbus-glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-submodules/libegg/eggdesktopfile.c
25missingIncludeinformationInclude file: "config.h" not found.
30missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
334constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
348constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
362constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
383constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
497variableScope398styleThe scope of the variable 'try_exec' can be reduced.
497variableScope398styleThe scope of the variable 'found_program' can be reduced.
498variableScope398styleThe scope of the variable 'only_show_in' can be reduced.
498variableScope398styleThe scope of the variable 'not_show_in' can be reduced.
500variableScope398styleThe scope of the variable 'i' can be reduced.
575constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
594constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
610constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
622variableScope398styleThe scope of the variable 'p' can be reduced.
649constParameterPointer398styleParameter 'desktop_file' can be declared as pointer to const
657constVariablePointer398styleVariable 'doc' can be declared as pointer to const
mate-submodules/libegg/eggdesktopfile.h
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-submodules/libegg/eggsmclient-private.h
23missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-submodules/libegg/eggsmclient-xsmp.c
24missingIncludeinformationInclude file: "config.h" not found.
31missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <X11/SM/SMlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gdk/gdk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
182unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE is a macro then please configure it.
1298missingIncludeSysteminformationInclude file: <X11/ICE/ICElib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
1299missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-submodules/libegg/eggsmclient.c
20missingIncludeinformationInclude file: "config.h" not found.
22missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
48unknownMacroerrorThere is an unknown macro here somewhere. Configuration is required. If G_DEFINE_TYPE_WITH_PRIVATE is a macro then please configure it.
mate-submodules/libegg/eggsmclient.h
23missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
mate-submodules/libegg/eggtreemultidnd.c
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46unusedStructMember563stylestruct member '_TreeViewDragInfo::source_target_list' is never used.
49unusedStructMember563stylestruct member '_TreeViewDragInfo::dest_target_list' is never used.
187constVariablePointer398styleVariable 'priv_data' can be declared as pointer to const
254constVariablePointer398styleVariable 'di' can be declared as pointer to const
mate-submodules/libegg/eggtreemultidnd.h
23missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
tools/mate-session-check-accelerated-gl-helper.c
72missingIncludeSysteminformationInclude file: <ctype.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
73missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
74missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
75missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
76missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
77missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
79missingIncludeSysteminformationInclude file: <regex.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
82missingIncludeSysteminformationInclude file: <kenv.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
85missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
86missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
87missingIncludeSysteminformationInclude file: <X11/extensions/Xcomposite.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
88missingIncludeSysteminformationInclude file: <GL/gl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
89missingIncludeSysteminformationInclude file: <GL/glx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
tools/mate-session-check-accelerated-gles-helper.c
28missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <GLES2/gl2.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <GLES2/gl2ext.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <EGL/egl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
42missingIncludeSysteminformationInclude file: <EGL/eglext.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
tools/mate-session-check-accelerated.c
25missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <epoxy/gl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <X11/Xatom.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
64constVariablePointer398styleVariable 'ev' can be declared as pointer to const
198constVariablePointer398styleVariable 'is_accelerated_ptr' can be declared as pointer to const
tools/mate-session-inhibit.c
21missingIncludeinformationInclude file: "config.h" not found.
23missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <sys/wait.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
tools/mate-session-save.c
24missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/stats.html b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/stats.html new file mode 100644 index 0000000..6cd11d8 --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/stats.html @@ -0,0 +1,195 @@ + + + + + + Cppcheck - HTML report - mate-session-manager + + + + + +
+ + + + + +
+ + diff --git a/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/style.css b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-01-23-114035-8717-cppcheck@861c50b8d78a_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} -- cgit v1.2.1