gyrus r317 - in branches/gyrus-python: . src src/glade



Author: avaldes
Date: Thu Jan 10 20:12:11 2008
New Revision: 317
URL: http://svn.gnome.org/viewvc/gyrus?rev=317&view=rev

Log:
2008-01-10      Alejandro Valdes Jimenez <avaldes utalca cl>
        * functionality of mailbox and ACLs has been completed, pending is the
        search and the report of mailboxes.
        * src/gyrus_constant.py: add  variables DEFAULT_WIDTH and DEFAULT_HIGH
        * src/gyrus.py:
                - add variables DEFAULT_WIDTH and DEFAULT_HIGH
                - create perm[] list for renderers of permissions
                - new function, on_entryacldelete_action()
                - new function, on_entryaclrename_action()
                - new function, on_refresh_action()
        * src/gyrus_acl.py:
                - new function, check_newname_in_list()
                - new function, delete_acl()
                - new function, set_acls()



Modified:
   branches/gyrus-python/ChangeLog
   branches/gyrus-python/TODO
   branches/gyrus-python/src/glade/create_mailbox.glade
   branches/gyrus-python/src/glade/page.glade
   branches/gyrus-python/src/glade/sessions.glade
   branches/gyrus-python/src/gyrus.py
   branches/gyrus-python/src/gyrus_acl.py
   branches/gyrus-python/src/gyrus_admin_mailbox.py
   branches/gyrus-python/src/gyrus_constant.py

Modified: branches/gyrus-python/TODO
==============================================================================
--- branches/gyrus-python/TODO	(original)
+++ branches/gyrus-python/TODO	Thu Jan 10 20:12:11 2008
@@ -1,4 +1,3 @@
 - generate the reports
-- ACLs
 - translate to other languages
 - search mailbox

Modified: branches/gyrus-python/src/glade/create_mailbox.glade
==============================================================================
--- branches/gyrus-python/src/glade/create_mailbox.glade	(original)
+++ branches/gyrus-python/src/glade/create_mailbox.glade	Thu Jan 10 20:12:11 2008
@@ -1,199 +1,133 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
 <glade-interface>
