~ubuntu-branches/ubuntu/raring/nautilus-share/raring

« back to all changes in this revision

Viewing changes to .pc/02_install_missing_samba.patch/src/nautilus-share.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2011-07-08 19:29:57 UTC
  • mfrom: (9.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110708192957-smtwyhrxx463r06g
Tags: 0.7.3-1
* [216b642] Update watch URL
* [5935de3] Imported Upstream version 0.7.3 (Closes: #630248)
* [aee4fd0] Drop upstreamed patches
* [8b469c0] Refresh 02_install_missing_samba.patch
* [b3611df] Refresh 99_ltmain_as-needed.patch
* [a049722] Drop explicit libglib2.0-dev build-dep
* [63b282f] Move to dh7

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <libnautilus-extension/nautilus-menu-provider.h>
32
32
#include <libnautilus-extension/nautilus-property-page-provider.h>
33
33
 
34
 
#include <libgnomevfs/gnome-vfs-utils.h>
35
34
#include "nautilus-share.h"
36
35
 
37
 
#include <eel/eel-vfs-extensions.h>
38
 
 
39
36
#include <glib/gi18n-lib.h>
40
37
 
41
 
#include <gtk/gtktable.h>
42
 
#include <gtk/gtkvbox.h>
43
 
#include <gtk/gtkhbox.h>
44
 
#include <gtk/gtklabel.h>
 
38
#include <gio/gio.h>
 
39
 
45
40
#include <gtk/gtk.h>
46
 
#include <gtk/gtkentry.h>
47
 
 
48
 
#include <glade/glade.h>
49
41
 
50
42
#include <string.h>
51
43
#include <time.h>
52
44
 
 
45
#include <sys/types.h>
 
46
#include <sys/stat.h>
53
47
#include <unistd.h>
54
48
#include <stdlib.h>
55
49
 
56
50
#include "shares.h"
57
51
 
58
52
 
59
 
#define NEED_ALWAYS_MASK      (S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)   /* all usershares need go+rx */
 
53
#define NEED_IF_GUESTOK_MASK (S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) /* need go+rx for guest enabled usershares */
60
54
#define NEED_IF_WRITABLE_MASK (S_IWGRP | S_IWOTH)                       /* writable usershares need go+w additionally*/
61
 
#define NEED_ALL_MASK         (NEED_ALWAYS_MASK | NEED_IF_WRITABLE_MASK)
 
55
#define NEED_ALL_MASK         (NEED_IF_GUESTOK_MASK | NEED_IF_WRITABLE_MASK)
62
56
 
63
57
static GObjectClass *parent_class;
64
58
 
69
63
  char *path; /* Full path which is being shared */
70
64
  NautilusFileInfo *fileinfo; /* Nautilus file to which this page refers */
71
65
 
72
 
  GladeXML *xml;
 
66
  GtkBuilder *xml;
73
67
 
74
68
  GtkWidget *main; /* Widget that holds all the rest.  Its "PropertyPage" GObject-data points to this PropertyPage structure */
75
69
  
322
316
} ConfirmPermissionsStatus;
323
317
 
324
318
static ConfirmPermissionsStatus
325
 
confirm_sharing_permissions (GtkWidget *widget, const char *path, gboolean is_shared, gboolean is_writable)
 
319
confirm_sharing_permissions (GtkWidget *widget, const char *path, gboolean is_shared, gboolean guest_ok, gboolean is_writable)
326
320
{
327
321
  struct stat st;
328
322
  mode_t mode, new_mode, need_mask;
333
327
  if (stat (path, &st) != 0)
334
328
    return CONFIRM_NO_MODIFICATIONS; /* We'll just let "net usershare" give back an error if the file disappears */
335
329
 
336
 
  mode = st.st_mode;
337
 
  new_mode = mode | NEED_ALWAYS_MASK;
 
330
  new_mode = mode = st.st_mode;
338
331
 
 
332
  if (guest_ok)
 
333
    new_mode |= NEED_IF_GUESTOK_MASK;
339
334
  if (is_writable)
340
335
    new_mode |= NEED_IF_WRITABLE_MASK;
341
336
 
389
384
  if (is_shared && page->was_writable && !share_info.is_writable)
390
385
    restore_write_permissions (page->path);
391
386
 
392
 
  status = confirm_sharing_permissions (page->main, page->path, is_shared, share_info.is_writable);
 
387
  status = confirm_sharing_permissions (page->main, page->path, is_shared, share_info.guest_ok, share_info.is_writable);
393
388
  if (status == CONFIRM_CANCEL_OR_ERROR)
394
389
    return FALSE; /* the user didn't want us to change his folder's permissions */
395
390
 
414
409
  if (!is_shared)
415
410
    restore_saved_permissions (page->path);
416
411
 
 
412
  /* update initially shared state, so that we may undo later on */
 
413
  if (retval)
 
414
    {
 
415
      page->was_initially_shared = is_shared;
 
416
      page->is_dirty = FALSE;
 
417
    }
 
418
 
417
419
  return retval;
418
420
}
419
421
 
421
423
static gchar *
422
424
get_fullpath_from_fileinfo(NautilusFileInfo *fileinfo)
423
425
{
424
 
  gchar *uri;
 
426
  GFile *file;
425
427
  gchar *fullpath;
426
428
 
427
429
  g_assert (fileinfo != NULL);
428
430
  
429
 
  uri = nautilus_file_info_get_uri(fileinfo);
430
 
  fullpath = gnome_vfs_get_local_path_from_uri(uri);
431
 
  g_assert (fullpath != NULL); /* In the beginning we checked that this was a local URI */
432
 
  g_free(uri);
 
431
  file = nautilus_file_info_get_location(fileinfo);
 
432
  fullpath = g_file_get_path(file);
 
433
  g_assert (fullpath != NULL && g_file_is_native(file)); /* In the beginning we checked that this was a local URI */
 
434
  g_object_unref(file);
433
435
 
434
436
  return(fullpath);
435
437
}
502
504
          return FALSE;
503
505
        }
