Index: /pykoticon/trunk/bin/pykoticon
===================================================================
--- /pykoticon/trunk/bin/pykoticon (revision 65)
+++ /pykoticon/trunk/bin/pykoticon (revision 66)
@@ -98,5 +98,5 @@
 class User :
     """A class for PyKota users."""
-    def __init__(self, username, userinfo, userquotas) :
+    def __init__(self, username, userinfo, userquotas, printers) :
         """Initialize user datas."""
         self.UserName = username
@@ -110,13 +110,23 @@
         except (ValueError, TypeError) :
             self.LifeTimePaid = 0.0
-        self.Quotas = []
+        self.Printers = {}    
+        self.Quotas = {}
         for i in range(len(userquotas["printername"])) :
             printername = userquotas["printername"][i]
+            try :
+                pindex = printers["printername"].index(printername)
+            except (ValueError, KeyError) :
+                pass
+            else :    
+                self.Printers[printername] = Printer(printername, \
+                                              printers["priceperpage"][pindex],\
+                                              printers["priceperjob"][pindex])
             pagecounter = userquotas["pagecounter"][i]
             softlimit = userquotas["softlimit"][i]
             hardlimit = userquotas["hardlimit"][i]
             datelimit = userquotas["datelimit"][i]
-            self.Quotas.append(UserQuota(printername, pagecounter, softlimit, \
-                                         hardlimit, datelimit))
+            self.Quotas[printername] = UserQuota(printername, pagecounter, \
+                                                   softlimit, hardlimit, \
+                                                              datelimit)
             
 class CGINetworkInterface :
@@ -155,5 +165,5 @@
         return answer
         
-    def getPrinterNames(self) :
+    def getPrinters(self) :
         """Retrieve the printer's names."""
         arguments = { "report" : 1,
@@ -161,7 +171,8 @@
                       "datatype" : "printers",
                     }  
-        return self.retrieveDatas(arguments, ["printername"])["printername"]
-        
-    def getUserInfo(self, username) :
+        return self.retrieveDatas(arguments, ["printername", "priceperpage", \
+                                              "priceperjob"])
+        
+    def getUser(self, username) :
         """Retrieve the user's information."""
         arguments = { "datatype" : "users",
@@ -180,17 +191,19 @@
                                               "datelimit"))
                                               
-    def getUser(self, username) :
+    def getUserInfo(self, username) :
         """Retrieves the user account and quota information."""
-        info = self.getUserInfo(username)
+        info = self.getUser(username)
         if info :
             quotas = self.getUserPQuotas(username)
-            return User(username, info, quotas)
+            return User(username, info, \
+                                  self.getUserPQuotas(username), \
+                                  self.getPrinters())
     
 class PyKotIconGrid(gridlib.Grid) :    
     """A class for user print quota entries."""
-    def __init__(self, parent, quotas) :
+    def __init__(self, parent, user) :
         gridlib.Grid.__init__(self, parent, -1)
         sys.stderr.write("%s\n" % dir(self))
-        self.CreateGrid(len(quotas), 4)
+        self.CreateGrid(len(user.Quotas.keys()), 4)
         self.EnableEditing(False)
         self.SetColLabelValue(0, _("Page Counter"))
@@ -208,21 +221,23 @@
         attr.SetReadOnly(True)
         self.SetColAttr(3, attr)
-        for i in range(len(quotas)) :
-            q = quotas[i]
-            self.SetRowLabelValue(i, quotas[i].PrinterName)
-            self.SetCellValue(i, 0, str(q.PageCounter))
-            self.SetCellValue(i, 1, str(q.SoftLimit))
-            self.SetCellValue(i, 2, str(q.HardLimit))
-            self.SetCellValue(i, 3, str(q.DateLimit))
+        i = 0
+        for printername in user.Quotas.keys() :
+            quota = user.Quotas[printername]
+            self.SetRowLabelValue(i, printername)
+            self.SetCellValue(i, 0, str(quota.PageCounter))
+            self.SetCellValue(i, 1, str(quota.SoftLimit))
+            self.SetCellValue(i, 2, str(quota.HardLimit))
+            self.SetCellValue(i, 3, str(quota.DateLimit))
             attr = gridlib.GridCellAttr()
             colour = wx.GREEN