-
-<widget class="GtkDialog" id="dialog_create_mailbox">
-  <property name="border_width">2</property>
-  <property name="visible">True</property>
-  <property name="title" translatable="yes">Create mailbox</property>
-  <property name="type">GTK_WINDOW_TOPLEVEL</property>
-  <property name="window_position">GTK_WIN_POS_NONE</property>
-  <property name="modal">False</property>
-  <property name="resizable">False</property>
-  <property name="destroy_with_parent">False</property>
-  <property name="decorated">True</property>
-  <property name="skip_taskbar_hint">False</property>
-  <property name="skip_pager_hint">False</property>
-  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
-  <property name="has_separator">True</property>
-
-  <child internal-child="vbox">
-    <widget class="GtkVBox" id="vbox_dialog">
-      <property name="visible">True</property>
-      <property name="homogeneous">False</property>
-      <property name="spacing">0</property>
-
-      <child internal-child="action_area">
-	<widget class="GtkHButtonBox" id="dialog-action_area1">
-	  <property name="visible">True</property>
-	  <property name="layout_style">GTK_BUTTONBOX_END</property>
-
-	  <child>
-	    <widget class="GtkButton" id="button_cancel">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-cancel</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-6</property>
-	    </widget>
-	  </child>
-
-	  <child>
-	    <widget class="GtkButton" id="button_ok">
-	      <property name="visible">True</property>
-	      <property name="can_default">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label">gtk-ok</property>
-	      <property name="use_stock">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="response_id">-5</property>
-	    </widget>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">False</property>
-	  <property name="fill">True</property>
-	  <property name="pack_type">GTK_PACK_END</property>
-	</packing>
-      </child>
-
-      <child>
-	<widget class="GtkTable" id="table_dialog">
-	  <property name="border_width">10</property>
-	  <property name="visible">True</property>
-	  <property name="n_rows">3</property>
-	  <property name="n_columns">2</property>
-	  <property name="homogeneous">False</property>
-	  <property name="row_spacing">10</property>
-	  <property name="column_spacing">5</property>
-
-	  <child>
-	    <widget class="GtkLabel" id="label_mailbox_name">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">&lt;b&gt;Name:&lt;/b&gt;</property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">True</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkEntry" id="entry_mailbox">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">True</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</property>
-	      <property name="invisible_char" translatable="yes">*</property>
-	      <property name="activates_default">False</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">0</property>
-	      <property name="bottom_attach">1</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkEntry" id="entry_quota">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="editable">True</property>
-	      <property name="visibility">True</property>
-	      <property name="max_length">0</property>
-	      <property name="text" translatable="yes"></property>
-	      <property name="has_frame">True</property>
-	      <property name="invisible_char" translatable="yes">*</property>
-	      <property name="activates_default">False</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">1</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">2</property>
-	      <property name="bottom_attach">3</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkLabel" id="label_quota">
-	      <property name="visible">True</property>
-	      <property name="label" translatable="yes">&lt;b&gt;Quota (MB):&lt;/b&gt;</property>
-	      <property name="use_underline">False</property>
-	      <property name="use_markup">True</property>
-	      <property name="justify">GTK_JUSTIFY_LEFT</property>
-	      <property name="wrap">False</property>
-	      <property name="selectable">False</property>
-	      <property name="xalign">0</property>
-	      <property name="yalign">0.5</property>
-	      <property name="xpad">0</property>
-	      <property name="ypad">0</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">1</property>
-	      <property name="top_attach">2</property>
-	      <property name="bottom_attach">3</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-
-	  <child>
-	    <widget class="GtkCheckButton" id="checkbutton_quota">
-	      <property name="visible">True</property>
-	      <property name="can_focus">True</property>
-	      <property name="label" translatable="yes">Assign quota</property>
-	      <property name="use_underline">True</property>
-	      <property name="relief">GTK_RELIEF_NORMAL</property>
-	      <property name="focus_on_click">True</property>
-	      <property name="active">True</property>
-	      <property name="inconsistent">False</property>
-	      <property name="draw_indicator">True</property>
-	    </widget>
-	    <packing>
-	      <property name="left_attach">0</property>
-	      <property name="right_attach">2</property>
-	      <property name="top_attach">1</property>
-	      <property name="bottom_attach">2</property>
-	      <property name="x_options">fill</property>
-	      <property name="y_options"></property>
-	    </packing>
-	  </child>
-	</widget>
-	<packing>
-	  <property name="padding">0</property>
-	  <property name="expand">True</property>
-	  <property name="fill">True</property>
-	</packing>
-      </child>
-    </widget>
-  </child>
-</widget>
-
+  <widget class="GtkDialog" id="dialog_create_mailbox">
+    <property name="visible">True</property>
+    <property name="border_width">2</property>
+    <property name="title" translatable="yes">Create mailbox</property>
+    <property name="resizable">False</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="vbox_dialog">
+        <property name="visible">True</property>
+        <child>
+          <widget class="GtkTable" id="table_dialog">
+            <property name="visible">True</property>
+            <property name="border_width">10</property>
+            <property name="n_rows">3</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">5</property>
+            <property name="row_spacing">10</property>
+            <child>
+              <widget class="GtkCheckButton" id="checkbutton_quota">
+                <property name="can_focus">True</property>
+                <property name="label" translatable="yes">Assign quota</property>
+                <property name="use_underline">True</property>
+                <property name="response_id">0</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+              </widget>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_quota">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Quota (MB):&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkEntry" id="entry_quota">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="invisible_char">*</property>
+                <property name="text" translatable="yes">0</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkEntry" id="entry_mailbox">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="invisible_char">*</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkLabel" id="label_mailbox_name">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Name:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="x_options">GTK_FILL</property>
+                <property name="y_options"></property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button_cancel">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button_ok">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="label">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-5</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>

Modified: branches/gyrus-python/src/glade/page.glade
==============================================================================
--- branches/gyrus-python/src/glade/page.glade	(original)
+++ branches/gyrus-python/src/glade/page.glade	Thu Jan 10 20:12:11 2008
@@ -471,7 +471,7 @@
                                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                                     <child>
                                       <widget class="GtkButton" id="button_apply_acl">