504
506
      else
505
 
        return TRUE;
 
507
        {
 
508
          property_page_set_normal (page);
 
509
          return TRUE;
 
510
        }
506
511
    }
507
512
}
508
513
 
541
546
    apply_is_sensitive = page->was_initially_shared;
542
547
 
543
548
  gtk_widget_set_sensitive (page->button_apply, apply_is_sensitive);
 
549
  gtk_button_set_label (GTK_BUTTON(page->button_apply),
 
550
                        page->was_initially_shared ? _("Modify _Share") : _("Create _Share"));
544
551
}
545
552
 
546
553
static void
637
644
    {
638
645
      if (page->standalone_window)
639
646
        gtk_widget_destroy (page->standalone_window);
 
647
      else
 
648
        property_page_check_sensitivity (page);
640
649
    }
641
650
}
642
651
 
672
681
 
673
682
      share_info = NULL;
674
683
      g_error_free (error);
 
684
      error = NULL;
675
685
    }
676
686
 
677
 
  page->xml = glade_xml_new(INTERFACES_DIR"/share-dialog.glade","vbox1",GETTEXT_PACKAGE);
678
 
  page->main = glade_xml_get_widget(page->xml,"vbox1");
 
687
 
 
688
  page->xml = gtk_builder_new ();
 
689
  gtk_builder_set_translation_domain (page->xml, "nautilus-share");
 
690
  g_assert (gtk_builder_add_from_file (page->xml,
 
691
              INTERFACES_DIR"/share-dialog.ui", &error));
 
692
 
 
693
  page->main = GTK_WIDGET (gtk_builder_get_object (page->xml, "vbox1"));
 
694
  g_assert (page->main != NULL);
 
695
 
679
696
  g_object_set_data_full (G_OBJECT (page->main),
680
697
                          "PropertyPage",
681
698
                          page,
682
699
                          free_property_page_cb);
683
700
 
684
 
  page->checkbutton_share_folder = glade_xml_get_widget(page->xml,"checkbutton_share_folder");
685
 
  page->hbox_share_comment = glade_xml_get_widget(page->xml,"hbox_share_comment");
686
 
  page->hbox_share_name = glade_xml_get_widget(page->xml,"hbox_share_name");
687
 
  page->checkbutton_share_rw_ro = glade_xml_get_widget(page->xml,"checkbutton_share_rw_ro");
688
 
  page->checkbutton_share_guest_ok = glade_xml_get_widget(page->xml,"checkbutton_share_guest_ok");
689
 
  page->entry_share_name = glade_xml_get_widget(page->xml,"entry_share_name");
690
 
  page->entry_share_comment = glade_xml_get_widget(page->xml,"entry_share_comment");
