diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py
index 7c8f1fba..24f1dcd4 100755
--- a/pyfpdb/Configuration.py
+++ b/pyfpdb/Configuration.py
@@ -452,8 +452,8 @@ class Email:
self.fetchType = node.getAttribute("fetchType")
def __str__(self):
- return " host = %s\n username = %s\n password = %s\n useSsl = %s\n folder = %s\n" \
- % (self.host, self.username, self.password, self.useSsl, self.folder)
+ return " siteName=%s\n fetchType=%s\n host = %s\n username = %s\n password = %s\n useSsl = %s\n folder = %s\n" \
+ % (self.siteName, self.fetchType, self.host, self.username, self.password, self.useSsl, self.folder)
class HudUI:
def __init__(self, node):
@@ -626,6 +626,7 @@ class Config:
self.db_selected = None # database the user would like to use
self.tv = None
self.general = General()
+ self.emails = {}
self.gui_cash_stats = GUICashStats()
for gen_node in doc.getElementsByTagName("general"):
@@ -687,7 +688,8 @@ class Config:
for email_node in doc.getElementsByTagName("email"):
email = Email(node = email_node)
- self.email = email
+ if email.siteName!="": #FIXME: Why on earth is this needed?
+ self.emails[email.siteName+"_"+email.fetchType]=email
for hui_node in doc.getElementsByTagName('hud_ui'):
hui = HudUI(node = hui_node)
diff --git a/pyfpdb/GuiImapFetcher.py b/pyfpdb/GuiImapFetcher.py
new file mode 100644
index 00000000..d8e4d18e
--- /dev/null
+++ b/pyfpdb/GuiImapFetcher.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+#Copyright 2010 Steffen Schaumburg
+#This program is free software: you can redistribute it and/or modify
+#it under the terms of the GNU Affero General Public License as published by
+#the Free Software Foundation, version 3 of the License.
+#
+#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 Affero General Public License
+#along with this program. If not, see .
+#In the "official" distribution you can find the license in agpl-3.0.txt.
+
+import threading
+import pygtk
+pygtk.require('2.0')
+import gtk
+import ImapFetcher
+
+class GuiImapFetcher (threading.Thread):
+ def __init__(self, config, db, sql, mainwin, debug=True):
+ self.config = config
+ self.db = db
+ self.mainVBox = gtk.VBox()
+
+
+ self.buttonsHBox = gtk.HBox()
+ self.mainVBox.pack_end(self.buttonsHBox, expand=False)
+
+ label=gtk.Label("To cancel just close this tab")
+ self.buttonsHBox.add(label)
+
+ self.saveButton = gtk.Button("_Save Configuration")
+ self.saveButton.connect('clicked', self.saveClicked)
+ self.buttonsHBox.add(self.saveButton)
+
+ self.runAllButton = gtk.Button("_Run All")
+ self.runAllButton.connect('clicked', self.runAllClicked)
+ self.buttonsHBox.add(self.runAllButton)
+
+ self.statusLabel=gtk.Label("Please edit your config if you wish and then click Run All")
+ self.mainVBox.pack_end(self.statusLabel, expand=False, padding=4)
+
+ self.rowVBox = gtk.VBox()
+ self.mainVBox.add(self.rowVBox)
+
+ self.displayConfig()
+
+ self.mainVBox.show_all()
+ #end def __init__
+
+ def saveClicked(self, widget, data=None):
+ pass
+ #def saveClicked
+
+ def runAllClicked(self, widget, data=None):
+ self.statusLabel.set_label("Starting import. Please wait.") #FIXME: why doesnt this one show?
+ for email in self.config.emails:
+ result=ImapFetcher.run(self.config.emails[email], self.db)
+ self.statusLabel.set_label("Finished import without error.")
+ #def runAllClicked
+
+ def get_vbox(self):
+ """returns the vbox of this thread"""
+ return self.mainVBox
+ #end def get_vbox
+
+ def displayConfig(self):
+ print self.config.emails
+ for email in self.config.emails:
+ print self.config.emails[email]
+
+ #end def displayConfig
+#end class GuiImapFetcher
diff --git a/pyfpdb/ImapFetcher.py b/pyfpdb/ImapFetcher.py
index da13698c..97dbf3de 100755
--- a/pyfpdb/ImapFetcher.py
+++ b/pyfpdb/ImapFetcher.py
@@ -33,16 +33,16 @@ def run(config, db):
#print "start of IS.run"
server=None
#try:
- #print "useSSL",config.email.useSsl,"host",config.email.host
- if config.email.useSsl:
- server = IMAP4_SSL(config.email.host)
+ #print "useSSL",config.useSsl,"host",config.host
+ if config.useSsl:
+ server = IMAP4_SSL(config.host)
else:
- server = IMAP4(config.email.host)
- response = server.login(config.email.username, config.email.password) #TODO catch authentication error
+ server = IMAP4(config.host)
+ response = server.login(config.username, config.password) #TODO catch authentication error
print "response to logging in:",response
#print "server.list():",server.list() #prints list of folders
- response = server.select(config.email.folder)
+ response = server.select(config.folder)
#print "response to selecting INBOX:",response
if response[0]!="OK":
raise error #TODO: show error message
diff --git a/pyfpdb/fpdb.pyw b/pyfpdb/fpdb.pyw
index 75faebf2..8553ee72 100755
--- a/pyfpdb/fpdb.pyw
+++ b/pyfpdb/fpdb.pyw
@@ -103,7 +103,7 @@ import GuiPrefs
import GuiLogView
#import GuiDatabase
import GuiBulkImport
-import ImapFetcher
+import GuiImapFetcher
import GuiRingPlayerStats
import GuiTourneyPlayerStats
import GuiTourneyViewer
@@ -786,7 +786,7 @@ class fpdb: