[gyrus/gyrus-python] Fixes bug #524254 (Francisco Rojas)
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: svn-commits-list gnome org
- Subject: [gyrus/gyrus-python] Fixes bug #524254 (Francisco Rojas)
- Date: Fri, 12 Jun 2009 12:13:12 -0400 (EDT)
commit dd59da59caf90a52dc2640585a278f7e60c19d9f
Author: Alejandro Valdes jimenez <avaldes amvj in utalca cl>
Date: Fri Jun 12 12:10:16 2009 -0400
Fixes bug #524254 (Francisco Rojas)
ChangeLog | 10 ++
data/glade/page.glade | 15 +--
src/GyrusAclStore.py | 62 ++++++++
src/GyrusAclTreeView.py | 316 ++++++++++++++++++++++++++++++++++++++++
src/GyrusDialogFindMailbox.py | 156 ++++++++++++++++++++
src/GyrusMailboxesStore.py | 78 ++++++++++
src/GyrusMailboxesTreeView.py | 284 ++++++++++++++++++++++++++++++++++++
src/Makefile.am | 10 ++-
src/gyrus.py | 321 +++++++++++++----------------------------
src/gyrus_constant.py | 30 ----
src/gyrus_util.py | 8 +
11 files changed, 1024 insertions(+), 266 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3f3a1e4..b69d015 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-06-12 Alejandro Valdes jimenez <avaldes gnome org>
+
+ * src/GyrusAclStore.py:
+ * src/GyrusAclTreeView.py:
+ * src/GyrusDialogFindMailbox.py:
+ * src/GyrusMailboxesStore.py:
+ * src/GyrusMailboxesTreeView.py:
+ * src/gyrus_util.py:
+ Fixes bug #524254 (Francisco Rojas).
+
2008-04-14 Claudio Saavedra <csaavedra gnome org>
* src/gyrus_admin_mailbox.py: (get_list_of_mailbox)
diff --git a/autogen.sh b/autogen.sh
old mode 100644
new mode 100755
diff --git a/data/glade/page.glade b/data/glade/page.glade
index f690c27..cb2547b 100644
--- a/data/glade/page.glade
+++ b/data/glade/page.glade
@@ -204,13 +204,7 @@
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
- <widget class="GtkTreeView" id="treeview_users">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="border_width">5</property>
- <property name="reorderable">True</property>
- <property name="enable_search">False</property>
- </widget>
+ <placeholder/>
</child>
</widget>
<packing>
@@ -456,12 +450,7 @@
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
- <widget class="GtkTreeView" id="treeview_acl">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="reorderable">True</property>
- <property name="rules_hint">True</property>
- </widget>
+ <placeholder/>
</child>
</widget>
</child>
diff --git a/src/GyrusAclStore.py b/src/GyrusAclStore.py
new file mode 100644
index 0000000..6cfd89b
--- /dev/null
+++ b/src/GyrusAclStore.py
@@ -0,0 +1,62 @@
+import gobject, gtk
+
+# Column indexes
+
+# for model of ACLs
+(
+ COLUMN_IDENTIFIER, #identefier of ACl
+ COLUMN_L, #lookup
+ COLUMN_R, #read
+ COLUMN_S, #seen
+ COLUMN_W, #write
+ COLUMN_I, #insert
+ COLUMN_P, #post
+ COLUMN_C, #create
+ COLUMN_D, #delete
+ COLUMN_A #admin
+) = range (10)
+
+class GyrusAclStore (gtk.ListStore):
+ def __init__(self):
+ gtk.ListStore.__init__(self, gobject.TYPE_STRING,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN,
+ gobject.TYPE_BOOLEAN)
+
+ #return a especific acl
+ def get_acl(self,iter):
+ ident, l, r, s, w, i, p, c, d, a = self.get(iter,
+ COLUMN_IDENTIFIER,
+ COLUMN_L,
+ COLUMN_R,
+ COLUMN_S,
+ COLUMN_W,
+ COLUMN_I,
+ COLUMN_P,
+ COLUMN_C,
+ COLUMN_D,
+ COLUMN_A)
+ return ident,l,r,s,w,i,p,c,d,a
+
+ def add_acl(self, id_acl, l, r, s, w, i, p, c, d, a):
+ # add new iter to model acl
+ iter = self.append()
+ self.set(iter,COLUMN_IDENTIFIER, id_acl,
+ COLUMN_L, l,
+ COLUMN_R, r,
+ COLUMN_S, s,
+ COLUMN_W, w,
+ COLUMN_I, i,
+ COLUMN_P, p,
+ COLUMN_C, c,
+ COLUMN_D, d,
+ COLUMN_A, a)
+ return iter
+
+
diff --git a/src/GyrusAclTreeView.py b/src/GyrusAclTreeView.py
new file mode 100644
index 0000000..aa7b48c
--- /dev/null
+++ b/src/GyrusAclTreeView.py
@@ -0,0 +1,316 @@
+#!/usr/bin/env python
+#
+# GyrusAclStore.py a local copy of the Acl
+#
+# GYRUS -- GNOME Cyrus Administrator.
+#
+# Copyright 2009 Francisco Rojas <frojas alumnos utalca cl>
+#
+# 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 Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gobject
+import gettext
+import GyrusAclStore
+
+from gyrus_constant import *
+
+gettext.bindtextdomain(APPNAME,DIRLOCALE)
+gettext.textdomain(APPNAME)
+_ = gettext.gettext
+
+gtk.glade.bindtextdomain(APPNAME,DIRLOCALE)
+gtk.glade.textdomain(APPNAME)
+
+NAME_PRIVILEGE = [None,
+ _("lookup"),
+ _("read"),
+ _("seen"),
+ _("write"),
+ _("insert"),
+ _("post"),
+ _("create"),
+ _("delete"),
+ _("admin")]
+
+
+class GyrusAclTreeView(gtk.TreeView):
+
+
+ __gproperties__ = {
+ 'connection' : (gobject.TYPE_PYOBJECT, 'connection',
+ 'object imaplib',
+ gobject.PARAM_READWRITE),
+ 'mailbox' : (gobject.TYPE_STRING, 'mailbox',
+ 'mailbox owns of the acl',
+ '', gobject.PARAM_READWRITE),
+ 'acl_selected' : (gobject.TYPE_STRING, 'acl selected',
+ 'acl selected in the treeview',
+ '', gobject.PARAM_READWRITE),
+ }
+
+
+ __gsignals__ = {
+ 'acl-selected' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
+ (gobject.TYPE_BOOLEAN,))
+ }
+
+
+ def __init__(self, connection = None):
+ gobject.GObject.__init__(self)
+ #gtk.TreeView.__init__(self)
+
+ model = GyrusAclStore.GyrusAclStore()
+ self.set_model (model)
+
+ self.connection = connection
+ self.set_enable_search(False)
+
+ cell = gtk.CellRendererText()
+ cell.set_property('editable',True)
+ cell.connect('edited', self._on_identifier_edited)
+
+ column = gtk.TreeViewColumn(_("identifier"),cell,text=0)
+ column.set_resizable(True)
+ self.append_column(column)
+
+ for ncol in range(1,10):
+ cell = gtk.CellRendererToggle()
+ cell.set_property('activatable',True)
+ cell.connect('toggled',self._on_toggled_acl,ncol)
+
+ column = gtk.TreeViewColumn(NAME_PRIVILEGE[ncol],cell)
+ column.set_resizable(True)
+ column.add_attribute(cell,"active",ncol)
+ self.append_column(column)
+
+ selection = self.get_selection()
+ selection.connect("changed",self._on_acl_selection_changed)
+
+ def do_get_property(self, property):
+ if property == 'connection':
+ return self.connection
+ elif property == 'mailbox':
+ return self.mailbox
+ elif property == 'acl-selected':
+ return self.acl_selected
+ else:
+ raise AttributeError, 'unknown property %s' % property.name
+
+ def do_set_property(self, property, value):
+ if property == 'connection':
+ self.connection = value
+ elif property == 'mailbox':
+ self.mailbox = value
+ elif property == 'acl-selected':
+ self.acl_selected = value
+ else:
+ raise AttributeError, 'unknown property %s' % property.name
+
+ def _on_toggled_acl(self, cell, path, ncol):
+ ''' Callback when a checkbox is toggled '''
+ model = self.get_model()
+ iter = model.get_iter_from_string(path)
+ id_acl, has_permission = model.get(iter,GyrusAclStore.COLUMN_IDENTIFIER,ncol)
+
+ model.set(iter, ncol, not has_permission)
+
+ self._set_acls(iter)
+
+ def _on_identifier_edited(self, cell, path, newname):
+ ''' Callback when an identifier is edited '''
+ newname = newname.strip()
+ model = self.get_model()
+
+ iter = model.get_iter_from_string(path)
+ oldname, l, r, s, w, i, p, c, d, a = model.get_acl(iter)
+
+ # check, newname exists in acl list
+ if oldname == newname:
+ return
+
+ self.is_in_list = False
+ model.foreach(self._is_newname_in_list, newname)
+ if not self.is_in_list:
+ model.set(iter, GyrusAclStore.COLUMN_IDENTIFIER, newname)
+ self._set_acls(iter)
+ self.delete_acl(oldname)
+ else:
+ #show error message and delete the row.
+ dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,gtk.BUTTONS_OK,_("Identifier exist: " + newname) )
+ dialog.run()
+ dialog.destroy()
+ self.rename_acl()
+
+ #when mailbox selection change, save the name of the mailbox
+ #and update the list of his acl
+ def on_users_selection_changed(self, obj, mailbox, data=None):
+ ''' Callback from GyrusMailboxesTreeView, when the user selection changed '''
+ self.mailbox = mailbox
+ self.update_of_mailbox()
+
+ def _on_acl_selection_changed(self, selection):
+ ''' Emit a new signal when the acl selection
+ is changed.
+ '''
+ model,iter = selection.get_selected()
+
+ if (iter):
+ self.emit('acl-selected', True)
+ else:
+ self.emit('acl-selected', False)
+
+ #update
+ def update_of_mailbox(self):
+
+ if (self.mailbox==None):
+ self.model().clear()
+ return
+
+ # get ACLs
+ t = self.connection.getacl(NAMESPACE + self.mailbox)
+ tm = t[1]
+ tmp = tm[0].split(" ")
+
+ lin = 1
+ j = lin
+ l = len(tmp)/2
+
+ model_acl = self.get_model()
+ model_acl.clear()
+
+ while lin <= l:
+ id_acl = tmp[j]
+ acls = tmp[j+1]
+
+ model_acl.add_acl(id_acl,
+ self._have_acl(acls,"l"),
+ self._have_acl(acls,"r"),
+ self._have_acl(acls,"s"),
+ self._have_acl(acls,"w"),
+ self._have_acl(acls,"i"),
+ self._have_acl(acls,"p"),
+ self._have_acl(acls,"c"),
+ self._have_acl(acls,"d"),
+ self._have_acl(acls,"a"),)
+
+ j = j + 2
+ lin = lin + 1
+
+ #check if the string contains a specific permisson
+ def _have_acl(self,string,acl):
+ ''' Check if the string contains a specific permisson. '''
+ r = string.find(acl)
+ if (r>=0):
+ return True
+ else:
+ return False
+
+ #set a set with new permisson
+ def _set_acls(self, iter):
+ ''' Set a set with new permisson. '''
+ model = self.get_model()
+ ident,l,r,s,w,i,p,c,d,a = model.get_acl(iter)
+
+ 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 = self.connection.setacl(NAMESPACE + self.mailbox, ident, perm)
+
+ #add a new acl
+ def add_acl(self):
+ ''' Add a new acl. '''
+ newname = self._new_name()
+ model_acl = self.get_model()
+ iter = model_acl.add_acl(newname,
+ True,
+ True,
+ True,
+ True,
+ True,
+ True,
+ True,
+ True,
+ True)
+
+ self._set_acls(iter)
+ # select the iter
+ selection = self.get_selection()
+ selection.select_iter(iter)
+
+ path = model_acl.get_path(iter)
+ col = self.get_column(GyrusAclStore.COLUMN_IDENTIFIER)
+ self.set_cursor(path, col, True)
+
+
+ def delete_acl(self, id_acl):
+ ''' Deleted the acl '''
+ permison = ''
+ type,data = self.connection.setacl(NAMESPACE + self.mailbox, id_acl, permison)
+ self.update_of_mailbox()
+
+ def rename_acl(self):
+ ''' Rename the acl. '''
+ selection = self.get_selection()
+ model,iter = selection.get_selected()
+
+ path = model.get_path(iter)
+ col = self.get_column(GyrusAclStore.COLUMN_IDENTIFIER)
+ self.set_cursor(path,col,True)
+
+ #check if the acls name isn't already in the list
+ def _is_newname_in_list(self, model, path, iter, newname):
+ ''' Check if the acl name istn't already in the list '''
+ oldname = model.get(iter,0)[0]
+ self.is_in_list = False;
+ if oldname == newname:
+ self.is_in_list = True;
+ return True
+ return False;
+
+ def _new_name(self):
+ ''' Choose a new name for the acl '''
+ original_name = _("identifier")
+ newname = original_name
+ model = self.get_model()
+ i = -1
+ self.is_in_list = False
+ model.foreach(self._is_newname_in_list, newname)
+ while(self.is_in_list):
+ i = i + 1
+ newname = original_name + str(i)
+ model.foreach(self._is_newname_in_list, newname)
+
+ return newname
diff --git a/src/GyrusDialogFindMailbox.py b/src/GyrusDialogFindMailbox.py
new file mode 100644
index 0000000..ff9fba2
--- /dev/null
+++ b/src/GyrusDialogFindMailbox.py
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+#
+# GyrusDialogFindMailbox.py Find mailbox dialog and engine.
+#
+# GYRUS -- GNOME Cyrus Administrator.
+#
+# Copyright 2009 Francisco Rojas <frojas alumnos utalca cl>
+#
+# Based on preview code (src/gyrus_find.py) by:
+# * - Alejandro Valdes <avaldes utalca cl>
+#
+# 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 Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gobject
+import gtk.glade
+import os
+import gnome
+import gyrus_util
+
+from gettext import gettext as _
+
+import config
+from gyrus_constant import *
+
+class GyrusDialogFindMailbox(gtk.Dialog):
+
+ def __init__(self, admin):
+ gtk.Dialog.__init__(self)
+ self.admin = admin
+
+ self.set_title(_("Find mailbox"))
+ self.set_resizable(False)
+ self.set_modal (True);
+
+ self._get_widgets()
+ self._connect_signals()
+
+ self.show_all()
+
+ def _get_widgets(self):
+ glade_file = gtk.glade.XML(os.path.join(config.GLADEDIR,
+ "find.glade"),
+ 'vbox_find',
+ 'gyrus')
+
+ vbox_find = glade_file.get_widget("vbox_find");
+
+ self.get_content_area().add(vbox_find)
+
+ self.comboboxentry_mailbox = glade_file.get_widget("comboboxentry_mailbox")
+ self.checkbutton_entire_word = glade_file.get_widget("checkbutton_entire_word")
+ self.checkbutton_wrap_around = glade_file.get_widget("checkbutton_wrap_around")
+
+ self.button_close = gtk.Button(stock=gtk.STOCK_CLOSE)
+ self.button_find = gtk.Button(stock=gtk.STOCK_FIND)
+
+ self.get_action_area().pack_start(self.button_close)
+ self.get_action_area().pack_start(self.button_find)
+
+
+ def _connect_signals(self):
+ self.button_close.connect("clicked", self._on_button_find_close_clicked,self)
+ self.button_find.connect ("clicked", self._on_button_find_find_clicked,self)
+
+
+ def _on_button_find_close_clicked (self, button, data):
+ self.destroy()
+
+ def _on_button_find_find_clicked (self, button, data):
+ key = self.comboboxentry_mailbox.get_active_text().strip()
+
+ more_mailboxes = None
+ wrap_around = None
+ search_from_beginning = None
+
+ if self.checkbutton_entire_word.get_active():
+ mode = "MODE_ENTIRE_WORD"
+ else:
+ mode = "MODE_ANY"
+
+ wrap_around = self.checkbutton_wrap_around.get_active()
+
+ selection = self.admin.treeview_users.get_selection()
+ model,iter = selection.get_selected()
+
+ # If no item is selected, start the search from the begin
+ if not iter:
+ iter = model.get_iter_first()
+ search_from_beginning = True
+ else:
+ iter = model.iter_next(iter)
+
+ # end of items
+ if not iter:
+ iter = model.get_iter_first()
+
+ search_from_beginning = False
+
+ while True:
+ value = model.get_name_mailbox(iter)
+
+ if mode == "MODE_ANY":
+ res = value.find(key)
+ if res >= 0:
+ found = True
+ else:
+ found = False
+ else:
+ if value == key:
+ found = True
+ else:
+ found = False
+
+ if found:
+ selection = self.admin.treeview_users.get_selection()
+ selection.select_iter(iter)
+ path = model.get_path(iter)
+ self.admin.treeview_users.set_cursor(path,None,False)
+
+
+ # if 'wrap around' mode is selected allows starting over again
+ iter = model.iter_next(iter)
+ if iter:
+ more_mailboxes = True
+ else:
+ more_mailboxes = False
+
+ if not more_mailboxes and wrap_around and not search_from_beginning:
+ iter = model.get_iter_first()
+ more_mailboxes = True
+ search_from_beginning = True
+
+ if not found and more_mailboxes:
+ pass
+ else:
+ break
+
+ if not found:
+ gyrus_util.show_message (_("The text was not found in the mailbox list."),gtk.MESSAGE_INFO)
+
diff --git a/src/GyrusMailboxesStore.py b/src/GyrusMailboxesStore.py
new file mode 100644
index 0000000..f0e68c0
--- /dev/null
+++ b/src/GyrusMailboxesStore.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# GyrusMailboxesStore.py a local copy of the Mailbox
+#
+# GYRUS -- GNOME Cyrus Administrator.
+#
+# Copyright 2009 Francisco Rojas <frojas alumnos utalca cl>
+#
+# 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 Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gobject
+import gettext
+import datetime
+
+from gyrus_constant import *
+import config
+
+
+# for model of mailbox
+(
+ COLUMN_MAILBOX_ICON,
+ COLUMN_MAILBOX,
+ COLUMN_QUOTA_ASSIGNED,
+ COLUMN_FREE
+) = range (4)
+
+
+class GyrusMailboxesStore(gtk.TreeStore):
+
+ def __init__ (self):
+ self.time_of_report = datetime.datetime.now()
+ gtk.TreeStore.__init__(self, gtk.gdk.Pixbuf,
+ gobject.TYPE_STRING,
+ gobject.TYPE_INT,
+ gobject.TYPE_INT)
+
+ def add_mailbox(self , name_mailbox, free, quota):
+
+ icon = os.path.join (config.ARTDIR, "gyrus.png")
+
+ iter = self.append(None)
+
+ self.set (iter, COLUMN_MAILBOX_ICON,
+ gtk.gdk.pixbuf_new_from_file_at_size (icon, 15, 15),
+ COLUMN_MAILBOX, name_mailbox,
+ COLUMN_QUOTA_ASSIGNED, quota,
+ COLUMN_FREE, free)
+
+ def get_name_mailbox(self, iter):
+ name = self.get(iter, COLUMN_MAILBOX)
+ return name[0]
+
+ def get_quota_of_mailbox(self, iter):
+ quota, free = self.get(iter, COLUMN_QUOTA_ASSIGNED, COLUMN_FREE)
+ return quota, free
+
+ def get_time(self):
+ return self.time_of_report
+
+ def set_time_now(self):
+ self.time_of_report = datetime.datetime.now()
+
diff --git a/src/GyrusMailboxesTreeView.py b/src/GyrusMailboxesTreeView.py
new file mode 100644
index 0000000..2f6301d
--- /dev/null
+++ b/src/GyrusMailboxesTreeView.py
@@ -0,0 +1,284 @@
+#!/usr/bin/env python
+#
+# GyrusMailboxesTreeview.py Administrator Mailboxes Modules.
+#
+# GYRUS -- GNOME Cyrus Administrator.
+#
+# Copyright 2009 Francisco Rojas <frojas alumnos utalca cl>
+#
+# Based on preview code (src/gyrus_find.py) by:
+# * - Alejandro Valdes <avaldes utalca cl>
+#
+# 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 Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+import gobject
+import gettext
+import sys
+
+import config
+from gyrus_constant import *
+from gettext import gettext as _
+
+import GyrusMailboxesStore
+
+
+class GyrusMailboxesTreeView (gtk.TreeView):
+
+ __gproperties__ = {
+ 'connection' : (gobject.TYPE_PYOBJECT, 'connection',
+ 'object imaplib',
+ gobject.PARAM_READWRITE),
+ 'mailbox_selected' : (gobject.TYPE_STRING, 'mailbox selected',
+ 'mailbox selected in the treeview',
+ '', gobject.PARAM_READWRITE),
+ }
+
+
+ __gsignals__ = {
+ 'mailbox-selection-change' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
+ (gobject.TYPE_STRING,))
+ }
+
+
+
+ def __init__ (self,connection=None):
+ gobject.GObject.__init__(self)
+ self.connection = connection
+ self.mailbox_selected = None
+
+ model = GyrusMailboxesStore.GyrusMailboxesStore()
+
+ col = gtk.TreeViewColumn(_("Mailboxs"))
+ col.set_resizable(True)
+ self.append_column(col)
+ cell = gtk.CellRendererPixbuf()
+ col.pack_start(cell,False)
+ col.add_attribute(cell, "pixbuf", GyrusMailboxesStore.COLUMN_MAILBOX_ICON)
+ cell = gtk.CellRendererText()
+ col.pack_start(cell, True)
+ col.add_attribute(cell, "text", GyrusMailboxesStore.COLUMN_MAILBOX)
+
+ self.set_rules_hint(True)
+ self.set_model(model)
+ self.set_reorderable(False)
+
+ selection = self.get_selection()
+ selection.connect("changed", self._on_users_selection_changed)
+
+ def do_get_property(self, property):
+ if property == 'connection':
+ return self.connection
+ elif property == 'mailbox-selected':
+ return self.mailbox_selected
+ else:
+ raise AttributeError, 'unknown property %s' % property.name
+
+ def do_set_property(self, property, value):
+ if property == 'connection':
+ self.connection = value
+ elif property == 'mailbox-selected':
+ self.mailbox_selected = value
+ else:
+ raise AttributeError, 'unknown property %s' % property.name
+
+ def _on_users_selection_changed(self, selection):
+ ''' Emit a new signal when a user selection changed. '''
+ model,iter = selection.get_selected()
+
+ if (iter):
+ mailbox = model.get(iter,GyrusMailboxesStore.COLUMN_MAILBOX)[0]
+ self.mailbox_selected = mailbox
+ self.emit('mailbox-selection-change', mailbox)
+
+ def remove_mailbox (self):
+ ''' Remove the selected mailbox'''
+ print NAMESPACE + self.mailbox_selected
+ response = self.connection.delete(NAMESPACE + self.mailbox_selected)
+ print response
+ if response[0] == 'OK':
+ return True,None
+ else:
+ return False,response[1][0]
+
+ def create_mailbox (self, mailbox):
+ ''' Create a new mailbox. '''
+ response = self.connection.create(NAMESPACE + mailbox)
+
+ if response[0] == 'OK':
+ return True,None
+ else:
+ return False,response[1][0]
+
+
+ def set_quota_of_mailbox (self, mailbox, quota):
+ ''' Set a mew quota of the mailbox '''
+ new = int(quota) * 1024
+ new = "(STORAGE " + str(new) + ")"
+
+ type,data = self.connection.setquota(NAMESPACE + mailbox,new)
+
+ if type == 'OK':
+ return True,None
+ else:
+ return False,type
+
+
+ def get_list_of_mailbox(self):
+ ''' Update the mailbox list of the TreeView '''
+ model = self.get_model()
+ #clean the model in the tree view
+ model.clear()
+ model.set_time_now()
+ # get all mailbox (only top-level)
+ type, data = self.connection.list(NAMESPACE,"%")
+
+ num_users = 0
+
+ #THIS IST WRONG, because if the query lunch a WARNING we omit it
+ if not data[0] == None:
+
+ token = None
+
+ for mailbox in data:
+ info_mailbox = mailbox.split("\"")
+ domain_name_mailbox = info_mailbox[3].split(".")
+ try:
+
+ name_mailbox = domain_name_mailbox[1]
+
+ #Checks name_mailbox will not repeat
+ if not (name_mailbox == token):
+ token = name_mailbox
+
+ #get other data we want save
+
+ res,msg,free,quota = self.get_quota_of_mailbox(name_mailbox)
+
+ model.add_mailbox(name_mailbox,free,quota)
+
+ num_users = num_users + 1
+ except:
+ print "Unexpected error:", sys.exc_info()[0]
+ pass
+
+ self.set_model(model)
+ col = self.get_column(0)
+
+ if (col != 0):
+ col.set_title(_('Mailboxs' + ' (' + str(num_users) + ')'))
+ else:
+ col.set_title(_('Mailboxs') + ' (0)')
+
+
+ def get_quota_of_mailbox(self, mailbox):
+ ''' Get the quota of the mailbox '''
+ response = self.connection.getquota(NAMESPACE + mailbox)
+
+ if response[0] == 'OK':
+ data_quota_mailbox = response[1]
+ tmp = data_quota_mailbox[0].split(" ")
+
+ used = tmp[2]
+
+ quota = tmp[3].split(")")[0]
+
+ free = (int(quota) - int(used)) / 1024
+ quota = int(quota) / 1024
+
+ return True,None,free,quota
+ else:
+ free = 0
+ quota = 0
+
+ return False,response[1][0],free,quota
+
+ def on_button_find_find_clicked(self, mailbox):
+
+ admin = self.get_current_gyrus_admin()
+ key = self.comboboxentry_mailbox.get_active_text().strip()
+
+ more_mailboxes = None
+ wrap_around = None
+ search_from_beginning = None
+
+ if self.checkbutton_entire_word.get_active():
+ mode = "MODE_ENTIRE_WORD"
+ else:
+ mode = "MODE_ANY"
+
+ wrap_around = self.checkbutton_wrap_around.get_active()
+
+ selection = admin.treeview_users.get_selection()
+ model,iter = selection.get_selected()
+
+ # If no item is selected, start the search from the begin
+ if not iter:
+ iter = model.get_iter_first()
+ search_from_beginning = True
+ else:
+ iter = model.iter_next(iter)
+
+ # end of items
+ if not iter:
+ iter = model.get_iter_first()
+
+ search_from_beginning = False
+
+ while True:
+ value = model.get(iter,1)
+
+ if mode == "MODE_ANY":
+ res = value[0].find(key)
+ if res >= 0:
+ found = True
+ else:
+ found = False
+ else:
+ if value[0] == key:
+ found = True
+ else:
+ found = False
+
+ if found:
+ selection = admin.treeview_users.get_selection()
+ selection.select_iter(iter)
+ path = model.get_path(iter)
+ admin.treeview_users.set_cursor(path,None,False)
+
+
+ # if 'wrap around' mode is selected allows starting over again
+ iter = model.iter_next(iter)
+ if iter:
+ more_mailboxes = True
+ else:
+ more_mailboxes = False
+
+ if not more_mailboxes and wrap_around and not search_from_beginning:
+ iter = model.get_iter_first()
+ more_mailboxes = True
+ search_from_beginning = True
+
+ if not found and more_mailboxes:
+ pass
+ else:
+ break
+
+ if not found:
+ self.show_message (_("The text was not found in the mailbox list."),gtk.MESSAGE_INFO)
+
diff --git a/src/Makefile.am b/src/Makefile.am
index d8d87f2..90ea80f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,15 @@ app_PYTHON = \
gyrus_find.py \
gyrus_print.py \
gyrus.py \
- gyrus_session.py
+ gyrus_session.py \
+ GyrusMailboxesTreeView.py \
+ GyrusMailboxesStore.py \
+ GyrusAclTreeView.py \
+ GyrusAclStore.py \
+ GyrusDialogFindMailbox.py \
+ GyrusReport.py \
+ gyrus_util.py
+
nodist_app_PYTHON = config.py
diff --git a/src/gyrus.py b/src/gyrus.py
index a20ac4b..29822ba 100644
--- a/src/gyrus.py
+++ b/src/gyrus.py
@@ -16,10 +16,15 @@ import config
from gyrus_constant import *
import gyrus_session
-import gyrus_acl
-import gyrus_admin_mailbox
-import gyrus_find
import gyrus_print
+import gyrus_util
+
+from GyrusMailboxesTreeView import GyrusMailboxesTreeView
+from GyrusAclTreeView import GyrusAclTreeView
+from GyrusDialogFindMailbox import GyrusDialogFindMailbox
+from GyrusReport import GyrusReport
+
+
# width and high of main window
DEFAULT_WIDTH = 750
@@ -285,59 +290,6 @@ class Gyrus:
button.show()
label.show()
- # create treeview/treemodel for users
- model = gtk.TreeStore(gtk.gdk.Pixbuf,
- gobject.TYPE_STRING)
-
- col = gtk.TreeViewColumn (_("Mailboxs"))
- col.set_resizable (True)
- admin.treeview_users.append_column (col)
- cell = gtk.CellRendererPixbuf()
- col.pack_start (cell,False)
- col.add_attribute (cell,"pixbuf",COLUMN_MAILBOX_ICON)
- cell = gtk.CellRendererText()
- col.pack_start (cell,True)
- col.add_attribute (cell,"text",COLUMN_MAILBOX)
-
- admin.treeview_users.set_rules_hint (True)
- admin.treeview_users.set_model (model)
- admin.treeview_users.set_reorderable(False)
-
- # create treeview/treemodel for acls
- model_acl = gtk.ListStore(gobject.TYPE_STRING,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_BOOLEAN)
-
-
- 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)
-
admin.label_host.set_label(session.host)
admin.label_port.set_label(str(session.port))
admin.label_user.set_label(session.user)
@@ -352,12 +304,13 @@ class Gyrus:
admin.button_connect.connect ("clicked", self.on_button_connect_clicked,admin)
admin.button_quota_apply.connect ("clicked", self.on_button_quota_apply_clicked,admin)
- selection = admin.treeview_users.get_selection()
- selection.connect("changed",self.on_users_selection_changed,admin)
-
- selection = admin.treeview_acl.get_selection()
- selection.connect("changed",self.on_acl_selection_changed,admin)
-
+ #connect mailbox selection change
+ admin.treeview_users.connect('mailbox-selection-change', self.on_users_selection_changed)
+ admin.treeview_users.connect('mailbox-selection-change', admin.treeview_acl.on_users_selection_changed)
+
+ #connect acl selection change
+ admin.treeview_acl.connect('acl-selected', self.on_acl_selected)
+
admin.treeview_users.show()
admin.treeview_acl.show()
admin.table_page.show()
@@ -387,18 +340,18 @@ class Gyrus:
def on_report_action (self,action):
admin = self.get_current_gyrus_admin()
- report = gyrus_print.GyrusReport(admin)
+ report = GyrusReport(admin)
def on_find_action (self,action):
- gyrus_find.load_page_find(self)
+ admin = self.get_current_gyrus_admin()
+ GyrusDialogFindMailbox(admin)
def on_refresh_action (self,action):
admin = self.get_current_gyrus_admin()
- lstore,num_usr = gyrus_admin_mailbox.get_list_of_mailbox(admin)
- self.refresh_treeview_user (lstore,num_usr)
-
+ admin.treeview_users.get_list_of_mailbox()
+
def on_entryacldelete_action (self,action):
admin = self.get_current_gyrus_admin()
@@ -411,48 +364,32 @@ class Gyrus:
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)
+ ident = model.get_acl(iter)
+ admin.treeview_acl.delete_acl(ident[0])
+ admin.treeview_acl.update_of_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):
+
+ def on_entryaclnew_action(self,action):
admin = self.get_current_gyrus_admin()
# add new iter to model acl
- model_acl = admin.treeview_acl.get_model()
- iter = model_acl.append(None)
- 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)
+ admin.treeview_acl.add_acl()
- path = model_acl.get_path(iter)
- col = admin.treeview_acl.get_column(COLUMN_IDENTIFIER)
- admin.treeview_acl.set_cursor(path,col,True)
+ def on_entryaclrename_action(self, action):
+ admin = self.get_current_gyrus_admin()
+ admin.treeview_acl.rename_acl()
+ def on_users_selection_changed(self, obj, mailbox, data=None):
+ admin = self.get_current_gyrus_admin()
+ res, msg, free, quota = obj.get_quota_of_mailbox(mailbox)
+ if res == True:
+ self.show_quota(admin, mailbox, quota, free)
+ else:
+ self.show_quota(admin, mailbox, 0, 0)
+ gyrus_util.show_message(msg, gtk.MESSAGE_ERROR)
+ self.actiongroup_mailbox.set_sensitive(True)
+ admin.entry_quota_new.set_properties(editable=True)
def on_removemailbox_action(self,action):
admin = self.get_current_gyrus_admin()
@@ -462,18 +399,14 @@ class Gyrus:
result = dialog.run()
if result == gtk.RESPONSE_YES:
- # get mailbox name
- mailbox = admin.entry_mailbox.get_text().strip()
-
- # remove mailbox
- res,msg = gyrus_admin_mailbox.remove_mailbox (admin,mailbox)
+ # remove mailbox
+ res,msg = admin.treeview_users.remove_mailbox()
if res == True:
# refresh list of mailbox
- lstore , num_usr = gyrus_admin_mailbox.get_list_of_mailbox(admin)
- self.refresh_treeview_user (lstore,num_usr)
+ admin.treeview_users.get_list_of_mailbox()
else:
- self.show_message (msg,gtk.MESSAGE_ERROR)
+ gyrus_util.show_message (msg,gtk.MESSAGE_ERROR)
dialog.destroy()
@@ -536,9 +469,15 @@ class Gyrus:
admin.button_connect = glade_file.get_widget ("button_connect")
admin.entry_quota_new = glade_file.get_widget ("entry_quota_new")
admin.button_quota_apply = glade_file.get_widget ("button_quota_apply")
- admin.treeview_users = glade_file.get_widget ("treeview_users")
- admin.treeview_acl = glade_file.get_widget ("treeview_acl")
-
+
+ admin.treeview_users = GyrusMailboxesTreeView()
+ scrolledwindow1 = glade_file.get_widget('scrolledwindow1')
+ scrolledwindow1.add(admin.treeview_users)
+
+ admin.treeview_acl = GyrusAclTreeView()
+ scrolled_acl = glade_file.get_widget('scrolled_acl')
+ scrolled_acl.add(admin.treeview_acl)
+
admin.entry_mailbox = glade_file.get_widget ("entry_mailbox")
admin.entry_assigned = glade_file.get_widget ("entry_assigned")
admin.entry_free = glade_file.get_widget ("entry_free")
@@ -574,9 +513,10 @@ class Gyrus:
auth = self.autenthicate_user (admin)
if (auth == True):
- lstore , num_usr = gyrus_admin_mailbox.get_list_of_mailbox(admin)
- self.refresh_treeview_user(lstore,num_usr)
-
+ admin.treeview_users.do_set_property('connection',cnx)
+ admin.treeview_acl.do_set_property('connection',cnx)
+ admin.treeview_users.get_list_of_mailbox()
+
self.actiongroup_window.set_sensitive (True)
self.actiongroup_server.set_sensitive (True)
@@ -584,12 +524,12 @@ class Gyrus:
admin.image_cnx.set_from_stock (gtk.STOCK_CONNECT,gtk.ICON_SIZE_BUTTON)
elif (auth == False):
- self.show_message (_("Could not logging"),gtk.MESSAGE_ERROR)
+ gyrus_util.show_message (_("Could not logging"),gtk.MESSAGE_ERROR)
admin.cnx = None
else:
admin.cnx = None
else:
- self.show_message (msgerr,gtk.MESSAGE_ERROR)
+ gyrus_util.show_message (msgerr,gtk.MESSAGE_ERROR)
else:
admin.label_cnx.set_text(_("Connect"))
admin.image_cnx.set_from_stock (gtk.STOCK_DISCONNECT,gtk.ICON_SIZE_BUTTON)
@@ -599,16 +539,7 @@ class Gyrus:
self.actiongroup_acl.set_sensitive (False)
self.clear_all_widget_of_admin(admin)
- def refresh_treeview_user(self,lstore,num_users):
- admin = self.get_current_gyrus_admin()
- admin.treeview_users.set_model(lstore)
- col = admin.treeview_users.get_column(0)
- if ( col != 0 ):
- col.set_title(_("Mailboxs" + " (" + str(num_users) + ")"))
- else:
- col.set_title(_("Mailboxs") + " (0)")
-
-
+
def clear_all_widget_of_admin (self,admin):
admin.cnx = None
admin.treeview_acl.get_model().clear()
@@ -623,38 +554,41 @@ class Gyrus:
else:
return False
+ def on_acl_selected(self, obj, selected, data=None):
+ if(selected):
+ self.actiongroup_acl.set_sensitive(True)
+ else:
+ self.actiongroup_acl.set_sensitive(False)
- def on_button_quota_apply_clicked (self,button,admin):
- mb = admin.entry_mailbox.get_text()
+ def on_button_quota_apply_clicked(self, button, admin):
+ mailbox = admin.treeview_users.do_get_property('mailbox-selected')
newquota = (admin.entry_quota_new.get_text()).strip()
if (newquota):
# filter only numbers
if (self.is_only_numbers(newquota)):
- setok,msgset = gyrus_admin_mailbox.set_quota_of_mailbox (admin,mb,newquota)
+ response, msgset = admin.treeview_users.set_quota_of_mailbox(mailbox, newquota)
- if (setok == True):
- admin.entry_quota_new.set_text("")
+ if (response == True):
+ admin.entry_quota_new.set_text('')
- res,msg,free,quota = gyrus_admin_mailbox.get_quota_of_mailbox (admin,mb)
+ res, msg, free, quota = admin.treeview_users.get_quota_of_mailbox(mailbox)
if res == True:
- self.show_quota (admin,mb,quota,free)
+ self.show_quota(admin, mailbox, quota, free)
else:
- self.show_quota (admin,mb,0,0)
- self.show_message (msg,gtk.MESSAGE_ERROR)
+ self.show_quota(admin,mb,0,0)
+ gyrus_util.show_message(msg,gtk.MESSAGE_ERROR)
- self.actiongroup_mailbox.set_sensitive (True)
+ self.actiongroup_mailbox.set_sensitive(True)
admin.entry_quota_new.set_properties(editable=True)
- gyrus_acl.get_acl_of_mailbox (admin,mb)
else:
- self.show_message (msgset,gtk.MESSAGE_ERROR)
+ gyrus_util.show_message(msgset, gtk.MESSAGE_ERROR)
else:
- self.show_message (_("This not a valid quota"),gtk.MESSAGE_ERROR)
+ gyrus_util.show_message(_("This not a valid quota"), gtk.MESSAGE_ERROR)
else:
- self.show_message (_("This not a valid quota"),gtk.MESSAGE_ERROR)
-
+ gyrus_util.show_message(_("This not a valid quota"), gtk.MESSAGE_ERROR)
def autenthicate_user (self,admin):
auth = False
@@ -685,110 +619,53 @@ class Gyrus:
return dialog_password,entry_password
-
- def show_message (self,msg,type):
- dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, type,gtk.BUTTONS_OK, msg)
- dialog.run()
- dialog.destroy()
-
-
- def on_acl_selection_changed(self,selection,admin):
- model,iter = selection.get_selected()
-
- if (iter):
- self.actiongroup_acl.set_sensitive (True)
- else:
- self.actiongroup_acl.set_sensitive (False)
-
+
def show_quota (self,admin,mb,quota,free):
admin.entry_mailbox.set_text(mb)
admin.entry_assigned.set_text(str(quota))
admin.entry_free.set_text(str(free))
- def on_users_selection_changed(self,selection,admin):
- model,iter = selection.get_selected()
-
- if (iter):
- mb = model.get(iter,COLUMN_MAILBOX)
- res,msg,free,quota = gyrus_admin_mailbox.get_quota_of_mailbox (admin,mb[0])
-
- if res == True:
- self.show_quota (admin,mb[0],quota,free)
- else:
- self.show_quota (admin,mb[0],0,0)
- self.show_message (msg,gtk.MESSAGE_ERROR)
-
- self.actiongroup_mailbox.set_sensitive (True)
- admin.entry_quota_new.set_properties(editable=True)
- gyrus_acl.get_acl_of_mailbox (admin,mb[0])
-
- else:
- self.actiongroup_mailbox.set_sensitive (False)
- admin.entry_assigned.set_text ("")
- admin.entry_free.set_text ("")
- admin.entry_mailbox.set_text ("")
- model_acl = admin.treeview_acl.get_model()
- model_acl.clear()
- admin.entry_quota_new.set_properties(editable=False)
- admin.entry_quota_new.set_text("")
-
-
- def on_addmailbox_action (self,action):
- page = self.notebook.get_current_page()
- table_page = self.notebook.get_nth_page(page)
-
- admin = self.imap_server[table_page]
+ def on_addmailbox_action(self, action):
+ admin = self.get_current_gyrus_admin()
self.load_dialog_edit_mailbox(admin)
+
- def load_dialog_edit_mailbox (self,admin):
- glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "create_mailbox.glade"),None,None)
-
- dialog = glade_file.get_widget ("dialog_create_mailbox")
- checkbutton_quota = glade_file.get_widget ("checkbutton_quota")
- entry_mailbox = glade_file.get_widget ("entry_mailbox")
- entry_quota = glade_file.get_widget ("entry_quota")
-
+ def load_dialog_edit_mailbox(self, admin):
+ glade_file = gtk.glade.XML(os.path.join(config.GLADEDIR, 'create_mailbox.glade'), None, None)
+
+ dialog = glade_file.get_widget ('dialog_create_mailbox')
+ checkbutton_quota = glade_file.get_widget('checkbutton_quota')
+ entry_mailbox = glade_file.get_widget('entry_mailbox')
+ entry_quota = glade_file.get_widget('entry_quota')
result = dialog.run()
if result == gtk.RESPONSE_OK:
- mb = entry_mailbox.get_text().strip()
+ mailbox = entry_mailbox.get_text().strip()
quota = entry_quota.get_text()
if (self.is_only_numbers(quota)):
# create mailbox
- result,msg = gyrus_admin_mailbox.create_mailbox(admin,mb)
+ result, msg = admin.treeview_users.create_mailbox(mailbox)
if result == True:
- model = admin.treeview_users.get_model()
-
- # add new mailbox
- iter = model.append(None)
- model.set (iter,COLUMN_MAILBOX,mb)
-
- # set quota to maiolbox
- setok,setmsg = gyrus_admin_mailbox.set_quota_of_mailbox(admin,mb,quota)
-
- if setok == False:
- self.show_message (setmsg,gtk.MESSAGE_ERROR)
-
+ # set quota to maillbox
+ response, msgset = admin.treeview_users.set_quota_of_mailbox(mailbox,
+ quota)
+ if response == False:
+ gyrus_util.show_message(setmsg, gtk.MESSAGE_ERROR)
+
# refresh list of mailbox
- lstore , num_usr =gyrus_admin_mailbox.get_list_of_mailbox(admin)
- self.refresh_treeview_user(lstore,num_usr)
+ admin.treeview_users.get_list_of_mailbox()
else:
- self.show_message (msg,gtk.MESSAGE_ERROR)
+ gyrus_util.show_message (msg,gtk.MESSAGE_ERROR)
else:
- self.show_message (_("This not a valid quota"),gtk.MESSAGE_ERROR)
+ gyrus_util.show_message (_("This not a valid quota"),gtk.MESSAGE_ERROR)
dialog.destroy()
- def tmp(widget,data,self):
- print widget, data, self
-
-
-
if __name__ == "__main__":
gnome.init(config.PACKAGE,config.VERSION)
diff --git a/src/gyrus_constant.py b/src/gyrus_constant.py
index 5086614..d7e0a68 100644
--- a/src/gyrus_constant.py
+++ b/src/gyrus_constant.py
@@ -20,33 +20,3 @@ WIDTH_LINE = 1
NAMESPACE = "user."
-# REMOVE ALL THIS CRAP FROM HERE, IT'S A HORRIBLE DESIGN!!!!!!
-
-# for model of mailbox
-(
- COLUMN_MAILBOX_ICON,
- COLUMN_MAILBOX,
- COLUMN_QUOTA_ASSIGNED,
- COLUMN_FREE
-) = range (4)
-
-# for model of ACLs
-COLUMN_IDENTIFIER = 0
-COLUMN_L = 1
-COLUMN_R = 2
-COLUMN_S = 3
-COLUMN_W = 4
-COLUMN_I = 5
-COLUMN_P = 6
-COLUMN_C = 7
-COLUMN_D = 8
-COLUMN_A = 9
-
-
-# for model of mailbox
-(
- COLUMN_MAILBOX_ICON,
- COLUMN_MAILBOX,
- COLUMN_QUOTA_ASSIGNED,
- COLUMN_FREE
-) = range (4)
diff --git a/src/gyrus_util.py b/src/gyrus_util.py
new file mode 100644
index 0000000..3af2090
--- /dev/null
+++ b/src/gyrus_util.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import gtk, os
+
+def show_message (msg,type):
+ dialog = gtk.MessageDialog(None,gtk.DIALOG_MODAL, type,gtk.BUTTONS_OK, msg)
+ dialog.run()
+ dialog.destroy()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]