691
 
  page->label_status = glade_xml_get_widget(page->xml,"label_status");
692
 
  page->button_cancel = glade_xml_get_widget(page->xml,"button_cancel");
693
 
  page->button_apply = glade_xml_get_widget(page->xml,"button_apply");
 
701
  page->checkbutton_share_folder = GTK_WIDGET (gtk_builder_get_object (page->xml,"checkbutton_share_folder"));
 
702
  page->hbox_share_comment = GTK_WIDGET (gtk_builder_get_object (page->xml,"hbox_share_comment"));
 
703
  page->hbox_share_name = GTK_WIDGET (gtk_builder_get_object (page->xml,"hbox_share_name"));
 
704
  page->checkbutton_share_rw_ro = GTK_WIDGET (gtk_builder_get_object (page->xml,"checkbutton_share_rw_ro"));
 
705
  page->checkbutton_share_guest_ok = GTK_WIDGET (gtk_builder_get_object (page->xml,"checkbutton_share_guest_ok"));
 
706
  page->entry_share_name = GTK_WIDGET (gtk_builder_get_object (page->xml,"entry_share_name"));
 
707
  page->entry_share_comment = GTK_WIDGET (gtk_builder_get_object (page->xml,"entry_share_comment"));
 
708
  page->label_status = GTK_WIDGET (gtk_builder_get_object (page->xml,"label_status"));
 
709
  page->button_cancel = GTK_WIDGET (gtk_builder_get_object (page->xml,"button_cancel"));
 
710
  page->button_apply = GTK_WIDGET (gtk_builder_get_object (page->xml,"button_apply"));
694
711
 
695
712
  /* Sanity check so that we don't screw up the Glade file */
696
713
  g_assert (page->checkbutton_share_folder != NULL
867
884
{
868
885
  char          *uri;
869
886
  char          *local_path = NULL;
 
887
  GFile         *f;
870
888
 
871
889
  *share_info = NULL;
872
890
  *is_shareable = FALSE;
873
891
 
874
892
  uri = nautilus_file_info_get_uri (file);
 
893
  f = nautilus_file_info_get_location(file);
875
894
  if (!uri)
876
895
    goto out;
877
896
 
900
919
  if (!nautilus_file_info_is_directory(file))
901
920
    goto out;
902
921
 
903
 
  if(!(local_path = gnome_vfs_get_local_path_from_uri(uri)))
 
922
  local_path = g_file_get_path(f);
 
923
  if (!local_path || !g_file_is_native(f))
904
924
    goto out;
905
925
 
906
926
  /* FIXME: NULL GError */
911
931
 
912
932
 out:
913
933
 
 
934
  g_object_unref(f);
914
935
  g_free (uri);
915
936
  g_free (local_path);
916
937
}
1086
1107
  g_assert (fileinfo != NULL);
1087
1108
 
1088
1109
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
1110
  gtk_window_set_title (GTK_WINDOW (window), _("Folder Sharing"));
1089
1111
  page = create_property_page (fileinfo);
1090
1112
  page->standalone_window = window;
1091
1113
  g_signal_connect (page->button_cancel, "clicked",
1128
1150
  item = nautilus_menu_item_new ("NautilusShare::share",
1129
1151
                                 _("Sharing Options"),
1130
1152
                                 _("Share this Folder"),
1131
 
                                 "stock_shared-by-me");
 
1153
                                 "folder-remote");
1132
1154
  g_signal_connect (item, "activate",
1133
1155
                    G_CALLBACK (share_this_folder_callback),
1134
1156
                    fileinfo);
1232
1254
void
1233
1255
nautilus_module_initialize (GTypeModule  *module)
1234
1256
{
1235
 
  g_print ("Initializing nautilus-share extension\n");
 
1257
  /*g_print ("Initializing nautilus-share extension\n");*/
1236
1258
 
1237
1259
  bindtextdomain("nautilus-share", NAUTILUS_SHARE_LOCALEDIR);
1238
1260
  bind_textdomain_codeset("nautilus-share", "UTF-8");
1244
1266
void
1245
1267
nautilus_module_shutdown   (void)
1246
1268
{
1247
 
  g_print ("Shutting down nautilus-share extension\n");
 
1269
  /*g_print ("Shutting down nautilus-share extension\n");*/
1248
1270
  /* FIXME freeing */
1249
1271
}
1250
1272