-                                        <property name="visible">True</property>
+                                        <property name="sensitive">False</property>
                                         <property name="can_focus">True</property>
                                         <property name="receives_default">True</property>
                                         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>

Modified: branches/gyrus-python/src/glade/sessions.glade
==============================================================================
--- branches/gyrus-python/src/glade/sessions.glade	(original)
+++ branches/gyrus-python/src/glade/sessions.glade	Thu Jan 10 20:12:11 2008
@@ -90,7 +90,6 @@
             <property name="layout_style">GTK_BUTTONBOX_END</property>
             <child>
               <widget class="GtkButton" id="helpbutton2">
-                <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="label">gtk-help</property>
@@ -209,56 +208,58 @@
                         <property name="column_spacing">10</property>
                         <property name="row_spacing">5</property>
                         <child>
-                          <widget class="GtkLabel" id="label13">
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Password:</property>
-                            <property name="mnemonic_widget">entry_passwd</property>
-                          </widget>
-                          <packing>
-                            <property name="top_attach">3</property>
-                            <property name="bottom_attach">4</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
-                          </packing>
-                        </child>
-                        <child>
-                          <widget class="GtkLabel" id="label12">
+                          <widget class="GtkAlignment" id="alignment3">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Username:</property>
-                            <property name="mnemonic_widget">entry_user</property>
+                            <child>
+                              <widget class="GtkSpinButton" id="spinbutton_port">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="adjustment">143 1 65536 1 10 10</property>
+                                <property name="climb_rate">1</property>
+                              </widget>
+                            </child>
                           </widget>
                           <packing>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
                             <property name="x_options">GTK_FILL</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkLabel" id="label9">
+                          <widget class="GtkVBox" id="vbox6">
                             <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Port:</property>
-                            <property name="mnemonic_widget">spinbutton_port</property>
+                            <child>
+                              <widget class="GtkEntry" id="entry_host">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="invisible_char">*</property>
+                              </widget>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                              </packing>
+                            </child>
                           </widget>
                           <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options"></property>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkLabel" id="label8">
+                          <widget class="GtkEntry" id="entry_user">
                             <property name="visible">True</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Host:</property>
-                            <property name="use_markup">True</property>
-                            <property name="mnemonic_widget">entry_host</property>
+                            <property name="can_focus">True</property>
+                            <property name="invisible_char">*</property>
                           </widget>
                           <packing>
-                            <property name="x_options">GTK_FILL</property>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>
@@ -278,57 +279,55 @@
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkEntry" id="entry_user">
+                          <widget class="GtkLabel" id="label8">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="invisible_char">*</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Host:</property>
+                            <property name="use_markup">True</property>
+                            <property name="mnemonic_widget">entry_host</property>
                           </widget>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">2</property>
-                            <property name="bottom_attach">3</property>
+                            <property name="x_options">GTK_FILL</property>
                             <property name="y_options"></property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkVBox" id="vbox6">
+                          <widget class="GtkLabel" id="label9">
                             <property name="visible">True</property>
-                            <child>
-                              <widget class="GtkEntry" id="entry_host">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="invisible_char">*</property>
-                              </widget>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                              </packing>
-                            </child>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Port:</property>
+                            <property name="mnemonic_widget">spinbutton_port</property>
                           </widget>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
+                            <property name="top_attach">1</property>
+                            <property name="bottom_attach">2</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
                           </packing>
                         </child>
                         <child>
-                          <widget class="GtkAlignment" id="alignment3">
+                          <widget class="GtkLabel" id="label12">
                             <property name="visible">True</property>
                             <property name="xalign">0</property>
-                            <child>
-                              <widget class="GtkSpinButton" id="spinbutton_port">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="adjustment">143 1 65536 1 10 10</property>
-                                <property name="climb_rate">1</property>
-                              </widget>
-                            </child>
+                            <property name="label" translatable="yes">Username:</property>
+                            <property name="mnemonic_widget">entry_user</property>
                           </widget>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
