From fac22fad6c018807799a4849934a67229c28a27a Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Thu, 22 Feb 2024 18:58:56 +0000 Subject: Deploy mate-desktop/mate-user-share to github.com/mate-desktop/mate-user-share.git:gh-pages --- .../0.html | 1567 ++++++++++++++++++++ .../1.html | 1123 ++++++++++++++ .../2.html | 833 +++++++++++ .../3.html | 1251 ++++++++++++++++ .../index.html | 212 +++ .../stats.html | 170 +++ .../style.css | 177 +++ 7 files changed, 5333 insertions(+) create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/0.html create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/1.html create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/2.html create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/3.html create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/index.html create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/stats.html create mode 100644 2022-10-29-134846-0734-cppcheck@fcf648868871_master/style.css (limited to '2022-10-29-134846-0734-cppcheck@fcf648868871_master') diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/0.html b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/0.html new file mode 100644 index 0000000..7a4ab90 --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/0.html @@ -0,0 +1,1567 @@ + + + + + + Cppcheck - HTML report - mate-user-share + + + + + +
+ + + +
+
  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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+
+/*
+ *  Copyright (C) 2004 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ *  Caja 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.
+ *
+ *  Caja 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: Alexander Larsson <alexl@redhat.com>
+ *
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "user_share-private.h"
+
+#define REALM "Please log in as the user guest"
+#define USER "guest"
+#define GSETTINGS_SCHEMA "org.mate.FileSharing"
+#define GSETTINGS_KEY_FILE_SHARING_ENABLED "enabled"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED "bluetooth-enabled"
+#define GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD "require-password"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ALLOW_WRITE "bluetooth-allow-write"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING "bluetooth-require-pairing"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED "bluetooth-obexpush-enabled"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES "bluetooth-accept-files"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY "bluetooth-notify"
+
+static GtkBuilder* builder;
+static GSettings* settings;
+
+
+static void
+write_out_password (const char *password)
+{
+    char *to_hash;
+    char *ascii_digest;
+    char *line;
+    char *filename;
+    FILE *file;
+
+    to_hash = g_strdup_printf ("%s:%s:%s", USER, REALM, password);
+    ascii_digest = g_compute_checksum_for_string (G_CHECKSUM_MD5, to_hash, strlen (to_hash));
+    g_free (to_hash);
+    line = g_strdup_printf ("%s:%s:%s\n", USER, REALM, ascii_digest);
+    g_free (ascii_digest);
+
+    filename = g_build_filename (g_get_user_config_dir (), "user-share", "passwd", NULL);
+
+    file = fopen (filename, "w");
+    if (file != NULL) {
+	fwrite (line, strlen (line), 1, file);
+	fclose (file);
+    }
+
+    g_free (filename);
+    g_free (line);
+}
+
+static void
+flush_password (void)
+{
+    GtkWidget *password_entry;
+    const char *password;
+
+    password_entry = GTK_WIDGET (gtk_builder_get_object (builder, "password_entry"));
+
+    if (g_object_get_data (G_OBJECT( password_entry), "user_edited")) {
+	password = gtk_entry_get_text (GTK_ENTRY (password_entry));
+	if (password != NULL && password[0] != 0)
+	    write_out_password (password);
+    }
+}
+
+
+static void
+update_ui (void)
+{
+    GSettings *settings;
+    gboolean enabled;
+#ifdef HAVE_BLUETOOTH
+    gboolean bluetooth_enabled, bluetooth_write_enabled, require_pairing_enabled;
+    gboolean bluetooth_obexpush_enabled, bluetooth_obexpush_notify;
+#endif /* HAVE_BLUETOOTH */
+    char *str;
+    PasswordSetting password_setting;
+    AcceptSetting accept_setting;<--- Unused variable: accept_setting
+    GtkWidget *check;
+    GtkWidget *password_combo;
+    GtkWidget *password_entry;
+#ifdef HAVE_BLUETOOTH
+    GtkWidget *vbox_share_bluetooth;
+    GtkWidget *vbox_receive_bluetooth;
+    GtkWidget *bluetooth_check;
+    GtkWidget *allow_write_bluetooth_check;
+    GtkWidget *require_pairing_check;
+    GtkWidget *enable_obexpush_check;
+    GtkWidget *accept_obexpush_combo;
+    GtkWidget *notify_received_obexpush_check;
+#endif /* HAVE_BLUETOOTH */
+
+    settings = g_settings_new (GSETTINGS_SCHEMA);
+
+    enabled = g_settings_get_boolean (settings,
+				     FILE_SHARING_ENABLED);
+
+    str = g_settings_get_string (settings, FILE_SHARING_REQUIRE_PASSWORD);
+    password_setting = password_setting_from_string (str);
+    g_free (str);
+
+#ifdef HAVE_BLUETOOTH
+    bluetooth_enabled = g_settings_get_boolean (settings,
+    					       FILE_SHARING_BLUETOOTH_ENABLED);
+    bluetooth_write_enabled = g_settings_get_boolean (settings,
+						     FILE_SHARING_BLUETOOTH_ALLOW_WRITE);
+    require_pairing_enabled = g_settings_get_boolean (settings,
+    						     FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING);
+    bluetooth_obexpush_enabled = g_settings_get_boolean (settings,
+    							FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED);
+    bluetooth_obexpush_notify = g_settings_get_boolean (settings,
+    						       FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY);
+
+    str = g_settings_get_string (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES);
+    accept_setting = accept_setting_from_string (str);
+    g_free (str);
+#endif /* HAVE_BLUETOOTH */
+
+    check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_check"));
+    password_combo = GTK_WIDGET (gtk_builder_get_object (builder, "password_combo"));
+    password_entry = GTK_WIDGET (gtk_builder_get_object (builder, "password_entry"));
+#ifdef HAVE_BLUETOOTH
+    vbox_share_bluetooth = GTK_WIDGET (gtk_builder_get_object (builder, "vbox_share_bluetooth"));
+    vbox_receive_bluetooth = GTK_WIDGET (gtk_builder_get_object (builder, "vbox_receive_bluetooth"));
+    bluetooth_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_bluetooth_check"));
+    allow_write_bluetooth_check = GTK_WIDGET (gtk_builder_get_object (builder, "allow_write_bluetooth_check"));
+    require_pairing_check = GTK_WIDGET (gtk_builder_get_object (builder, "require_pairing_check"));
+    enable_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_obexpush_check"));
+    accept_obexpush_combo = GTK_WIDGET (gtk_builder_get_object (builder, "accept_obexpush_combo"));
+    notify_received_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "notify_received_obexpush_check"));
+#endif /* HAVE_BLUETOOTH */
+
+    /* Network */
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), enabled);
+    gtk_widget_set_sensitive (password_combo, enabled);
+    gtk_widget_set_sensitive (password_entry, enabled && password_setting != PASSWORD_NEVER);
+
+    gtk_combo_box_set_active (GTK_COMBO_BOX (password_combo),
+			      password_setting);
+
+#ifdef HAVE_BLUETOOTH
+    /* Bluetooth ObexFTP */
+    gtk_widget_set_visible (vbox_share_bluetooth, TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bluetooth_check), bluetooth_enabled);
+    gtk_widget_set_sensitive (allow_write_bluetooth_check, bluetooth_enabled);
+    gtk_widget_set_sensitive (require_pairing_check, bluetooth_enabled);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (allow_write_bluetooth_check),
+    				  bluetooth_write_enabled);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (require_pairing_check),
+    				  require_pairing_enabled);
+
+    /* Bluetooth ObexPush */
+    gtk_widget_set_visible (vbox_receive_bluetooth, TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_obexpush_check), bluetooth_obexpush_enabled);
+    gtk_widget_set_sensitive (accept_obexpush_combo, bluetooth_obexpush_enabled);
+    gtk_widget_set_sensitive (notify_received_obexpush_check, bluetooth_obexpush_enabled);
+
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (notify_received_obexpush_check),
+    				  bluetooth_obexpush_notify);
+
+    gtk_combo_box_set_active (GTK_COMBO_BOX (accept_obexpush_combo),
+    			      accept_setting);
+#endif /* HAVE_BLUETOOTH */
+
+    g_object_unref (settings);
+}
+
+static void
+file_sharing_enabled_changed (GSettings *settings, gchar *key, gpointer data)
+{
+    update_ui ();
+}
+
+static void
+password_required_changed (GSettings *settings, gchar *key, gpointer data)
+{
+    update_ui ();
+}
+
+#ifdef HAVE_BLUETOOTH
+static void
+file_sharing_bluetooth_enabled_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	update_ui ();
+}
+
+static void
+file_sharing_bluetooth_allow_write_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	update_ui ();
+}
+
+static void
+file_sharing_bluetooth_require_pairing_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	update_ui ();
+}
+
+static void
+file_sharing_bluetooth_obexpush_enabled_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	update_ui ();
+}
+
+static void
+file_sharing_bluetooth_obexpush_accept_files_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	update_ui ();
+}
+
+static void
+file_sharing_bluetooth_obexpush_notify_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	update_ui ();
+}
+#endif /* HAVE_BLUETOOTH */
+
+static void
+password_combo_changed (GtkComboBox *combo_box)
+{
+    GSettings *settings;
+    guint setting;
+
+    setting = gtk_combo_box_get_active (combo_box);
+
+    settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+    g_settings_set_string (settings,
+			     FILE_SHARING_REQUIRE_PASSWORD,
+			     password_string_from_setting (setting));
+    g_object_unref (settings);
+}
+
+static void
+launch_share (void)
+{
+	if (!g_spawn_command_line_async (USER_SHARE_PROGRAM, NULL))
+		g_warning ("Unable to start mate-user-share program");
+}
+
+#ifdef HAVE_BLUETOOTH
+static void
+enable_bluetooth_check_toggled (GtkWidget *check)
+{
+	GSettings *settings;
+	gboolean enabled;
+
+	enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+
+	settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+	g_settings_set_boolean (settings,
+			       FILE_SHARING_BLUETOOTH_ENABLED,
+			       enabled);
+
+	g_object_unref (settings);
+
+	if (enabled != FALSE)
+		launch_share ();
+}
+#endif /* HAVE_BLUETOOTH */
+
+static void
+enable_check_toggled (GtkWidget *check)
+{
+	GSettings *settings;
+	gboolean enabled;
+
+	enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+
+	settings = g_settings_new (GSETTINGS_SCHEMA);
+
+	g_settings_set_boolean (settings,
+			       FILE_SHARING_ENABLED,
+			       enabled);
+
+	g_object_unref (settings);
+
+	if (enabled != FALSE)
+		launch_share ();
+}
+
+static void
+password_entry_changed (GtkEditable *editable)
+{
+	g_object_set_data (G_OBJECT (editable),
+			   "user_edited", GINT_TO_POINTER (1));
+	flush_password ();
+}
+
+#ifdef HAVE_BLUETOOTH
+static void
+bluetooth_allow_write_check_toggled (GtkWidget *check)
+{
+	GSettings *settings;
+	gboolean enabled;
+
+	enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+
+	settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+	g_settings_set_boolean (settings,
+			       FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
+			       enabled);
+
+	g_object_unref (settings);
+}
+
+static void
+bluetooth_require_pairing_check_toggled (GtkWidget *check)
+{
+	GSettings *settings;
+	gboolean enabled;
+
+	enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+
+	settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+	g_settings_set_boolean (settings,
+			       FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
+			       enabled);
+
+	g_object_unref (settings);
+}
+
+static void
+enable_obexpush_check_toggled (GtkWidget *check)
+{
+	GSettings *settings;
+	gboolean enabled;
+
+	enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+
+	settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+	g_settings_set_boolean (settings,
+			       FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
+			       enabled);
+
+	g_object_unref (settings);
+
+	if (enabled != FALSE)
+		launch_share ();
+}
+
+static void
+accept_obexpush_combo_changed (GtkComboBox *combo_box)
+{
+    GSettings *settings;
+    guint setting;
+
+    setting = gtk_combo_box_get_active (combo_box);
+
+    settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+    g_settings_set_string (settings,
+			     FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES,
+			     accept_string_from_setting (setting));
+    g_object_unref (settings);
+}
+
+static void
+notify_received_obexpush_check_toggled (GtkWidget *check)
+{
+	GSettings *settings;
+	gboolean enabled;
+
+	enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+
+	settings = g_settings_new (GSETTINGS_SCHEMA) ;
+
+	g_settings_set_boolean (settings,
+			       FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
+			       enabled);
+
+	g_object_unref (settings);
+}
+#endif /* HAVE_BLUETOOTH */
+
+static GtkWidget *
+error_dialog (const char *title,
+	      const char *reason,
+	      GtkWindow *parent)
+{
+	GtkWidget *error_dialog;
+
+	if (reason == NULL)
+		reason = _("No reason");
+
+	error_dialog =
+		gtk_message_dialog_new (parent,
+					GTK_DIALOG_MODAL,
+					GTK_MESSAGE_ERROR,
+					GTK_BUTTONS_OK,
+					"%s", title);
+	gtk_message_dialog_format_secondary_text
+		(GTK_MESSAGE_DIALOG (error_dialog), "%s", reason);
+
+	gtk_window_set_title (GTK_WINDOW (error_dialog), ""); /* as per HIG */
+	gtk_container_set_border_width (GTK_CONTAINER (error_dialog), 5);
+	gtk_dialog_set_default_response (GTK_DIALOG (error_dialog),
+					 GTK_RESPONSE_OK);
+	gtk_window_set_modal (GTK_WINDOW (error_dialog), TRUE);
+
+	return error_dialog;
+}
+
+static void
+help_button_clicked (GtkButton *button, GtkWidget *window)
+{
+	GError *error = NULL;
+
+	if (gtk_show_uri_on_window (GTK_WINDOW (window), "help:mate-user-share", gtk_get_current_event_time (), &error) == FALSE) {
+		GtkWidget *dialog;
+
+		dialog = error_dialog (_("Could not display the help contents."), error->message, GTK_WINDOW (window));
+		g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK
+				  (gtk_widget_destroy), error_dialog);
+		gtk_window_present (GTK_WINDOW (dialog));
+
+		g_error_free (error);
+	}
+}
+
+static GtkWidget *
+create_window (void)
+{
+    GError *error = NULL;
+    GSettings *settings;
+    GtkWidget *check;
+    GtkWidget *password_combo;
+    GtkWidget *password_entry;
+#ifdef HAVE_BLUETOOTH
+    GtkWidget *bluetooth_check;
+    GtkWidget *bluetooth_allow_write_check;
+    GtkWidget *require_pairing_check;
+    GtkWidget *enable_obexpush_check;
+    GtkWidget *accept_obexpush_combo;
+    GtkWidget *notify_received_obexpush_check;
+#endif /* HAVE_BLUETOOTH */
+    GtkWidget *window;
+    GtkListStore *store;
+    GtkCellRenderer *cell;
+    GtkTreeIter iter;
+
+    builder = gtk_builder_new ();
+    gtk_builder_add_from_file (builder, DATADIR"file-share-properties.ui", &error);
+
+    if (error) {
+      GtkWidget *dialog;
+
+      dialog = error_dialog (_("Could not build interface."), error->message, NULL);
+      gtk_dialog_run (GTK_DIALOG (dialog));
+      gtk_widget_destroy (dialog);
+
+      g_error_free (error);
+      return NULL;
+    }
+
+    window = GTK_WIDGET (gtk_builder_get_object (builder, "user_share_dialog"));
+
+    settings = g_settings_new (GSETTINGS_SCHEMA);
+
+    check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_check"));
+    password_combo = GTK_WIDGET (gtk_builder_get_object (builder, "password_combo"));
+    password_entry = GTK_WIDGET (gtk_builder_get_object (builder, "password_entry"));
+#ifdef HAVE_BLUETOOTH
+    bluetooth_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_bluetooth_check"));
+    bluetooth_allow_write_check = GTK_WIDGET (gtk_builder_get_object (builder, "allow_write_bluetooth_check"));
+    require_pairing_check = GTK_WIDGET (gtk_builder_get_object (builder, "require_pairing_check"));
+    enable_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "enable_obexpush_check"));
+    accept_obexpush_combo = GTK_WIDGET (gtk_builder_get_object (builder, "accept_obexpush_combo"));
+    notify_received_obexpush_check = GTK_WIDGET (gtk_builder_get_object (builder, "notify_received_obexpush_check"));
+#endif /* HAVE_BLUETOOTH */
+
+    store = gtk_list_store_new (1, G_TYPE_STRING);
+    gtk_combo_box_set_model (GTK_COMBO_BOX (password_combo),
+			     GTK_TREE_MODEL (store));
+    cell = gtk_cell_renderer_text_new ();
+    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (password_combo), cell, TRUE);
+    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (password_combo), cell,
+				    "text", 0,
+				    NULL);
+
+    /* Keep in same order as enum */
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0,
+			_("Never"), -1);
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0,
+			_("When writing files"), -1);
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0,
+			_("Always"), -1);
+    g_object_unref (store);
+
+    /* We can't read the password from the text, just set it to something */
+    gtk_entry_set_text (GTK_ENTRY (password_entry), "none");
+    g_object_set_data (G_OBJECT (password_entry),
+		       "user_edited", GINT_TO_POINTER (0));
+    g_signal_connect (password_entry,
+		      "changed", G_CALLBACK (password_entry_changed), NULL);
+
+#ifdef HAVE_BLUETOOTH
+    /* Accept files combo */
+    store = gtk_list_store_new (1, G_TYPE_STRING);
+    gtk_combo_box_set_model (GTK_COMBO_BOX (accept_obexpush_combo),
+			     GTK_TREE_MODEL (store));
+    cell = gtk_cell_renderer_text_new ();
+    gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (accept_obexpush_combo), cell, TRUE);
+    gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (accept_obexpush_combo), cell,
+				    "text", 0,
+				    NULL);
+
+    /* Keep in same order as enum */
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0,
+			_("Always"), -1);
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0,
+			_("Only for set up devices"), -1);
+    //FIXME implement
+#if 0
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter, 0,
+    			_("Ask"), -1);
+#endif
+    g_object_unref (store);
+#endif /* HAVE_BLUETOOTH */
+
+    g_signal_connect (check,
+		      "toggled", G_CALLBACK (enable_check_toggled), NULL);
+    g_signal_connect (password_combo,
+		      "changed", G_CALLBACK (password_combo_changed), NULL);
+#ifdef HAVE_BLUETOOTH
+    g_signal_connect (bluetooth_check,
+    		      "toggled", G_CALLBACK (enable_bluetooth_check_toggled), NULL);
+    g_signal_connect (bluetooth_allow_write_check,
+    		      "toggled", G_CALLBACK (bluetooth_allow_write_check_toggled), NULL);
+    g_signal_connect (require_pairing_check,
+    		      "toggled", G_CALLBACK (bluetooth_require_pairing_check_toggled), NULL);
+    g_signal_connect (enable_obexpush_check,
+    		      "toggled", G_CALLBACK (enable_obexpush_check_toggled), NULL);
+    g_signal_connect (accept_obexpush_combo,
+    		      "changed", G_CALLBACK (accept_obexpush_combo_changed), NULL);
+    g_signal_connect (notify_received_obexpush_check,
+    		      "toggled", G_CALLBACK (notify_received_obexpush_check_toggled), NULL);
+#endif /* HAVE_BLUETOOTH */
+
+    g_signal_connect_swapped (GTK_WIDGET (gtk_builder_get_object (builder, "close_button")),
+                              "clicked", G_CALLBACK (gtk_widget_destroy), window);
+    g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "help_button")),
+		      "clicked", G_CALLBACK (help_button_clicked),
+		      gtk_builder_get_object (builder, "user_share_dialog"));
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_ENABLED,
+			     G_CALLBACK (file_sharing_enabled_changed), NULL);
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD,
+			     G_CALLBACK (password_required_changed), NULL);
+#ifdef HAVE_BLUETOOTH
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED,
+			     G_CALLBACK (file_sharing_bluetooth_enabled_changed), NULL);
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
+			     G_CALLBACK (file_sharing_bluetooth_allow_write_changed), NULL);
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
+			     G_CALLBACK (file_sharing_bluetooth_require_pairing_changed), NULL);
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
+			     G_CALLBACK (file_sharing_bluetooth_obexpush_enabled_changed), NULL);
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES,
+			     G_CALLBACK (file_sharing_bluetooth_obexpush_accept_files_changed), NULL);
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
+			     G_CALLBACK (file_sharing_bluetooth_obexpush_notify_changed), NULL);
+#endif /* HAVE_BLUETOOTH */
+
+    update_ui ();
+
+    return window;
+}
+
+static void
+activate (GtkApplication *app)
+{
+    GList *list;
+    GtkWidget *window;
+
+    list = gtk_application_get_windows (app);
+
+    if (list) {
+        gtk_window_present (GTK_WINDOW (list->data));
+    } else {
+        window = create_window ();
+        gtk_window_set_application (GTK_WINDOW (window), app);
+        gtk_widget_show (window);
+    }
+}
+
+int
+main (int argc, char *argv[])
+{
+    GtkApplication *app;
+    gint status;
+
+    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+    textdomain (GETTEXT_PACKAGE);
+
+    app = gtk_application_new ("org.mate.user-share.properties",
+                               G_APPLICATION_FLAGS_NONE);
+    g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+
+    status = g_application_run (G_APPLICATION (app), argc, argv);
+
+    g_object_unref (app);
+
+    return status;
+}
+
+
+
+ +
+ + diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/1.html b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/1.html new file mode 100644 index 0000000..6ca74fd --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/1.html @@ -0,0 +1,1123 @@ + + + + + + Cppcheck - HTML report - mate-user-share + + + + + +
+ + + +
+
  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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+
