SuperTweet interface driver classes.

Dependents:   SuperTweet_TestProgram StarBoardOrangeExpansion1 GSL_04-Network_Twitter

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Thu Oct 28 12:02:05 2010 +0000
Parent:
0:d48d92e6c145
Child:
2:d463d3fc4f81
Commit message:
Added comments.

Changed in this revision

SuperTweet.cpp Show annotated file Show diff for this revision Revisions of this file
SuperTweet.h Show annotated file Show diff for this revision Revisions of this file
SuperTweetV1XML.cpp Show annotated file Show diff for this revision Revisions of this file
SuperTweetV1XML.h Show annotated file Show diff for this revision Revisions of this file
--- a/SuperTweet.cpp	Tue Oct 12 22:20:38 2010 +0000
+++ b/SuperTweet.cpp	Thu Oct 28 12:02:05 2010 +0000
@@ -9,15 +9,29 @@
 
 const std::string SuperTweet::URLBASE_V1 = "http://api.supertweet.net/1/";
 
+/**
+ * Create.
+ *
+ * @param account Account name.
+ * @param password Password.
+ */
 SuperTweet::SuperTweet(const std::string account, const std::string password)
         : account(account), password(password), client() {
     client.basicAuth(account.c_str(), password.c_str());
     client.setTimeout(10000);
 }
 
+/**
+ * Dispose.
+ */
 SuperTweet::~SuperTweet() {
 }
 
+/**
+ * Set timeout.
+ *
+ * @param ms Timeout. [ms]
+ */
 void SuperTweet::setTimeout(int ms) {
     client.setTimeout(ms);
 }
--- a/SuperTweet.h	Tue Oct 12 22:20:38 2010 +0000
+++ b/SuperTweet.h	Thu Oct 28 12:02:05 2010 +0000
@@ -8,14 +8,58 @@
 #include <string>
 #include "HTTPClient.h"
 
+/**
+ * SuperTweet driver class.
+ */
 class SuperTweet {
 public:
+
+    /**
+     * Create.
+     *
+     * @param account Account name.
+     * @param password Password.
+     */
     SuperTweet(const std::string account, const std::string password);
+
+    /**
+     * Dispose.
+     */
     virtual ~SuperTweet();
+
+    /**
+     * Set timeout.
+     *
+     * @param ms Timeout. [ms]
+     */
     void setTimeout(int ms);
+
+    /**
+     * Returns the 20 most recent statuses posted by the authenticating user.
+     *
+     * @param func A pointer to a callback function.
+     * @return Result code.
+     */
     virtual HTTPResult getStatusesUserTimeline(void (*func)(char *buf, size_t siz)) = 0;
+
+    /**
+     * Returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the user's they follow.
+     *
+     * @param func A pointer to a callback function.
+     * @return Result code.
+     */
     virtual HTTPResult getStatusesHomeTimeline(void (*func)(char *buf, size_t siz)) = 0;
+
+    /**
+     * Updates the authenticating user's status.
+     * A status update with text identical to the authenticating user's text identical
+     * to the authenticating user's current status will be ignored to prevent duplicates.
+     *
+     * @param func A pointer to a callback function.
+     * @return Result code.
+     */
     virtual HTTPResult postStatusesUpdate(const std::string datatext, void (*func)(char *buf, size_t siz)) = 0;
+
 protected:
     static const std::string URLBASE_V1;
     const std::string account;
--- a/SuperTweetV1XML.cpp	Tue Oct 12 22:20:38 2010 +0000
+++ b/SuperTweetV1XML.cpp	Thu Oct 28 12:02:05 2010 +0000
@@ -7,13 +7,28 @@
 
 #include "SuperTweetV1XML.h"
 
+/**
+ * Create.
+ *
+ * @param account Account name.
+ * @param password Password.
+ */
 SuperTweetV1XML::SuperTweetV1XML(const std::string account, const std::string password)
         : SuperTweet(account, password) {
 }
 
+/**
+ * Dispose.
+ */
 SuperTweetV1XML::~SuperTweetV1XML() {
 }
 
+/**
+ * Returns the 20 most recent statuses posted by the authenticating user.
+ *
+ * @param func A pointer to a callback function.
+ * @return Result code.
+ */
 HTTPResult SuperTweetV1XML::getStatusesUserTimeline(void (*func)(char *buf, size_t siz)) {
     HTTPMap map;
     HTTPStream stream;
@@ -35,6 +50,12 @@
     return result;
 }
 
+/**
+ * Returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the user's they follow.
+ *
+ * @param func A pointer to a callback function.
+ * @return Result code.
+ */
 HTTPResult SuperTweetV1XML::getStatusesHomeTimeline(void (*func)(char *buf, size_t siz)) {
     HTTPMap map;
     HTTPStream stream;
@@ -46,18 +67,26 @@
     stream.readNext((byte*)buf, sizeof(buf) - 1);
     HTTPResult r = client.get(url.c_str(), &stream, this, &SuperTweetV1XML::callback);
     if (r != HTTP_OK) {
-    while (!completed) {
-        Net::poll();
-        if (stream.readable()) {
-            buf[stream.readLen()] = 0;
-            func(buf, stream.readLen());
-            stream.readNext((byte*)buf, sizeof(buf) - 1);
+        while (!completed) {
+            Net::poll();
+            if (stream.readable()) {
+                buf[stream.readLen()] = 0;
+                func(buf, stream.readLen());
+                stream.readNext((byte*)buf, sizeof(buf) - 1);
+            }
         }
     }
-    }
     return result;
 }
 
+/**
+ * Updates the authenticating user's status.
+ * A status update with text identical to the authenticating user's text identical
+ * to the authenticating user's current status will be ignored to prevent duplicates.
+ *
+ * @param func A pointer to a callback function.
+ * @return Result code.
+ */
 HTTPResult SuperTweetV1XML::postStatusesUpdate(const std::string datatext, void (*func)(char *buf, size_t siz)) {
     HTTPMap map;
     HTTPStream stream;
--- a/SuperTweetV1XML.h	Tue Oct 12 22:20:38 2010 +0000
+++ b/SuperTweetV1XML.h	Thu Oct 28 12:02:05 2010 +0000
@@ -7,12 +7,49 @@
 
 #include "SuperTweet.h"
 
+/**
+ * SuperTweet driver class.
+ */
 class SuperTweetV1XML : public SuperTweet {
 public:
+
+    /**
+     * Create.
+     *
+     * @param account Account name.
+     * @param password Password.
+     */
     SuperTweetV1XML(const std::string account, const std::string password);
+
+    /**
+     * Dispose.
+     */
     virtual ~SuperTweetV1XML();
+
+    /**
+     * Returns the 20 most recent statuses posted by the authenticating user.
+     *
+     * @param func A pointer to a callback function.
+     * @return Result code.
+     */
     virtual HTTPResult getStatusesUserTimeline(void (*func)(char *buf, size_t siz));
+
+    /**
+     * Returns the 20 most recent statuses, including retweets if they exist, posted by the authenticating user and the user's they follow.
+     *
+     * @param func A pointer to a callback function.
+     * @return Result code.
+     */
     virtual HTTPResult getStatusesHomeTimeline(void (*func)(char *buf, size_t siz));
+
+    /**
+     * Updates the authenticating user's status.
+     * A status update with text identical to the authenticating user's text identical
+     * to the authenticating user's current status will be ignored to prevent duplicates.
+     *
+     * @param func A pointer to a callback function.
+     * @return Result code.
+     */
     virtual HTTPResult postStatusesUpdate(const std::string datatext, void (*func)(char *buf, size_t siz));
 private:
     HTTPResult result;