+                            <property name="top_attach">2</property>
+                            <property name="bottom_attach">3</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options"></property>
+                          </packing>
+                        </child>
+                        <child>
+                          <widget class="GtkLabel" id="label13">
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">Password:</property>
+                            <property name="mnemonic_widget">entry_passwd</property>
+                          </widget>
+                          <packing>
+                            <property name="top_attach">3</property>
+                            <property name="bottom_attach">4</property>
                             <property name="x_options">GTK_FILL</property>
                             <property name="y_options"></property>
                           </packing>
@@ -442,7 +441,6 @@
             <property name="layout_style">GTK_BUTTONBOX_END</property>
             <child>
               <widget class="GtkButton" id="helpbutton3">
-                <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="label">gtk-help</property>

Modified: branches/gyrus-python/src/gyrus.py
==============================================================================
--- branches/gyrus-python/src/gyrus.py	(original)
+++ branches/gyrus-python/src/gyrus.py	Thu Jan 10 20:12:11 2008
@@ -22,6 +22,18 @@
 gtk.glade.bindtextdomain(APPNAME,DIRLOCALE)
 gtk.glade.textdomain(APPNAME)
 
+
+perm = [None,
+	_("lookup"),
+	_("read"),
+	_("seen"),
+	_("write"),
+	_("insert"),
+	_("post"),
+	_("create"),
+	_("delete"),
+	_("admin")]
+
 class GyrusAdmin:
 	def __init__ (self):
 		table_page = None
@@ -39,6 +51,8 @@
 		image_cnx = None
 		label_cnx = None
 		cnx = None
+		newname = None		# temporal for validate name of new entry on acl
+		newnameok = None 	# temporal for validate name of new entry on acl
 		session_name = None
 		session_host = None
 		session_port = None
@@ -63,7 +77,7 @@
 		# create main window
 		window = gtk.Window()
 		window.set_position(1)
-		window.set_default_size(700,500)
+		window.set_default_size(DEFAULT_WIDTH,DEFAULT_HIGH)
 		window.set_title (APPNAME)
 		window.set_icon (gtk.gdk.pixbuf_new_from_file(LOGO))
 		window.connect ("delete_event",self.quit_program)
@@ -105,20 +119,22 @@
 		self.actiongroup_server.add_actions([
 			 ('AddMailbox', gtk.STOCK_ADD, _('Add mailbox'),None, _('Add a mailbox under the one selected'), self.on_addmailbox_action),
 			 ('Find', gtk.STOCK_FIND, _('Find mailbox'),None, _('Search for a mailbox in current server'), self.tmp),
-			 ('Refresh', gtk.STOCK_REFRESH, None,'<control>R', _('Refresh the mailbox list'), self.tmp),
+			 ('Refresh', gtk.STOCK_REFRESH, None,'<control>R', _('Refresh the mailbox list'), self.on_refresh_action),
 			 ('Report', gtk.STOCK_INDEX, _('Create report'),None, _('Create report of users with quota problems'), self.tmp),
 			])
 
 		self.actiongroup_mailbox.add_actions([
 			 ('RemoveMailbox', gtk.STOCK_REMOVE, _('Remove mailbox'), None, 
 			 _('Remove current mailbox from the server'), self.on_removemailbox_action),
-			 ('EntryNew', gtk.STOCK_ADD, _('New entry'), '<control><shift>N', 
+			 ('EntryNew', gtk.STOCK_ADD, _('New ACL'), '<control><shift>N', 
 			 _('Create a new ACL entry in current mailbox'), self.on_entryaclnew_action),
 			])
 
 		self.actiongroup_acl.add_actions([
-			 ('EntryRename', gtk.STOCK_EDIT, _('Rename entry'), '<control><shift>R', _('Rename selected ACL entry'), self.tmp),
-			 ('EntryDelete', gtk.STOCK_REMOVE, _('Delete entry'), '<control><shift>D', _('Delete selected ACL entry'), self.tmp),
+			 ('EntryRename', gtk.STOCK_EDIT, _('Rename ACL'), '<control><shift>R', 
+			 _('Rename selected ACL entry'), self.on_entryaclrename_action),
+			 ('EntryDelete', gtk.STOCK_REMOVE, _('Delete ACL'), '<control><shift>D', 
+			 _('Delete selected ACL entry'), self.on_entryacldelete_action),
 			])
 
 
@@ -243,104 +259,25 @@
 					gobject.TYPE_BOOLEAN,
 					gobject.TYPE_BOOLEAN)
 