+/*
+ *  Copyright (C) 2004-2008 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ *  Caja 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.
+ *
+ *  Caja 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: Alexander Larsson <alexl@redhat.com>
+ *
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <X11/Xlib.h>
+
+#include <gio/gio.h>
+
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_SELINUX
+#include <selinux/selinux.h>
+#endif
+
+#include "user_share-common.h"
+#include "user_share-private.h"
+#include "http.h"
+
+/* From avahi-common/domain.h */
+#define AVAHI_LABEL_MAX 64
+
+#define GSETTINGS_SCHEMA "org.mate.FileSharing"
+
+static pid_t httpd_pid = 0;
+
+static int
+get_port (void)
+{
+	int sock;
+	struct sockaddr_in addr;
+	int reuse;
+	socklen_t len;
+
+	sock = socket (PF_INET, SOCK_STREAM, 0);
+	if (sock < 0) {
+		return -1;
+	}
+
+	memset (&addr, 0, sizeof (addr));
+	addr.sin_port = 0;
+	addr.sin_addr.s_addr = INADDR_ANY;
+	addr.sin_family = AF_INET;
+
+	reuse = 1;
+	setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof (reuse));
+	if (bind (sock, (struct sockaddr *)&addr, sizeof (addr)) == -1) {
+		close (sock);
+		return -1;
+	}
+
+	len = sizeof (addr);
+	if (getsockname (sock, (struct sockaddr *)&addr, &len) == -1) {
+		close (sock);
+		return -1;
+	}
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__OpenBSD__)
+	/* XXX This exposes a potential race condition, but without this,
+	 * httpd will not start on the above listed platforms due to the fact
+	 * that SO_REUSEADDR is also needed when Apache binds to the listening
+	 * socket.  At this time, Apache does not support that socket option.
+	 */
+	close (sock);
+#endif
+	return ntohs (addr.sin_port);
+}
+
+static char *
+truncate_name (const char *name)
+{
+	const char *end;
+
+	end = g_utf8_find_prev_char (name, name + 64);
+	g_assert (end != NULL);
+	return g_strndup (name, end - name);
+}
+
+static char *
+get_share_name (void)
+{
+	static char *name = NULL;
+	const char *host_name;
+	char *str;
+
+	if (name == NULL) {
+		host_name = g_get_host_name ();
+		if (strcmp (host_name, "localhost") == 0) {
+			/* Translators: The %s will get filled in with the user name
+			   of the user, to form a genitive. If this is difficult to
+			   translate correctly so that it will work correctly in your
+			   language, you may use something equivalent to
+			   "Public files of %s", or leave out the %s altogether.
+			   In the latter case, please put "%.0s" somewhere in the string,
+			   which will match the user name string passed by the C code,
+			   but not put the user name in the final string. This is to
+			   avoid the warning that msgfmt might otherwise generate. */
+			name = g_strdup_printf (_("%s's public files"), g_get_user_name ());
+		} else {
+			/* Translators: This is similar to the string before, only it
+			   has the hostname in it too. */
+			name = g_strdup_printf (_("%s's public files on %s"),
+						g_get_user_name (),
+						host_name);
+		}
+
+	}
+	/* And truncate */
+	if (strlen (name) < AVAHI_LABEL_MAX)
+		return name;
+
+	str = truncate_name (name);
+	g_free (name);
+	name = str;
+
+	return name;
+}
+
+static void
+ensure_conf_dir (void)
+{
+	char *dirname;
+
+	dirname = g_build_filename (g_get_user_config_dir (), "user-share", NULL);
+	g_mkdir_with_parents (dirname, 0755);
+	g_free (dirname);
+}
+
+static void
+httpd_child_setup (gpointer user_data)
+{
+#ifdef HAVE_SELINUX
+	char *mycon;
+	/* If selinux is enabled, avoid transitioning to the httpd_t context,
+	   as this normally means you can't read the users homedir. */
+	if (is_selinux_enabled()) {
+		if (getcon (&mycon) < 0) {
+			abort ();
+		}
+		if (setexeccon (mycon) < 0)
+			abort ();
+		freecon (mycon);
+	}
+#endif
+}
+
+static const char *known_httpd_locations [] = {
+	HTTPD_PROGRAM,
+	"/usr/sbin/httpd",
+	"/usr/sbin/httpd2",
+	"/usr/sbin/apache2",
+	NULL
+};
+
+static char*
+get_httpd_program (void)
+{
+	int i;
+
+	for (i = 0; known_httpd_locations[i]; i++) {
+		if (known_httpd_locations[i][0] == '\0') {
+			/* empty string as first element, happens when
+			 * configured --with-httpd=auto */
+			continue;
+		}
+		if (g_file_test (known_httpd_locations[i], G_FILE_TEST_IS_EXECUTABLE)
+				&& ! g_file_test (known_httpd_locations[i], G_FILE_TEST_IS_DIR)) {
+			return g_strdup (known_httpd_locations[i]);
+		}
+	}
+	return NULL;
+}
+
+static const char *known_httpd_modules_locations [] = {
+	HTTPD_MODULES_PATH,
+	"/etc/httpd/modules",
+	"/usr/lib/apache2/modules",
+	NULL
+};
+
+static gchar*
+get_httpd_modules_path (void)
+{
+	int i;
+
+	for (i = 0; known_httpd_modules_locations[i]; i++) {
+		if (known_httpd_modules_locations[i][0] == '\0') {
+			/* empty string as first element, happens when
+			 * configured --with-httpd=auto */
+			continue;
+		}
+		if (g_file_test (known_httpd_modules_locations[i], G_FILE_TEST_IS_EXECUTABLE)
+				&& g_file_test (known_httpd_modules_locations[i], G_FILE_TEST_IS_DIR)) {
+			return g_strdup (known_httpd_modules_locations[i]);
+		}
+	}
+	return NULL;
+}
+
+static GRegex *version_regex = NULL;
+
+static char*
+get_httpd_config (const char *httpd_program)
+{
+	gchar *standard_output;
+	gchar *cmd_line;
+	GMatchInfo *match_info;
+	gchar *version_number = NULL;
+	gchar *config;
+
+	cmd_line = g_strdup_printf ("%s -v", httpd_program);
+	if (! g_spawn_command_line_sync (cmd_line, &standard_output, NULL, NULL, NULL)) {
+		g_free (cmd_line);
+		return NULL;
+	}
+	g_free (cmd_line);
+
+	if (version_regex == NULL) {
+		version_regex = g_regex_new ("\\d\\.\\d", 0, 0, NULL);
+	}
+
+	if (g_regex_match (version_regex, standard_output, 0, &match_info)) {
+		while (g_match_info_matches (match_info)) {
+			version_number = g_match_info_fetch (match_info, 0);
+			break;
+		}
+		g_match_info_free (match_info);
+		g_free (standard_output);
+	} else {
+		/* Failed to parse httpd version number */
+		g_warning ("Could not parse '%s' as a version for httpd", standard_output);
+		g_free (standard_output);
+		/* assume it is 2.2 */
+		version_number = g_strdup ("2.2");
+	}
+
+	config = g_strdup_printf (HTTPD_CONFIG_TEMPLATE, version_number);
+	g_free (version_number);
+
+	return config;
+}
+
+static gboolean
+spawn_httpd (int port, pid_t *pid_out)
+{
+	char *free1, *free2, *free3, *free4, *free5, *free6, *free7, *free8, *free9;
+	gboolean res;
+	char *argv[10];
+	char *env[10];
+	int i;
+	gint status;
+	char *pid_filename;
+	char *pidfile;
+	GError *error;
+	gboolean got_pidfile;
+	GSettings *settings;
+	char *str;
+	char *public_dir;
+
+	public_dir = lookup_public_dir ();
+	ensure_conf_dir ();
+
+	i = 0;
+	free1 = argv[i++] = get_httpd_program ();
+	if (argv[0] == NULL) {
+		fprintf (stderr, "error finding httpd server\n");
+		return FALSE;
+	}
+
+	argv[i++] = "-f";
+	free2 = argv[i++] = get_httpd_config (argv[0]);
+	argv[i++] = "-C";
+	free3 = argv[i++] = g_strdup_printf ("Listen %d", port);
+
+	settings = g_settings_new (GSETTINGS_SCHEMA);
+	str = g_settings_get_string (settings,
+				       FILE_SHARING_REQUIRE_PASSWORD);
+
+	if (str && strcmp (str, "never") == 0) {
+		/* Do nothing */
+	} else if (str && strcmp (str, "on_write") == 0){
+		argv[i++] = "-D";
+		argv[i++] = "RequirePasswordOnWrite";
+	} else {
+		/* always, or safe fallback */
+		argv[i++] = "-D";
+		argv[i++] = "RequirePasswordAlways";
+	}
+	g_free (str);
+	g_object_unref (settings);
+
+	argv[i] = NULL;
+
+	i = 0;
+	free4 = env[i++] = g_strdup_printf ("HOME=%s", g_get_home_dir());
+	free5 = env[i++] = g_strdup_printf ("XDG_PUBLICSHARE_DIR=%s", public_dir);
+	free6 = env[i++] = g_strdup_printf ("XDG_CONFIG_HOME=%s", g_get_user_config_dir ());
+	free7 = env[i++] = g_strdup_printf ("GUS_SHARE_NAME=%s", get_share_name ());
+	free8 = env[i++] = g_strdup_printf ("GUS_LOGIN_LABEL=%s", "Please log in as the user guest");
+	free9 = env[i++] = g_strdup_printf ("HTTP_MODULES_PATH=%s",get_httpd_modules_path ());
+	env[i++] = "LANG=C";
+	env[i] = NULL;
+
+	pid_filename = g_build_filename (g_get_user_config_dir (), "user-share", "pid", NULL);
+
+	/* Remove pid file before spawning to avoid races with child and old pidfile */
+	unlink (pid_filename);
+
+	error = NULL;
+	res = g_spawn_sync (g_get_home_dir(),
+			    argv, env, 0,
+			    httpd_child_setup, NULL,
+			    NULL, NULL,
+			    &status,
+			    &error);
+	g_free (free1);
+	g_free (free2);
+	g_free (free3);
+	g_free (free4);
+	g_free (free5);
+	g_free (free6);
+	g_free (free7);
+	g_free (free8);
+	g_free (free9);
+	g_free (public_dir);
+
+	if (!res) {
+		fprintf (stderr, "error spawning httpd: %s\n",
+			 error->message);
+		g_error_free (error);
+		g_free (pid_filename);
+		return FALSE;
+	}
+
+	if (status != 0) {
+		g_free (pid_filename);
+		return FALSE;
+	}
+
+	got_pidfile = FALSE;
+	error = NULL;
+	for (i = 0; i < 5; i++) {
+		if (error != NULL)
+			g_error_free (error);
+		error = NULL;
+		if (g_file_get_contents (pid_filename, &pidfile, NULL, &error)) {
+			got_pidfile = TRUE;
+			*pid_out = atoi (pidfile);
+			g_free (pidfile);
+			break;
+		}
+		sleep (1);
+	}
+
+	g_free (pid_filename);
+
+	if (!got_pidfile) {
+		fprintf (stderr, "error opening httpd pidfile: %s\n", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+	return TRUE;
+}
+
+static void
+kill_httpd (void)
+{
+	if (httpd_pid != 0) {
+		kill (httpd_pid, SIGTERM);
+
+		/* Allow child time to die, we can't waitpid, because its
+		   not a direct child */
+		sleep (1);
+	}
+	httpd_pid = 0;
+}
+
+void
+http_up (void)
+{
+	guint port;
+
+	port = get_port ();
+	if (!spawn_httpd (port, &httpd_pid)) {
+		fprintf (stderr, "spawning httpd failed\n");
+	}
+}
+
+void
+http_down (void)
+{
+	kill_httpd ();
+}
+
+gboolean
+http_init (void)
+{
+	return TRUE;
+}
+
+pid_t
+http_get_pid (void)
+{
+	return httpd_pid;
+}
+
+
+
+ +
+ + diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/2.html b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/2.html new file mode 100644 index 0000000..1682147 --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/2.html @@ -0,0 +1,833 @@ + + + + + + Cppcheck - HTML report - mate-user-share + + + + + +
+ + + +
+
  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
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+ *
+ * Copyright (C) 2003 Novell, Inc.
+ * Copyright (C) 2003-2004 Red Hat, Inc.
+ * Copyright (C) 2005 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 <stdlib.h>
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <libcaja-extension/caja-menu-provider.h>
+#include <libcaja-extension/caja-location-widget-provider.h>
+
+#ifdef HAVE_BLUETOOTH
+#include <bluetooth-client.h>
+#endif
+
+#include "caja-share-bar.h"
+#include "user_share-common.h"
+
+#define CAJA_TYPE_USER_SHARE  (caja_user_share_get_type ())
+#define CAJA_USER_SHARE(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), CAJA_TYPE_USER_SHARE, CajaUserShare))
+#define CAJA_IS_USER_SHARE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CAJA_TYPE_USER_SHARE))
+
+typedef struct
+{
+        GObject              parent_slot;
+} CajaUserShare;
+
+typedef struct
+{
+        GObjectClass parent_slot;
+} CajaUserShareClass;
+
+static GType caja_user_share_get_type      (void);
+static void  caja_user_share_register_type (GTypeModule *module);
+
+static void
+launch_process (char **argv, GtkWindow *parent)
+{
+        GError *error;
+        GtkWidget *dialog;
+
+        error = NULL;
+        if (!g_spawn_async (NULL,
+                            argv, NULL,
+                            0,
+                            NULL, NULL,
+                            NULL,
+                            &error)) {
+
+
+                dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
+						 GTK_BUTTONS_OK, _("Unable to launch the Personal File Sharing preferences"));
+
+                gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
+
+                gtk_dialog_run (GTK_DIALOG (dialog));
+                gtk_widget_destroy (dialog);
+
+                g_error_free (error);
+        }
+}
+
+static void
+launch_prefs_on_window (GtkWindow *window)
+{
+        char *argv [2];
+
+        argv [0] = g_build_filename (BINDIR, "mate-file-share-properties", NULL);
+        argv [1] = NULL;
+
+        launch_process (argv, window);
+
+        g_free (argv [0]);
+}
+
+static void
+bar_response_cb (CajaShareBar *bar,
+                 gint response,
+                 gpointer         data)
+{
+        if (response == CAJA_SHARE_BAR_RESPONSE_PREFERENCES) {
+                launch_prefs_on_window (GTK_WINDOW (data));
+        }
+}
+
+#ifdef HAVE_BLUETOOTH
+static void
+downloads_bar_set_from_bluetooth_status (GtkWidget *bar)
+{
+	BluetoothClient *client;
+	gboolean bt_powered;
+
+	client = g_object_get_data (G_OBJECT (bar), "bluetooth-client");
+	g_object_get (G_OBJECT (client),
+		      "default-adapter-powered", &bt_powered,
+		      NULL);
+	gtk_widget_set_visible (bar, bt_powered);
+}
+
+static void
+default_adapter_powered_cb (GObject    *gobject,
+			    GParamSpec *pspec,
+			    GtkWidget  *bar)
+{
+	downloads_bar_set_from_bluetooth_status (bar);
+}
+#endif /* HAVE_BLUETOOTH */
+
+static GtkWidget *
+caja_user_share_get_location_widget (CajaLocationWidgetProvider *iface,
+                                         const char                     *uri,
+                                         GtkWidget                      *window)
+{
+	GFile             *file;
+	GtkWidget         *bar;
+	guint              i;
+	gboolean           enable = FALSE;
+	GFile             *home;
+#ifdef HAVE_BLUETOOTH
+	const GUserDirectory special_dirs[] = { G_USER_DIRECTORY_PUBLIC_SHARE, G_USER_DIRECTORY_DOWNLOAD };
+
+	gboolean is_dir[] = { FALSE, FALSE };
+#else
+	const GUserDirectory special_dirs[] = { G_USER_DIRECTORY_PUBLIC_SHARE };
+
+	gboolean is_dir[] = { FALSE };
+#endif /* HAVE_BLUETOOTH */
+	file = g_file_new_for_uri (uri);
+	home = g_file_new_for_path (g_get_home_dir ());
+
+	/* We don't show anything in $HOME */
+	if (g_file_equal (home, file)) {
+		g_object_unref (home);
+		g_object_unref (file);
+		return NULL;
+	}
+
+	g_object_unref (home);
+
+	for (i = 0; i < G_N_ELEMENTS (special_dirs); i++) {
+		GFile *dir;
+		dir = lookup_dir_with_fallback (special_dirs[i]);
+		if (g_file_equal (dir, file)) {
+			enable = TRUE;
+			is_dir[i] = TRUE;
+		}
+		g_object_unref (dir);
+	}
+
+	g_object_unref (file);
+
+	if (enable == FALSE)
+		return NULL;
+
+	if (is_dir[0] != FALSE) {
+#ifdef HAVE_BLUETOOTH
+		if (is_dir[1] != FALSE) {
+			bar = caja_share_bar_new (_("May be used to share or receive files"));
+		} else {
+			bar = caja_share_bar_new (_("May be shared over the network or Bluetooth"));
+		}
+#else
+		bar = caja_share_bar_new (_("May be shared over the network"));
+#endif /* HAVE_BLUETOOTH */
+	} else {
+#ifdef HAVE_BLUETOOTH
+		BluetoothClient *client;
+
+		bar = caja_share_bar_new (_("May be used to receive files over Bluetooth"));
+
+		gtk_widget_set_no_show_all (bar, TRUE);
+		client = bluetooth_client_new ();
+		g_object_set_data_full (G_OBJECT (bar), "bluetooth-client", client, g_object_unref);
+		g_signal_connect (G_OBJECT (client), "notify::default-adapter-powered",
+				  G_CALLBACK (default_adapter_powered_cb), bar);
+		downloads_bar_set_from_bluetooth_status (bar);
+#endif /* HAVE_BLUETOOTH */
+	}
+
+	g_signal_connect (bar, "response",
+			  G_CALLBACK (bar_response_cb),
+			  window);
+
+	gtk_widget_show_all (bar);
+
+	return bar;
+}
+
+static void
+caja_user_share_location_widget_provider_iface_init (CajaLocationWidgetProviderIface *iface)
+{
+        iface->get_widget = caja_user_share_get_location_widget;
+}
+
+static void
+caja_user_share_instance_init (CajaUserShare *share)
+{
+
+}
+
+static void
+caja_user_share_class_init (CajaUserShareClass *klass)
+{
+
+}
+
+static GType share_type = 0;
+
+static GType
+caja_user_share_get_type (void)
+{
+        return share_type;
+}
+
+static void
+caja_user_share_register_type (GTypeModule *module)
+{
+        static const GTypeInfo info = {
+                sizeof (CajaUserShareClass),
+                (GBaseInitFunc) NULL,
+                (GBaseFinalizeFunc) NULL,
+                (GClassInitFunc) caja_user_share_class_init,
+                NULL,
+                NULL,
+                sizeof (CajaUserShare),
+                0,
+                (GInstanceInitFunc) caja_user_share_instance_init,
+        };
+
+        static const GInterfaceInfo location_widget_provider_iface_info = {
+                (GInterfaceInitFunc) caja_user_share_location_widget_provider_iface_init,
+                NULL,
+                NULL
+        };
+
+        share_type = g_type_module_register_type (module,
+                                                 G_TYPE_OBJECT,
+                                                 "CajaUserShare",
+                                                 &info, 0);
+
+        g_type_module_add_interface (module,
+                                     share_type,
+                                     CAJA_TYPE_LOCATION_WIDGET_PROVIDER,
+                                     &location_widget_provider_iface_info);
+}
+
+void
+caja_module_initialize (GTypeModule *module)
+{
+        caja_user_share_register_type (module);
+        bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+}
+
+void
+caja_module_shutdown (void)
+{
+}
+
+void
+caja_module_list_types (const GType **types,
+                            int          *num_types)
+{
+        static GType type_list [1];
+
+        type_list[0] = CAJA_TYPE_USER_SHARE;
+
+        *types = type_list;
+        *num_types = 1;
+}
+
+
+
+ +
+ + diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/3.html b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/3.html new file mode 100644 index 0000000..7bdfa00 --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/3.html @@ -0,0 +1,1251 @@ + + + + + + Cppcheck - HTML report - mate-user-share + + + + + +
+ + + +
+
  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
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+
+/*
+ *  Copyright (C) 2004-2008 Red Hat, Inc.
+ *  Copyright (C) 2012-2021 MATE Developers
+ *
+ *  Caja 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.
+ *
+ *  Caja 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: Alexander Larsson <alexl@redhat.com>
+ *
+ */
+
+#include "config.h"
+
+#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gio/gio.h>
+#include <X11/Xlib.h>
+
+#include "user_share-private.h"
+#include "user_share-common.h"
+#include "http.h"
+
+#ifdef HAVE_BLUETOOTH
+#include <bluetooth-client.h>
+
+#include "obexftp.h"
+#include "obexpush.h"
+
+#endif /* HAVE_BLUETOOTH */
+
+#include <gio/gio.h>
+
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
+
+static guint disabled_timeout_tag = 0;
+static GSettings* settings;<--- Shadowed declaration
+
+#define GSETTINGS_SCHEMA "org.mate.FileSharing"
+#define GSETTINGS_KEY_FILE_SHARING_ENABLED "enabled"
+#define GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD "require-password"
+
+#ifdef HAVE_BLUETOOTH
+/* MATE Session */
+#define MATE_SESSION_DBUS_NAME      "org.gnome.SessionManager"
+#define MATE_SESSION_DBUS_OBJECT    "/org/gnome/SessionManager"
+#define MATE_SESSION_DBUS_INTERFACE "org.gnome.SessionManager"
+
+static GDBusProxy *session_proxy = NULL;
+static gboolean has_console = TRUE;
+
+static BluetoothClient *client = NULL;
+static gboolean bluetoothd_enabled = FALSE;
+
+#define OBEX_ENABLED (bluetoothd_enabled && has_console)
+
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED "bluetooth-enabled"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ALLOW_WRITE "bluetooth-allow-write"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING "bluetooth-require-pairing"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED "bluetooth-obexpush-enabled"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES "bluetooth-accept-files"
+#define GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY "bluetooth-notify"
+
+
+static void
+obex_services_start (void)
+{
+	GSettings *settings;
+
+	if (bluetoothd_enabled == FALSE ||
+	    has_console == FALSE)
+	    	return;
+
+	settings = g_settings_new(GSETTINGS_SCHEMA);
+
+	if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == TRUE) {
+	    obexpush_up ();
+	}
+	if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == TRUE) {
+	    obexftp_up ();
+	}
+
+	g_object_unref (client);
+}
+
+static void
+obex_services_shutdown (void)
+{
+	obexpush_down ();
+	obexftp_down ();
+}
+
+static void
+session_properties_changed_cb (GDBusProxy      *session,
+			       GVariant        *changed,
+			       char           **invalidated,
+			       gpointer         user_data)
+{
+	GVariant *v;
+
+	v = g_variant_lookup_value (changed, "SessionIsActive", G_VARIANT_TYPE_BOOLEAN);
+	if (v) {
+		has_console = g_variant_get_boolean (v);
+		g_debug ("Received session is active change: now %s", has_console ? "active" : "inactive");
+
+		if (has_console)
+			obex_services_start ();
+		else
+			obex_services_shutdown ();
+
+		g_variant_unref (v);
+	}
+}
+
+static gboolean
+is_session_active (void)
+{
+	GVariant *variant;
+	gboolean is_session_active = FALSE;
+
+	variant = g_dbus_proxy_get_cached_property (session_proxy,
+						    "SessionIsActive");
+	if (variant) {
+		is_session_active = g_variant_get_boolean (variant);
+		g_variant_unref (variant);
+ 	}
+
+	return is_session_active;
+}
+
+static void
+session_init (void)
+{
+	GError *error = NULL;
+
+	session_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+						       G_DBUS_PROXY_FLAGS_NONE,
+						       NULL,
+						       MATE_SESSION_DBUS_NAME,
+						       MATE_SESSION_DBUS_OBJECT,
+						       MATE_SESSION_DBUS_INTERFACE,
+						       NULL,
+						       &error);
+	if (session_proxy == NULL) {
+		g_warning ("Failed to get session proxy: %s", error->message);
+		g_error_free (error);
+		return;
+	}
+	g_signal_connect (session_proxy, "g-properties-changed",
+			  G_CALLBACK (session_properties_changed_cb),
+			  NULL);
+	has_console = is_session_active ();
+}
+
+static void
+default_adapter_changed (GObject    *gobject,<--- Parameter 'gobject' can be declared with const
+			 GParamSpec *pspec,
+			 gpointer    user_data)
+{
+	char *adapter;
+	gboolean adapter_powered;
+
+	g_object_get (G_OBJECT (client),
+		      "default-adapter", &adapter,
+		      "default-adapter-powered", &adapter_powered,
+		      NULL);
+	if (adapter != NULL && *adapter != '\0') {
+		bluetoothd_enabled = adapter_powered;
+	} else {
+		bluetoothd_enabled = FALSE;
+	}
+
+	/* Were we called as init, or as a callback */
+	if (gobject != NULL) {
+		if (bluetoothd_enabled != FALSE)
+			obex_services_start ();
+		else
+			obex_services_shutdown ();
+	}
+}
+
+static void
+bluez_init (void)
+{
+	client = bluetooth_client_new ();
+	default_adapter_changed (NULL, NULL, NULL);
+	g_signal_connect (G_OBJECT (client), "notify::default-adapter",
+			  G_CALLBACK (default_adapter_changed), NULL);
+	g_signal_connect (G_OBJECT (client), "notify::default-adapter-powered",
+			  G_CALLBACK (default_adapter_changed), NULL);
+}
+#endif /* HAVE_BLUETOOTH */
+
+static gboolean
+file_sharing_enabled (void)
+{
+	gboolean enabled = TRUE;
+	settings = g_settings_new (GSETTINGS_SCHEMA);
+
+#ifdef HAVE_BLUETOOTH
+	if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
+	    g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE &&
+	    g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
+#else /* HAVE_BLUETOOTH */
+	if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE)
+#endif /* HAVE_BLUETOOTH */
+		enabled = FALSE;
+
+	g_object_unref (settings);
+
+	return enabled;
+}
+
+static void
+migrate_old_configuration (void)
+{
+	const char *old_config_dir;
+	const char *new_config_dir;
+
+	old_config_dir = g_build_filename (g_get_home_dir (), ".mate2", "user-share", NULL);
+	new_config_dir = g_build_filename (g_get_user_config_dir (), "user-share", NULL);
+	if (g_file_test (old_config_dir, G_FILE_TEST_IS_DIR))
+		g_rename (old_config_dir, new_config_dir);
+
+}
+
+static void
+require_password_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	/* Need to restart to get new password setting */
+	if (http_get_pid () != 0) {
+		http_down ();
+		http_up ();
+	}
+}
+
+/* File sharing was disabled for some time, exit now */
+/* If we re-enable it in the ui, this will be restarted anyway */
+static gboolean
+disabled_timeout_callback (gpointer user_data)
+{
+	GSettings *settings = (GSettings *) user_data;
+	http_down ();
+
+#ifdef HAVE_BLUETOOTH
+	if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE &&
+	    g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE)
+		_exit (0);
+#else /* HAVE_BLUETOOTH */
+	if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE)
+		_exit (0);
+#endif /* HAVE_BLUETOOTH */
+	return FALSE;
+}
+
+static void
+file_sharing_enabled_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	gboolean enabled;
+
+	if (disabled_timeout_tag != 0) {
+		g_source_remove (disabled_timeout_tag);
+		disabled_timeout_tag = 0;
+	}
+
+	enabled = g_settings_get_boolean (settings,
+					 FILE_SHARING_ENABLED);
+	if (enabled) {
+		if (http_get_pid () == 0) {
+			http_up ();
+		}
+	} else {
+		http_down ();
+		disabled_timeout_tag = g_timeout_add_seconds (3,
+							      (GSourceFunc)disabled_timeout_callback,
+							      settings);
+	}
+}
+
+#ifdef HAVE_BLUETOOTH
+static void
+file_sharing_bluetooth_allow_write_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) != FALSE)
+		obexftp_restart ();
+}
+
+static void
+file_sharing_bluetooth_require_pairing_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	if (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) != FALSE) {
+		/* We need to fully reset the session,
+		 * otherwise the new setting isn't taken into account */
+		obexftp_down ();
+		obexftp_up ();
+	}
+}
+
+static void
+file_sharing_bluetooth_enabled_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	if (g_settings_get_boolean (settings,
+				   FILE_SHARING_BLUETOOTH_ENABLED) == FALSE) {
+		obexftp_down ();
+		if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
+		    g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE) {
+			_exit (0);
+		}
+	} else if (OBEX_ENABLED) {
+		obexftp_up ();
+	}
+}
+
+static void
+file_sharing_bluetooth_obexpush_enabled_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	if (g_settings_get_boolean (settings,
+				   FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED) == FALSE) {
+		obexpush_down ();
+		if (g_settings_get_boolean (settings, FILE_SHARING_ENABLED) == FALSE &&
+		    g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_ENABLED) == FALSE) {
+			_exit (0);
+		}
+	} else if (OBEX_ENABLED) {
+		obexpush_up ();
+	}
+}
+
+static void
+file_sharing_bluetooth_obexpush_accept_files_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	AcceptSetting setting;
+	char *str;
+
+	str = g_settings_get_string (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES);
+	setting = accept_setting_from_string (str);
+	g_free (str);
+
+	obexpush_set_accept_files_policy (setting);
+}
+
+static void
+file_sharing_bluetooth_obexpush_notify_changed (GSettings *settings, gchar *key, gpointer data)
+{
+	obexpush_set_notify (g_settings_get_boolean (settings, FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY));
+}
+#endif /* HAVE_BLUETOOTH */
+
+static RETSIGTYPE
+cleanup_handler (int sig)
+{
+	http_down ();
+#ifdef HAVE_BLUETOOTH
+	obexftp_down ();
+	obexpush_down ();
+#endif /* HAVE_BLUETOOTH */
+	_exit (2);
+}
+
+static int
+x_io_error_handler (Display *xdisplay)
+{
+	http_down ();
+#ifdef HAVE_BLUETOOTH
+	obexftp_down ();
+#endif /* HAVE_BLUETOOTH */
+	_exit (2);
+}
+
+int
+main (int argc, char **argv)
+{
+	GSettings *settings;<--- Shadow variable
+	Display *xdisplay;
+	G_GNUC_UNUSED int x_fd;
+	Window selection_owner;
+	Atom xatom;
+
+	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+
+	gtk_init (&argc, &argv);
+
+	if (g_strcmp0 (g_get_real_name (), "root") == 0) {
+		g_warning ("mate-user-share cannot be started as root for security reasons.");
+		return 1;
+	}
+
+	signal (SIGPIPE, SIG_IGN);
+	signal (SIGINT, cleanup_handler);
+	signal (SIGHUP, cleanup_handler);
+	signal (SIGTERM, cleanup_handler);
+
+	xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+	if (xdisplay == NULL) {
+		g_warning ("Can't open display");
+		return 1;
+	}
+
+	xatom = XInternAtom (xdisplay, "_MATE_USER_SHARE", FALSE);
+	selection_owner = XGetSelectionOwner (xdisplay, xatom);
+
+	if (selection_owner != None) {
+		/* There is an owner already, quit */
+		return 1;
+	}
+
+	selection_owner = XCreateSimpleWindow (xdisplay,
+					       RootWindow (xdisplay, 0),
+					       0, 0, 1, 1,
+					       0, 0, 0);
+	XSetSelectionOwner (xdisplay, xatom, selection_owner, CurrentTime);
+
+	if (XGetSelectionOwner (xdisplay, xatom) != selection_owner) {
+		/* Didn't get the selection */
+		return 1;
+	}
+
+	migrate_old_configuration ();
+
+	if (!file_sharing_enabled ())
+		return 1;
+
+	settings = g_settings_new (GSETTINGS_SCHEMA);
+
+	x_fd = ConnectionNumber (xdisplay);
+	XSetIOErrorHandler (x_io_error_handler);
+
+	if (http_init () == FALSE)
+		return 1;
+#ifdef HAVE_BLUETOOTH
+	if (obexftp_init () == FALSE)
+		return 1;
+	if (obexpush_init () == FALSE)
+		return 1;
+#endif /* HAVE_BLUETOOTH */
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_ENABLED,
+			     G_CALLBACK (file_sharing_enabled_changed), NULL);
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_REQUIRE_PASSWORD,
+			     G_CALLBACK (require_password_changed), NULL);
+
+#ifdef HAVE_BLUETOOTH
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ENABLED,
+			     G_CALLBACK (file_sharing_bluetooth_enabled_changed), NULL);
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_ALLOW_WRITE,
+			     G_CALLBACK (file_sharing_bluetooth_allow_write_changed), NULL);
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_REQUIRE_PAIRING,
+			     G_CALLBACK (file_sharing_bluetooth_require_pairing_changed), NULL);
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ENABLED,
+			     G_CALLBACK (file_sharing_bluetooth_obexpush_enabled_changed), NULL);
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_ACCEPT_FILES,
+			     G_CALLBACK (file_sharing_bluetooth_obexpush_accept_files_changed), NULL);
+
+    g_signal_connect (settings,
+			     "changed::" GSETTINGS_KEY_FILE_SHARING_BLUETOOTH_OBEXPUSH_NOTIFY,
+			     G_CALLBACK (file_sharing_bluetooth_obexpush_notify_changed), NULL);
+
+	bluez_init ();
+	session_init ();
+#endif /* HAVE_BLUETOOTH */
+
+	/* Initial setting */
+	file_sharing_enabled_changed (settings, NULL, NULL);
+#ifdef HAVE_BLUETOOTH
+	file_sharing_bluetooth_enabled_changed (settings, NULL, NULL);
+	file_sharing_bluetooth_obexpush_accept_files_changed (settings, NULL, NULL);
+	file_sharing_bluetooth_obexpush_notify_changed (settings, NULL, NULL);
+	file_sharing_bluetooth_obexpush_enabled_changed (settings, NULL, NULL);
+#endif /* HAVE_BLUETOOTH */
+
+	gtk_main ();
+
+	return 0;
+}
+
+
+
+ +
+ + diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/index.html b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/index.html new file mode 100644 index 0000000..b780b4e --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/index.html @@ -0,0 +1,212 @@ + + + + + + Cppcheck - HTML report - mate-user-share + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/file-share-properties.c
83variableScope398styleThe scope of the variable 'password' can be reduced.
106unusedVariable563styleUnused variable: accept_setting
621variableScope398styleThe scope of the variable 'window' can be reduced.
src/http.c
115variableScope398styleThe scope of the variable 'host_name' can be reduced.
src/share-extension.c
62variableScope398styleThe scope of the variable 'dialog' can be reduced.
src/user_share.c
175constParameter398styleParameter 'gobject' can be declared with const
392shadowVariable398styleLocal variable 'settings' shadows outer variable
+
+ +
+ + diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/stats.html b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/stats.html new file mode 100644 index 0000000..93d49a4 --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/stats.html @@ -0,0 +1,170 @@ + + + + + + Cppcheck - HTML report - mate-user-share + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 7
+   3  src/file-share-properties.c
+   2  src/user_share.c
+   1  src/share-extension.c
+   1  src/http.c
+

+ +
+ +
+ + diff --git a/2022-10-29-134846-0734-cppcheck@fcf648868871_master/style.css b/2022-10-29-134846-0734-cppcheck@fcf648868871_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2022-10-29-134846-0734-cppcheck@fcf648868871_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