Index: libraries/PuSHSubscriber.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feeds/libraries/PuSHSubscriber.inc,v
retrieving revision 1.7
diff -u -p -r1.7 PuSHSubscriber.inc
--- libraries/PuSHSubscriber.inc	23 Mar 2010 13:14:03 -0000	1.7
+++ libraries/PuSHSubscriber.inc	29 Jul 2010 01:06:47 -0000
@@ -175,10 +175,18 @@ class PuSHSubscriber {
   }
 
   /**
-   * Verify a request. After a hub has received a subscribe or unsubscribe
-   * request (see PuSHSubscriber::request()) it sends back a challenge verifying
-   * that an action indeed was requested ($_GET['hub_challenge']). This
-   * method handles the challenge.
+   * Verify a request.
+   *
+   * After a hub has received a subscribe or unsubscribe request (see
+   * PuSHSubscriber::request()) it sends back a challenge verifying that an
+   * action indeed was requested ($_GET['hub_challenge']). This method handles
+   * the challenge.
+   *
+   * @return
+   *   An array with a key 'mode' that is either 'subscribe' or 'unsubscribe'
+   *   and a key 'challenge' that is the challenge sent by the hub if the
+   *   request could be verified, NULL otherwise. Pass the result on to
+   *   verificationResponse() to output the verification response to the client.
    */
   public function verifyRequest() {
     if (isset($_GET['hub_challenge'])) {
@@ -199,29 +207,53 @@ class PuSHSubscriber {
             $sub->post_fields = array();
             $sub->save();
             $this->log('Verified "subscribe" request.');
-            $verify = TRUE;
+            return array(
+              'mode' => 'subscribe',
+              'challenge' => $_GET['hub_challenge'],
+            );
           }
           elseif ($_GET['hub_mode'] == 'unsubscribe' && $sub->status == 'unsubscribe') {
             $sub->status = 'unsubscribed';
             $sub->post_fields = array();
             $sub->save();
             $this->log('Verified "unsubscribe" request.');
-            $verify = TRUE;
+            return array(
+              'mode' => 'unsubscribe',
+              'challenge' => $_GET['hub_challenge'],
+            );
           }
         }
       }
       elseif ($_GET['hub_mode'] == 'unsubscribe') {
         $this->log('Verified "unsubscribe" request.');
-        $verify = TRUE;
-      }
-      if ($verify) {
-        header('HTTP/1.1 200 "Found"', null, 200);
-        print $_GET['hub_challenge'];
-        exit();
+        return array(
+          'mode' => 'unsubscribe',
+          'challenge' => $_GET['hub_challenge'],
+        );
       }
     }
+  }
+
+  /**
+   * Print a response to a verification request.
+   *
+   * Common usage:
+   *
+   * $result = $subscriber->verifyRequest();
+   * $subscriber->printVerificationRequest($result);
+   *
+   * @param $result
+   *   An array where the key 'mode' is either 'subscribe' or 'unsubscribe' and
+   *   the key 'challenge' is the hub challenge. Pass in NULL to respond
+   *   negative.
+   */
+  public function verificationResponse($result) {
+    if (isset($result['challenge'])) {
+      header('HTTP/1.1 200 "Found"', null, 200);
+      print $result['challenge'];
+      exit();
+    }
     header('HTTP/1.1 404 "Not Found"', null, 404);
-    $this->log('Could not verify subscription.', 'error');
     exit();
   }
 
Index: plugins/FeedsHTTPFetcher.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsHTTPFetcher.inc,v
retrieving revision 1.23
diff -u -p -r1.23 FeedsHTTPFetcher.inc
--- plugins/FeedsHTTPFetcher.inc	1 Jul 2010 14:19:18 -0000	1.23
+++ plugins/FeedsHTTPFetcher.inc	29 Jul 2010 01:06:47 -0000
@@ -71,7 +71,15 @@ class FeedsHTTPFetcher extends FeedsFetc
     @feeds_dbg(file_get_contents('php://input'));
     // A subscription verification has been sent, verify.
     if (isset($_GET['hub_challenge'])) {
-      $this->subscriber($feed_nid)->verifyRequest();
+      $result = $this->subscriber($feed_nid)->verifyRequest();
+      if (isset($result['subscribe'])) {
+        // Do stuff like:
+        // feeds_scheduler()->setSchedulePeriod('import', $this->id, $feed_nid, 86400);
+      }
+      else if (isset($result['unsubscribe'])) {
+        // feeds_scheduler()->unsetSchedulePeriod('import', $this->id, $feed_nid);
+      }
+      $this->subscriber($feed_nid)->verificationResponse($result);
     }
     // No subscription notification has ben sent, we are being notified.
     else {