-		col0 = gtk.TreeViewColumn (_("identifier"))
-		col0.set_resizable (True)
-		admin.treeview_acl.append_column (col0)
-		cell0 = gtk.CellRendererText()
-		col0.pack_start(cell0,True)
-		col0.add_attribute (cell0,"text",COLUMN_IDENTIFIER)
-		col0.add_attribute (cell0,"editable",True)
-		admin.treeview_acl.set_data("column-identifier",col0)
-
-		col1 = gtk.TreeViewColumn (_("lookup"))
-		col1.set_data("permission",COLUMN_L)
-		col1.set_data("parent-admin",admin)
-		col1.set_resizable (True)
-		admin.treeview_acl.append_column (col1)
-		cell1 = gtk.CellRendererToggle()
-		col1.pack_start(cell1,True)
-		col1.add_attribute (cell1,"active",COLUMN_L)
-		cell1.connect ('toggled',gyrus_acl.on_toggled_acl,col1)
-
-		col2 = gtk.TreeViewColumn (_("read"))
-		col2.set_data("permission",COLUMN_R)
-		col2.set_data("parent-admin",admin)
-		col2.set_resizable (True)
-		admin.treeview_acl.append_column (col2)
-		cell2 = gtk.CellRendererToggle()
-		col2.pack_start(cell2,True)
-		col2.add_attribute (cell2,"active",COLUMN_R)
-		cell2.connect ('toggled',gyrus_acl.on_toggled_acl,col2)
-
-		col3 = gtk.TreeViewColumn (_("seen"))
-		col3.set_data("permission",COLUMN_S)
-		col3.set_data("parent-admin",admin)
-		col3.set_resizable (True)
-		admin.treeview_acl.append_column (col3)
-		cell3 = gtk.CellRendererToggle()
-		col3.pack_start(cell3,True)
-		col3.add_attribute (cell3,"active",COLUMN_S)
-		cell3.connect ('toggled',gyrus_acl.on_toggled_acl,col3)
-
-		col4 = gtk.TreeViewColumn (_("write"))
-		col4.set_data("permission",COLUMN_W)
-		col4.set_data("parent-admin",admin)
-		col4.set_resizable (True)
-		admin.treeview_acl.append_column (col4)
-		cell4 = gtk.CellRendererToggle()
-		col4.pack_start(cell4,True)
-		col4.add_attribute (cell4,"active",COLUMN_W)
-		cell4.connect ('toggled',gyrus_acl.on_toggled_acl,col4)
-
-		col5 = gtk.TreeViewColumn (_("insert"))
-		col5.set_data("permission",COLUMN_I)
-		col5.set_data("parent-admin",admin)
-		col5.set_resizable (True)
-		admin.treeview_acl.append_column (col5)
-		cell5 = gtk.CellRendererToggle()
-		col5.pack_start(cell5,True)
-		col5.add_attribute (cell5,"active",COLUMN_I)
-		cell5.connect ('toggled',gyrus_acl.on_toggled_acl,col5)
-
-		col6 = gtk.TreeViewColumn (_("post"))
-		col6.set_data("permission",COLUMN_P)
-		col6.set_data("parent-admin",admin)
-		col6.set_resizable (True)
-		admin.treeview_acl.append_column (col6)
-		cell6 = gtk.CellRendererToggle()
-		col6.pack_start(cell6,True)
-		col6.add_attribute (cell6,"active",COLUMN_P)
-		cell6.connect ('toggled',gyrus_acl.on_toggled_acl,col6)
-
-		col7 = gtk.TreeViewColumn (_("create"))
-		col7.set_data("permission",COLUMN_C)
-		col7.set_data("parent-admin",admin)
-		col7.set_resizable (True)
-		admin.treeview_acl.append_column (col7)
-		cell7 = gtk.CellRendererToggle()
-		col7.pack_start(cell7,True)
-		col7.add_attribute (cell7,"active",COLUMN_C)
-		cell7.connect ('toggled',gyrus_acl.on_toggled_acl,col7)
-
-		col8 = gtk.TreeViewColumn (_("delete"))
-		col8.set_data("permission",COLUMN_D)
-		col8.set_data("parent-admin",admin)
-		col8.set_resizable (True)
-		admin.treeview_acl.append_column (col8)
-		cell8 = gtk.CellRendererToggle()
-		col8.pack_start(cell8,True)
-		col8.add_attribute (cell8,"active",COLUMN_D)
-		cell8.connect ('toggled',gyrus_acl.on_toggled_acl,col8)
-
-		col9 = gtk.TreeViewColumn (_("admin"))
-		col9.set_data("permission",COLUMN_A)
-		col9.set_data("parent-admin",admin)
-		col9.set_resizable (True)
-		admin.treeview_acl.append_column (col9)
-		cell9 = gtk.CellRendererToggle()
-		col9.pack_start(cell9,True)
-		col9.add_attribute (cell9,"active",COLUMN_A)
-		cell9.connect ('toggled',gyrus_acl.on_toggled_acl,col9)
+
+		cell = gtk.CellRendererText()
+		cell.set_property('editable',True)
+		cell.connect ('edited',gyrus_acl.on_identifier_edited,admin,self)
+
+		col = gtk.TreeViewColumn (_("identifier"),cell,text=0)
+		col.set_resizable (True)
+		admin.treeview_acl.append_column (col)
+		
+		for ncol in range(1,10):
+
+			cell = gtk.CellRendererToggle()
+			cell.set_property('activatable',True)
+			cell.connect ('toggled',gyrus_acl.on_toggled_acl,admin,ncol)
+
+			colp = gtk.TreeViewColumn (perm[ncol],cell)
+			colp.set_resizable (True)
+			colp.add_attribute(cell,"active",ncol)
+			admin.treeview_acl.append_column (colp)
 
 		admin.treeview_acl.set_model (model_acl)
 		admin.treeview_acl.set_reorderable(False)
@@ -362,8 +299,8 @@
 		selection = admin.treeview_users.get_selection()
 		selection.connect("changed",self.on_users_selection_changed,admin)
 
-		selection2 = admin.treeview_acl.get_selection()
-		selection2.connect("changed",self.on_acl_selection_changed,admin)
+		selection = admin.treeview_acl.get_selection()
+		selection.connect("changed",self.on_acl_selection_changed,admin)
 
 		admin.treeview_users.show()
 		admin.treeview_acl.show()
@@ -390,7 +327,41 @@
 
 		admin = self.imap_server[table]
 		return admin
+
+	
+	def on_refresh_action (self,action):
+		admin = self.get_current_gyrus_admin()
+		gyrus_admin_mailbox.get_list_of_mailbox(admin)
+
 	
+	def on_entryacldelete_action (self,action):
+		admin = self.get_current_gyrus_admin()
+
+		selection = admin.treeview_acl.get_selection()
+		model,iter = selection.get_selected()
+
+		dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, 
+				gtk.BUTTONS_YES_NO, _("Really delete this ACL entry?"))
+
+		result = dialog.run()
+
+		if result == gtk.RESPONSE_YES:
+			mailbox = admin.entry_mailbox.get_text()
+			ident = model.get(iter,COLUMN_IDENTIFIER)
+			gyrus_acl.delete_acl(mailbox,ident[0],admin)
+			gyrus_acl.get_acl_of_mailbox (admin,mailbox)
+
+		dialog.destroy()
+
+	def on_entryaclrename_action (self,action):
+		admin = self.get_current_gyrus_admin()
+		selection = admin.treeview_acl.get_selection()
+		model,iter = selection.get_selected()
+		
+		path = model.get_path(iter)
+		col = admin.treeview_acl.get_column(COLUMN_IDENTIFIER)
+		admin.treeview_acl.set_cursor(path,col,True)
+
 
 	def on_entryaclnew_action (self,action):
 		admin = self.get_current_gyrus_admin()