-            if q.SoftLimit is not None :
-                if q.PageCounter >= q.SoftLimit :
+            if quota.SoftLimit is not None :
+                if quota.PageCounter >= quota.SoftLimit :
                     colour = wx.RED
-            elif q.HardLimit is not None :        
-                if q.PageCounter >= q.HardLimit :
+            elif quota.HardLimit is not None :        
+                if quota.PageCounter >= quota.HardLimit :
                     colour = wx.RED
             attr.SetBackgroundColour(colour)        
             self.SetRowAttr(i, attr)
+            i += 1
         self.AutoSize()
             
@@ -233,5 +248,6 @@
                _("PyKota Print Quota for user %s") % getCurrentUserName(), \
                size = (460, -1), \
-               style = wxPython.wx.wxDEFAULT_FRAME_STYLE | wxPython.wx.wxNO_FULL_REPAINT_ON_RESIZE)
+               style = wxPython.wx.wxDEFAULT_FRAME_STYLE \
+                     | wxPython.wx.wxNO_FULL_REPAINT_ON_RESIZE)
         self.greenicon = wxPython.wx.wxIcon(os.path.join("..", "icons", "pykoticon-green.ico"), \
                                   wxPython.wx.wxBITMAP_TYPE_ICO)
@@ -275,5 +291,5 @@
         if self.inTimer is False : # avoids re-entrance
             self.inTimer = True
-            self.User = self.networkInterface.getUser(getCurrentUserName())
+            self.User = self.networkInterface.getUserInfo(getCurrentUserName())
             if self.User.LimitBy == "balance" :
                 if self.User.Balance <= 0.0 :
@@ -283,11 +299,12 @@
             else :        
                 isRed = False
-                for q in self.User.Quotas :
-                    if q.SoftLimit is not None :
-                        if q.PageCounter >= q.SoftLimit :
+                for q in self.User.Quotas.keys() :
+                    quota = self.User.Quotas[q]
+                    if quota.SoftLimit is not None :
+                        if quota.PageCounter >= quota.SoftLimit :
                             isRed = True
                             break
-                    elif q.HardLimit is not None :        
-                        if q.PageCounter >= q.HardLimit :
+                    elif quota.HardLimit is not None :        
+                        if quota.PageCounter >= quota.HardLimit :
                             isRed = True
                             break
@@ -300,5 +317,5 @@
                     self.quotasgrid.Destroy()
                     del self.quotasgrid
-                self.quotasgrid = PyKotIconGrid(self, self.User.Quotas)    
+                self.quotasgrid = PyKotIconGrid(self, self.User)    
             self.inTimer = False
         # Now we want it every 3 minutes    
@@ -320,4 +337,8 @@
             self.chrono.Stop()
             del self.chrono
+        if hasattr(self, "quotasgrid") :
+            self.quotasgrid.Close()
+            self.quotasgrid.Destroy()
+            del self.quotasgrid
         if hasattr(self, "menu") :
             self.menu.Destroy()
@@ -375,15 +396,24 @@
         username = getCurrentUserName()
     net = CGINetworkInterface(DUMPYKOTA_URL)
-    user = net.getUser(username)
+    user = net.getUserInfo(username)
     print "UserName : ", user.UserName
     print "LimitBy : ", user.LimitBy
     print "Balance : ", user.Balance
-    for q in user.Quotas :
-        print "\tPrinterName : ", q.PrinterName
-        print "\tPageCounter : ", q.PageCounter
-        print "\tSoftLimit : ", q.SoftLimit
-        print "\tHardLimit : ", q.HardLimit
-        print "\tDateLimit : ", q.DateLimit
+    for printername in user.Quotas.keys() :
+        quota = user.Quotas[printername]
+        print "\tPrinterName : ", printername
+        print "\tPageCounter : ", quota.PageCounter
+        print "\tSoftLimit : ", quota.SoftLimit
+        print "\tHardLimit : ", quota.HardLimit
+        print "\tDateLimit : ", quota.DateLimit
         print
+    for printername in user.Printers.keys() :
+        printer = user.Printers[printername]
+        print "\tPrinterName : ", printername
+        print "\tPrice per Page : ", printer.PricePerPage
+        print "\tPrice per Job : ", printer.PricePerJob
+        print
+        
+        
 
 if __name__ == '__main__':
