Index: mailhandler.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mailhandler/Attic/mailhandler.module,v
retrieving revision 1.96.2.33
diff -u -r1.96.2.33 mailhandler.module
--- mailhandler.module	27 Jan 2011 13:17:40 -0000	1.96.2.33
+++ mailhandler.module	27 Jan 2011 20:08:58 -0000
@@ -21,15 +21,20 @@
  */
 
 /**
- * Implementation of hook_cron(). Process msgs from all enabled mailboxes.
+ * Implementation of hook_cron().
+ *
+ * Retrieve and process mesages from all enabled mailboxes.
  */
 function mailhandler_cron() {
-  // Include mailhandler retrieval functions
+  // @todo: remove this include when the retriever gets decoupled.
   module_load_include('inc', 'mailhandler', 'mailhandler.retrieve');
-  // Retrieve messages
-  $result = db_query('SELECT * FROM {mailhandler} WHERE enabled = 1 ORDER BY mail');
-  while ($mailbox = db_fetch_array($result)) {
-    mailhandler_node_process_mailbox($mailbox, 'auto', variable_get('mailhandler_max_retrieval', 0), array());
+
+  // Get only enabled for cron mailboxes.
+  $mailboxes = mailhandler_mailbox_load_multiple(array(), array('enabled' => TRUE));
+
+  // Process mailboxes.
+  foreach ($mailboxes as $mid => $mailbox) {
+    mailhandler_node_process_mailbox((object)$mailbox, 'auto');
   }
 }
 