@@ -398,22 +369,25 @@
 		# add new iter to model acl	
 		model_acl = admin.treeview_acl.get_model()
 		iter = model_acl.append(None)
-              	model_acl.set(iter,COLUMN_IDENTIFIER,_("new entry"),
-                               COLUMN_L,False,
-                               COLUMN_R,False,
-                               COLUMN_S,False,
-                               COLUMN_W,False,
-                               COLUMN_I,False,
-                               COLUMN_P,False,
-                               COLUMN_C,False,
-                               COLUMN_D,False,
-                               COLUMN_A,False)
+              	model_acl.set(iter,COLUMN_IDENTIFIER,_("identifier"),
+                               COLUMN_L,True,
+                               COLUMN_R,True,
+                               COLUMN_S,True,
+                               COLUMN_W,True,
+                               COLUMN_I,True,
+                               COLUMN_P,True,
+                               COLUMN_C,True,
+                               COLUMN_D,True,
+                               COLUMN_A,True)
 		
+		# select the iter
+		selection = admin.treeview_acl.get_selection()
+		selection.select_iter(iter)		
+
 		path = model_acl.get_path(iter)
-		column = admin.treeview_acl.get_data("column-identifier")
-		admin.treeview_acl.set_cursor(path,column,True)
+		col = admin.treeview_acl.get_column(COLUMN_IDENTIFIER)
+		admin.treeview_acl.set_cursor(path,col,True)
 
-		
 
 	def on_removemailbox_action(self,action):
 		admin = self.get_current_gyrus_admin()

Modified: branches/gyrus-python/src/gyrus_acl.py
==============================================================================
--- branches/gyrus-python/src/gyrus_acl.py	(original)
+++ branches/gyrus-python/src/gyrus_acl.py	Thu Jan 10 20:12:11 2008
@@ -56,12 +56,90 @@
 		return False
 
 		
-def on_toggled_acl(cell,path,column):
-	admin = column.get_data("parent-admin")
-	col = column.get_data("permission")
+def on_toggled_acl(cell,path,admin,ncol):
 	model = admin.treeview_acl.get_model()
 	iter = model.get_iter_from_string(path)
 
-	user,has_permission = model.get(iter,COLUMN_IDENTIFIER,col)
+	user,has_permission = model.get(iter,COLUMN_IDENTIFIER,ncol)
 
-	model.set(iter,col,not has_permission)
+	model.set(iter,ncol,not has_permission)
+
+	mailbox = admin.entry_mailbox.get_text()
+	model = admin.treeview_acl.get_model()
+	set_acls (mailbox,model,iter,admin)
+
+
+def on_identifier_edited(cell,path,newname,admin,self):
+	newname = newname.strip()
+
+	model = admin.treeview_acl.get_model()
+	iter = model.get_iter_from_string(path)
+
+	oldname = model.get(iter,COLUMN_IDENTIFIER)
+
+	if oldname[0] == newname:
+		# is the same iter
+		pass
+	else:
+		# check, newname exists in acl list
+		admin.newname = newname
+		admin.newnameok = True
+		model.foreach(check_newname_in_list,admin)
+
+		if admin.newnameok:
+			mailbox = admin.entry_mailbox.get_text()
+			model.set(iter,COLUMN_IDENTIFIER,newname)
+			set_acls (mailbox,model,iter,admin)
+			delete_acl (mailbox,oldname[0],admin)
+		else:
+			self.show_message (_("Identifier exist: " + newname),gtk.MESSAGE_ERROR)
+			model.remove(iter)
+
+
+def check_newname_in_list(model,path,iter,admin):
+	oldname = model.get(iter,COLUMN_IDENTIFIER)
+
+	if oldname[0] == admin.newname:
+		admin.newnameok = False
+		return True
+
+
+def delete_acl (mailbox,ident,admin):
+	perm = ""
+
+	type,data = admin.cnx.setacl(NAMESPACE + mailbox,ident,perm)
+
+
+def set_acls (mailbox,model,iter,admin):
+	ident,l,r,s,w,i,p,c,d,a = model.get(iter,
+			COLUMN_IDENTIFIER,
+			COLUMN_L,
+			COLUMN_R,
+			COLUMN_S,
+			COLUMN_W,
+			COLUMN_I,
+			COLUMN_P,
+			COLUMN_C,
+			COLUMN_D,
+			COLUMN_A)
+	perm = ""
+	if l:
+		perm = perm + "l"
+	if r:
+		perm = perm + "r"
+	if s:
+		perm = perm + "s"
+	if w:
+		perm = perm + "w"
+	if i:
+		perm = perm + "i"
+	if p:
+		perm = perm + "p"
+	if c:
+		perm = perm + "c"
+	if d:
+		perm = perm + "d"
+	if a:
+		perm = perm + "a"
+	
+	type,data = admin.cnx.setacl(NAMESPACE + mailbox,ident,perm)	

