import Buffy, time

# Read configuration
conf = Buffy.Config()

# Decide if a mailbox is to be displayed
# Please note that all configuration methods also come with 'set_*' conterparts
#def view(x):
#	if x.getMsgUnread() > 0:
#		return True
#
#	#if conf.get_view_important() and x.getMsgFlagged() > 0:
#		return True;
#
#	if conf.get_view_read() and x.getMsgTotal() > 0:
#		return True;
#
#	return conf.get_view_empty();


# Get the folder objects from the paths in the config file
folders = []
for path in conf.get_folder_locations():
	folders += Buffy.MailFolder_enumerateFolders(path);

while True:
	for f in folders:
		print "Scanning " + f.name()
		if f.changed():
			f.updateStatistics()
#		if view(f):
			#print "Scanning " + f.name()
		print "%s: %d %d %d %d" % (f.name(), f.getMsgTotal(), f.getMsgUnread(), f.getMsgNew(), f.getMsgFlagged())
	#print "UI " + conf.get_update_interval()
	#time.sleep(conf.get_update_interval())
	time.sleep(1)