Modified: branches/gyrus-python/src/gyrus_admin_mailbox.py
==============================================================================
--- branches/gyrus-python/src/gyrus_admin_mailbox.py	(original)
+++ branches/gyrus-python/src/gyrus_admin_mailbox.py	Thu Jan 10 20:12:11 2008
@@ -49,28 +49,34 @@
 	model.clear()
 
 	# get all mailbox (only top-level)
-	type, data = admin.cnx.list("user.","%")
-
-	token = None
-	i = 0
-	for b in data:
-		c = b.split("\"")
-		d = c[3].split(".")
-		try:
-			mb = d[1]
-			if not (mb == token):
-				token = mb
-				iter = model.append(None)
-				model.set (iter,COLUMN_MAILBOX_ICON, 
-						gtk.gdk.pixbuf_new_from_file_at_size (DIRGYRUS + "images/gyrus.png",15,15),
-						COLUMN_MAILBOX,mb)
-				i = i + 1
-		except:
-			print "error"
-			pass
+	type, data = admin.cnx.list(NAMESPACE,"%")
 
 	col = admin.treeview_users.get_column(0)
-	col.set_title(_("Mailboxs" + " (" + str(i) + ")"))
+
+	if not data[0] == None:
+
+		token = None
+		i = 0
+		for b in data:
+			c = b.split("\"")
+			d = c[3].split(".")
+			try:
+				mb = d[1]
+				if not (mb == token):
+					token = mb
+					iter = model.append(None)
+					model.set (iter,COLUMN_MAILBOX_ICON, 
+							gtk.gdk.pixbuf_new_from_file_at_size (DIRGYRUS + "images/gyrus.png",15,15),
+							COLUMN_MAILBOX,mb)
+					i = i + 1
+			except:
+				print "error"
+				pass
+
+		col.set_title(_("Mailboxs" + " (" + str(i) + ")"))
+	else:
+		col.set_title(_("Mailboxs") + " (0)")
+		
 	
 
 def get_quota_of_mailbox (admin,mailbox):

Modified: branches/gyrus-python/src/gyrus_constant.py
==============================================================================
--- branches/gyrus-python/src/gyrus_constant.py	(original)
+++ branches/gyrus-python/src/gyrus_constant.py	Thu Jan 10 20:12:11 2008
@@ -14,6 +14,10 @@
 APPNAME ="gyrus"
 VERSION = "0.4"
 
+# width and high of main window
+DEFAULT_WIDTH = 750
+DEFAULT_HIGH = 550
+
 # for model of sessions
 COLUMN_NAME = 0  
 COLUMN_IP = 1
@@ -33,6 +37,7 @@
 COLUMN_D = 8
 COLUMN_A = 9
 
+	
 # for model of mailbox
 COLUMN_MAILBOX_ICON = 0
 COLUMN_MAILBOX = 1
@@ -81,7 +86,6 @@
       <toolitem action="Find" />
       <separator/>
       <toolitem action="Refresh"/>
-      <toolitem action="Report"/>
       <separator/>
       <toolitem action="Quit"/>
     </placeholder>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]