Index: mythplugins/configure
===================================================================
--- mythplugins/configure (revision 22859)
+++ mythplugins/configure (working copy)
@@ -22,6 +22,7 @@
archive="yes"
zoneminder="yes"
movies="yes"
+twitter="yes"
cc="gcc"
qmake="qmake"
@@ -89,6 +90,9 @@
MythMovies related options:
--enable-mythmovies build the mythmovies plugin [$movies]
+MythTwitter related options:
+ --enable-mythtwitter build the mythmovies plugin [$twitter]
+
EOF
exit 1
fi
@@ -173,6 +177,10 @@
;;
--disable-mythmovies) movies="no"
;;
+ --enable-mythtwitter) twitter="yes"
+ ;;
+ --disable-mythtwitter) twitter="no"
+ ;;
--enable-opengl) opengl="yes"
;;
--disable-opengl) opengl="no"
@@ -214,6 +222,7 @@
zoneminder="yes";
flix="yes";
movies="yes";
+ twitter="yes";
sdl="yes";
opengl="yes";
visual="yes";
@@ -233,6 +242,7 @@
zoneminder="no";
flix="no";
movies="no";
+ twitter="no";
sdl="no";
opengl="no";
visual="no";
@@ -570,7 +580,14 @@
echo " MythMovies plugin will not be built"
fi
+if test "$twitter" = "yes" ; then
+ echo " MythTwitter plugin will be built"
+ echo "SUBDIRS += mythtwitter" >> ./config.pro
+else
+ echo " MythTwitter plugin will not be built"
+fi
+
###########################################################
# #
# MythGallery related configuration options #
Index: mythplugins/mythtwitter/i18n/themestrings.h
===================================================================
--- mythplugins/mythtwitter/i18n/themestrings.h (revision 0)
+++ mythplugins/mythtwitter/i18n/themestrings.h (revision 0)
@@ -0,0 +1,4 @@
+void strings_null() {
+ ThemeUI::tr("Cancel");
+ ThemeUI::tr("Ok");
+}
Index: mythplugins/mythtwitter/i18n/dummy.c
===================================================================
--- mythplugins/mythtwitter/i18n/dummy.c (revision 0)
+++ mythplugins/mythtwitter/i18n/dummy.c (revision 0)
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
Index: mythplugins/mythtwitter/i18n/translate.pro
===================================================================
--- mythplugins/mythtwitter/i18n/translate.pro (revision 0)
+++ mythplugins/mythtwitter/i18n/translate.pro (revision 0)
@@ -0,0 +1,4 @@
+SOURCES += ../mythtwitter/*.cpp
+SOURCES += ../mythtwitter/*.h
+SOURCES += ./themestrings.h
+
Index: mythplugins/mythtwitter/i18n/i18n.pro
===================================================================
--- mythplugins/mythtwitter/i18n/i18n.pro (revision 0)
+++ mythplugins/mythtwitter/i18n/i18n.pro (revision 0)
@@ -0,0 +1,11 @@
+include ( ../../mythconfig.mak )
+include ( ../../settings.pro )
+
+TEMPLATE = app
+CONFIG -= moc qt
+
+trans.path = $${PREFIX}/share/mythtv/i18n/
+
+INSTALLS += trans
+
+SOURCES += dummy.c
Index: mythplugins/mythtwitter/theme/theme.pro
===================================================================
--- mythplugins/mythtwitter/theme/theme.pro (revision 0)
+++ mythplugins/mythtwitter/theme/theme.pro (revision 0)
@@ -0,0 +1,24 @@
+include ( ../../mythconfig.mak )
+include ( ../../settings.pro )
+
+QMAKE_STRIP = echo
+
+TARGET = themenop
+TEMPLATE = app
+CONFIG -= qt moc
+
+QMAKE_COPY_DIR = sh ../../cpsvndir
+
+defaultfiles.path = $${PREFIX}/share/mythtv/themes/default
+defaultfiles.files = default/*.xml
+
+widefiles.path = $${PREFIX}/share/mythtv/themes/default-wide
+widefiles.files = default-wide/*.xml
+
+menufiles.path = $${PREFIX}/share/mythtv/
+menufiles.files = menus/*.xml
+
+INSTALLS += defaultfiles widefiles menufiles
+
+# Input
+SOURCES += ../../themedummy.c
Index: mythplugins/mythtwitter/theme/default/twitter-ui.xml
===================================================================
--- mythplugins/mythtwitter/theme/default/twitter-ui.xml (revision 0)
+++ mythplugins/mythtwitter/theme/default/twitter-ui.xml (revision 0)
@@ -0,0 +1,182 @@
+
+
+
+ -1,-1,580,165
+
+
+ mythprogressdialog-background.png
+
+
+
+
+
+ 102,50
+
+
+
+
+
+
+
+
+
+ -1,-1,500,500
+
+
+ mythdialogbox-background.png
+
+
+
+
+
+
+
+ 58,210
+
+
+
+
+
+ 58,340
+
+
+
+
+
+
+
+
+
+
+
+ 50,148,700,445
+ vertical
+ 1
+ 0,0,100%,430
+
+ 0,0,100%,75
+
+ 0,0,100%,75
+
+ 0,0,100%,100%
+ box
+
+
+
+ 5,5,65,65
+ 140
+ true
+
+
+
+
+
+
+
+
+
+ 255
+
+
+
+
+
+
+
+
+
+
+
+
+ 640,405
+
+
+ lb-uparrow-reg.png
+
+
+
+
+ lb-uparrow-sel.png
+
+
+
+
+ 670,405
+
+
+ lb-dnarrow-reg.png
+
+
+
+
+ lb-dnarrow-sel.png
+
+
+
+
+
+
+ 230,58
+
+
+
+
+
+
+
+
+
+
Index: mythplugins/mythtwitter/theme/default-wide/twitter-ui.xml
===================================================================
--- mythplugins/mythtwitter/theme/default-wide/twitter-ui.xml (revision 0)
+++ mythplugins/mythtwitter/theme/default-wide/twitter-ui.xml (revision 0)
@@ -0,0 +1,182 @@
+
+
+
+ -1,-1,580,165
+
+
+ mythprogressdialog-background.png
+
+
+
+
+
+ 102,50
+
+
+
+
+
+
+
+
+
+ -1,-1,500,500
+
+
+ mythdialogbox-background.png
+
+
+
+
+
+
+
+ 58,210
+
+
+
+
+
+ 58,340
+
+
+
+
+
+
+
+
+
+
+
+ 50,148,1180,535
+ vertical
+ 1
+ 0,0,100%,100%
+
+ 0,0,100%,75
+
+ 0,0,100%,75
+
+ 0,0,100%,100%
+ box
+
+
+
+ 5,5,65,65
+ 140
+ true
+
+
+
+
+
+
+
+
+
+ 255
+
+
+
+
+
+
+
+
+
+
+
+
+ 1040,535
+
+
+ lb-uparrow-reg.png
+
+
+
+
+ lb-uparrow-sel.png
+
+
+
+
+ 1070,535
+
+
+ lb-dnarrow-reg.png
+
+
+
+
+ lb-dnarrow-sel.png
+
+
+
+
+
+
+ 500,58
+
+
+
+
+
+
+
+
+
+
Index: mythplugins/mythtwitter/mythtwitter.pro
===================================================================
--- mythplugins/mythtwitter/mythtwitter.pro (revision 0)
+++ mythplugins/mythtwitter/mythtwitter.pro (revision 0)
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+# Directories
+SUBDIRS = mythtwitter theme i18n
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterconfig.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterconfig.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterconfig.h (revision 0)
@@ -0,0 +1,45 @@
+#ifndef MYTHTWITTERSETTINGS_H
+#define MYTHTWITTERSETTINGS_H
+
+#include
+#include
+#include
+#include
+#include
+
+// libmythui
+#include
+#include
+#include
+#include
+#include
+
+class MythTwitterSettings : public MythScreenType
+{
+ Q_OBJECT
+
+ public:
+
+ MythTwitterSettings(MythScreenStack *parent, const char *name = 0);
+ ~MythTwitterSettings();
+
+ bool Create(void);
+ bool keyPressEvent(QKeyEvent *);
+
+ public slots:
+ void slotSave(void);
+
+ private:
+// MythUIButtonList *m_serviceList;
+ MythUITextEdit *m_loginEdit;
+ MythUITextEdit *m_passwordEdit;
+
+ MythUIButton *m_okButton;
+ MythUIButton *m_cancelButton;
+
+ private slots:
+ void populateServices(void);
+};
+
+#endif
+
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterserver.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterserver.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterserver.h (revision 0)
@@ -0,0 +1,91 @@
+#ifndef MYTHTWITTERSERVER_H
+#define MYTHTWITTERSERVER_H
+
+namespace SERVER
+{
+ enum DEVICES { SMS, IM, NONE };
+
+ enum RESP
+ {
+ OK = 200,
+ NOT_MODIFIED = 304,
+ BAD_REQUEST = 400,
+ NOT_AUTHORIZED = 401,
+ FORBIDDEN = 403,
+ NOT_FOUND = 404,
+ INTERNAL_SERVER_ERROR = 500,
+ BAD_GATEWAY = 502,
+ SERVICE_UNAVAILABLE = 503,
+ UNKNOWN = 2723
+ };
+
+ enum PROXY_TYPE {
+ NO_PROXY,
+ SOCKS5_PROXY,
+ HTTP_PROXY
+ };
+
+ struct Option1
+ {
+ Option1() {since_id=1; max_id=65536; count=200; page=1; }
+ /// Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
+ quint64 since_id;
+ /// Optional. Returns only statuses with an ID less than (that is, older than) the specified
+ quint64 max_id;
+ /// Optional. Specifies the number of statuses to retrieve. May not be greater than 200.
+ unsigned int count;
+ /// Optional. Specify which page to return.
+ unsigned int page;
+ };
+
+ struct Option2
+ {
+ Option2() { id=""; user_id=6253282; screen_name=""; since_id=1; max_id=Q_INT64_C(932838457459459); page=1;}
+ /// Optional. Specifies the ID or screen name of the user for whom to return the user_timeline.
+ QString id;
+ /// Optional. Specfies the ID of the user for whom to return the user_timeline. Helpful for disambiguating when a valid user ID is also a valid screen name.
+ unsigned int user_id;
+ /// Optional. Specfies the screen name of the user for whom to return the user_timeline. Helpful for disambiguating when a valid screen name is also a user ID.
+ QString screen_name;
+ /// Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
+ quint64 since_id;
+ /// Optional. Returns only statuses with an ID less than (that is, older than) the specified ID.
+ quint64 max_id;
+ /// Optional. Specify which page to return.
+ unsigned int page;
+ };
+
+ struct Option3
+ {
+ Option3() { since_id=1; max_id=65536; page=1; }
+ /// Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
+ quint64 since_id;
+ /// Optional. Returns only statuses with an ID less than (that is, older than) the specified
+ quint64 max_id;
+ /// Optional. Retrieves the 20 next most recent mentions.
+ unsigned int page;
+ };
+
+ struct Option4
+ {
+ Option4() { id=""; user_id=6253282; screen_name=""; page=1; }
+ /// Optional. The ID or screen name of the user for whom to request a list of friends.
+ QString id;
+ /// Optional. Specfies the ID of the user for whom to return the list of friends. Helpful for disambiguating when a valid user ID is also a valid screen name.
+ unsigned int user_id;
+ /// Optional. Specfies the screen name of the user for whom to return the list of friends. Helpful for disambiguating when a valid screen name is also a user ID.
+ QString screen_name;
+ /// Optional. Retrieves the next 100 friends.
+ unsigned int page;
+ };
+
+ struct Option5
+ {
+ Option5() {since_id=1; page=1; }
+ /// Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.
+ quint64 since_id;
+ /// Optional. Specify which page to return.
+ unsigned int page;
+ };
+};
+#endif //MYTHTWITTERSERVER_H
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterlib.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterlib.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterlib.h (revision 0)
@@ -0,0 +1,350 @@
+#ifndef MYTHTWITTERLIB_H
+#define MYTHTWITTERLIB_H
+
+#ifdef WIN32
+ #define EXPORT __declspec(dllexport)
+#else
+ #define EXPORT
+#endif
+
+#include
+#include "mythtwitterserver.h"
+#include "mythtwittercore.h"
+
+class MythTwitter : public Core
+{
+ public:
+ EXPORT MythTwitter();
+ virtual ~MythTwitter();
+
+//=====================================================================
+ // Unauthenticated Methods
+//=====================================================================
+ /**
+ * Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
+ * Does not require authentication.
+ */
+ EXPORT void GetPublicTimeline();
+//=====================================================================
+ /**
+ * Returns a single status, specified by the id parameter below. The status's author will be returned inline.
+ * @param id Required. The numerical ID of the status you're trying to retrieve.
+ */
+ EXPORT void GetSingleStatus(quint64 id);
+//=====================================================================
+ /**
+ * WARNING!!! Not described in API
+ * Returns a list of the users currently featured on the site with their current statuses inline.
+ */
+ EXPORT void GetFeaturedUsers();
+//=====================================================================
+ /**
+ * Attempts to establish an authorized connection with Twitter.
+ * See SetLoginInfo(QString user, QString password) and VerifyCredentials();
+ */
+ EXPORT void Login(QString user, QString password);
+//=====================================================================
+ /**
+ * Ends the session of the authenticating user, returning a null cookie.
+ * Use this method to sign users out of client-facing applications like widgets.
+ */
+ EXPORT void Logout();
+//=====================================================================
+ /**
+ * Aborts the current request and deletes all scheduled requests.
+ */
+ EXPORT void Abort();
+//=====================================================================
+ /**
+ * Sets the user name and password for establish an authorized connection with Twitter.
+ */
+ EXPORT void SetLoginInfo(QString user, QString password);
+//=====================================================================
+ /**
+ * NOTE: Use only after "SetLoginInfo(QString user, QString password)" method!
+ *
+ * Returns an HTTP 200 OK response code and a representation of the requesting user if
+ * authentication was successful; returns a 401 status code and an error message if not.
+ * Use this method to test if supplied user credentials are valid.
+ */
+ EXPORT void VerifyCredentials();
+//=====================================================================
+ /**
+ * Use proxy for connection with Twitter.
+ */
+ EXPORT void SetProxy(SERVER::PROXY_TYPE type, const QString hostName, \
+ quint16 port, const QString user, const QString password);
+//=====================================================================
+ /**
+ * Returns the string "ok" in the requested format with a 200 OK HTTP status code.
+ */
+ EXPORT void IsTwitterUp();
+//=====================================================================
+//=====================================================================
+
+
+//=====================================================================
+ // Authenticated/Unauthenticated Methods
+//=====================================================================
+ /**
+ * Returns the 20 most recent statuses posted from the authenticating user.
+ * It's also possible to request another user's timeline via the id parameter below.
+ * This is the equivalent of the Web /archive page for your own user, or the profile page for a third party.
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetUsersTimeline(SERVER::Option2 *opt=NULL);
+//=====================================================================
+ /**
+ * Returns the 20 most recent favorite statuses for the authenticating user or user specified by the ID parameter in the requested format.
+ * @param user Optional. The ID or screen name of the user for whom to request a list of favorite statuses.
+ */
+ EXPORT void GetFavorites(QString user="", unsigned int page=1);
+//=====================================================================
+ /**
+ * Returns an array of numeric IDs for every user the specified user is following.
+ * @param id Optional. The ID or screen_name of the user to retrieve
+ * the friends ID list for.
+ * @param user_id Optional. Specfies the ID of the user for whom to return the friends
+ * list. Helpful for disambiguating when a valid user ID is also a valid screen name.
+ * @param screen_name Optional. Specfies the screen name of the user for whom to return the
+ * friends list. Helpful for disambiguating when a valid screen name is also a user ID.
+ */
+ EXPORT void GetFriendsIDs(QString id = "", QString user_id = "", QString screen_name = "");
+//=====================================================================
+ /**
+ * Returns an array of numeric IDs for every user the specified user is followed by.
+ * @param id Optional. The ID or screen_name of the user to retrieve
+ * the friends ID list for.
+ * @param user_id Optional. Specfies the ID of the user for whom to return the followers list.
+ * Helpful for disambiguating when a valid user ID is also a valid screen name.
+ * @param screen_name Optional. Specfies the screen name of the user for whom to return
+ * the followers list. Helpful for disambiguating when a valid screen name is also a user ID.
+ */
+ EXPORT void GetFollowersIDs(QString id = "", QString user_id = "", QString screen_name = "");
+//=====================================================================
+//=====================================================================
+
+
+//=====================================================================
+ // Authenticated Methods
+//=====================================================================
+ /**
+ * Returns the 20 most recent statuses posted by the authenticating user and that user's friends.
+ * This is the equivalent of /home on the Web.
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetFriendsTimeline(SERVER::Option1 *opt=NULL);
+//=====================================================================
+ /**
+ * Updates the authenticating user's status. Requires the status parameter specified below. Request must be a POST.
+ * @param status Required. The text of your status update. Be sure to URL encode as necessary.
+ * Must not be more than 160 characters and should not be more than 140 characters to ensure optimal display.
+ * @param in_reply_to_status_id Optional. The ID of an existing status that the status to be
+ * posted is in reply to. This implicitly sets the in_reply_to_user_id attribute of the resulting
+ * status to the user ID of the message being replied to. Invalid/missing status IDs will be ignored.
+ * WARNING!!! Not described in API.
+ * @param source Optional. Twitter client name, must be registered at http://twitter.com/help/request_source
+ */
+ EXPORT void PostNewStatus(QString status, quint64 in_reply_to_status_id = NULL, QString source = "");
+//=====================================================================
+ /**
+ * Returns the 20 most recent mentions (status containing @username) for the authenticating user.
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetRecentMentions(SERVER::Option3 *opt=NULL);
+//=====================================================================
+ /**
+ * Destroys the status specified by the required ID parameter. The authenticating user must be the author of the specified status.
+ * @param id Required. The ID of the status to destroy.
+ */
+ EXPORT void RemoveStatus(quint64 id);
+//=====================================================================
+ /**
+ * Returns up to 100 of the authenticating user's friends who have most recently updated, each with current status inline.
+ * It's also possible to request another user's recent friends list via the id parameter below.
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetFriends(SERVER::Option4 *opt=NULL);
+//=====================================================================
+ /**
+ * Returns the authenticating user's followers, each with current status inline.
+ * They are ordered by the order in which they joined Twitter (this is going to be changed).
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetFollowers(SERVER::Option4 *opt=NULL);
+//=====================================================================
+ /**
+ * Returns extended information of a given user, specified by ID or screen name as per the
+ * required id parameter below. This information includes design settings, so third party
+ * developers can theme their widgets according to a given user's preferences.
+ * You must be properly authenticated to request the page of a protected user.
+ * One of the following is required:
+ * @param id The ID or screen name of a user.
+ * @param user_id Optional. Specfies the ID of the user to return.
+ * Helpful for disambiguating when a valid user ID is also a valid screen name.
+ * @param screen_name Optional. Specfies the screen name of the user to return.
+ * Helpful for disambiguating when a valid screen name is also a user ID.
+ */
+ EXPORT void GetUserDetails(QString id = "", unsigned int user_id=NULL, QString screen_name = "");
+//=====================================================================
+ /**
+ * Returns a list of the 20 most recent direct messages sent by the authenticating user.
+ * The XML and JSON versions include detailed information about the sending and recipient users.
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetSentDirectMessages(SERVER::Option5 *opt=NULL);
+//=====================================================================
+ /**
+ * Returns a list of the 20 most recent direct messages sent to the authenticating user.
+ * The XML and JSON versions include detailed information about the sending and recipient users.
+ * @param opt Optional. Options which can be user specified.
+ */
+ EXPORT void GetReceivedDirectMessages(SERVER::Option5 *opt=NULL);;
+//=====================================================================
+ /**
+ * Sends a new direct message to the specified user from the authenticating user.
+ * Requires both the user and text parameters below. Request must be a POST.
+ * Returns the sent message in the requested format when successful.
+ * @param user Required. The ID or screen name of the recipient user.
+ * @param text Required. The text of your direct message.
+ * Be sure to URL encode as necessary, and keep it under 140 characters.
+ */
+ EXPORT void SendDirectMessage(QString user, QString text);
+//=====================================================================
+ /**
+ * Destroys the direct message specified in the required ID parameter.
+ * The authenticating user must be the recipient of the specified direct message.
+ * @param id Required. The ID of the direct message to destroy.
+ */
+ EXPORT void RemoveDirectMessage(quint64 id);
+//=====================================================================
+ /**
+ * Befriends the user specified in the ID parameter as the authenticating user.
+ * Returns the befriended user in the requested format when successful.
+ * Returns a string describing the failure condition when unsuccessful.
+ * @param user Required. The ID or screen name of the user to befriend.
+ */
+ EXPORT void AddFriendship(QString user, bool follow=true);
+//=====================================================================
+ /**
+ * Discontinues friendship with the user specified in the ID parameter as the authenticating user.
+ * Returns the un-friended user in the requested format when successful. Returns a string describing the failure condition when unsuccessful.
+ * @param user Required. The ID or screen name of the user with whom to discontinue friendship.
+ */
+ EXPORT void RemoveFriendship(QString user);
+//=====================================================================
+ /**
+ * Tests if a friendship exists between two users.
+ * @param user_a Required. The ID or screen_name of the first user to test friendship for.
+ * @param user_b Required. The ID or screen_name of the second user to test friendship for.
+ */
+ EXPORT void FriendshipExist(QString user_a, QString user_b);
+//=====================================================================
+ /**
+ * Sets which device Twitter delivers updates to for the authenticating user.
+ * Sending none as the device parameter will disable IM or SMS updates.
+ * @param device Required. Must be one of: sms, im, none.
+ */
+ EXPORT void UpdateDeliveryDevice(SERVER::DEVICES device);
+//=====================================================================
+ /**
+ * Returns the remaining number of API requests available to the authenticating user before the API limit is reached for the current hour.
+ * Calls to rate_limit_status require authentication, but will not count against the rate limit.
+ */
+ EXPORT void RemainingApiRequests();
+//=====================================================================
+ /**
+ * Favorites the status specified in the ID parameter as the authenticating user. Returns the favorite status when successful.
+ * @param id Required. The ID of the status to favorite.
+ */
+ EXPORT void AddFavorite(quint64 id);
+//=====================================================================
+ /**
+ * Un-favorites the status specified in the ID parameter as the authenticating user.
+ * Returns the un-favorited status in the requested format when successful.
+ * @param id Required. The ID of the status to un-favorite.
+ */
+ EXPORT void RemoveFavorite(quint64 id);
+//=====================================================================
+ /**
+ * Sets one or more hex values that control the color scheme of the authenticating
+ * user's profile page on twitter.com.
+ * One or more of the following parameters must be present.
+ * Each parameter's value must be a valid hexidecimal value,
+ * and may be either three or six characters (ex: #fff or #ffffff).
+ *
+ * @param profile_background_color Optional.
+ * @param profile_text_color Optional.
+ * @param profile_link_color Optional.
+ * @param profile_sidebar_fill_color Optional.
+ * @param profile_sidebar_border_color Optional.
+ */
+ EXPORT void UpdateProfileColors(QString background_color = "", QString text_color = "", QString link_color = "", QString sidebar_fill_color = "", QString sidebar_border_color = "");
+//=====================================================================
+ /**
+ * Updates the authenticating user's profile image.
+ * @param image Required. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes
+ * in size. Images with width larger than 500 pixels will be scaled down.
+ */
+ EXPORT void UpdateProfileImage(QString image);
+//=====================================================================
+ /**
+ * Updates the authenticating user's profile background image.
+ * @param image. Required. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size.
+ * Images with width larger than 2048 pixels will be scaled down.
+ * @param tile Optional. If set to true the background image will be displayed tiled.
+ * The image will not be tiled otherwise.
+ */
+ EXPORT void UpdateProfileBackgroundImage(QString image, bool tile = false);
+//=====================================================================
+ /**
+ * Sets values that users are able to set under the "Account" tab of their settings page.
+ * Only the parameters specified will be updated; to only update the "name" attribute,
+ * for example, only include that parameter in your request.
+ * One or more of the following parameters must be present. Each parameter's value should
+ * be a string. See the individual parameter descriptions below for further constraints.
+ * @param name Optional. Maximum of 20 characters.
+ * @param email Optional. Maximum of 40 characters. Must be a valid email address.
+ * @param url Optional. Maximum of 100 characters. Will be prepended with "http://" if not present.
+ * @param location Optional. Maximum of 30 characters. The contents are not normalized or geocoded in any way.
+ * @param description Optional. Maximum of 160 characters.
+ */
+ EXPORT void UpdateProfile(QString name = "", QString email = "", QString url = "", \
+ QString location = "", QString description = "");
+//=====================================================================
+ /**
+ * NOTE: The Notification Methods require the authenticated user to already be friends with
+ * the specified user otherwise the error "there was a problem following the specified user"
+ * will be returned.
+ *
+ * Enables notifications for updates from the specified user to the authenticating user.
+ * Returns the specified user when successful.
+ * @param id Required. The ID or screen name of the user to follow.
+ */
+ EXPORT void EnableNotifications(QString id);
+//=====================================================================
+ /**
+ * Disables notifications for updates from the specified user to the authenticating user.
+ * Returns the specified user when successful.
+ * @param id Required. The ID or screen name of the user to leave.
+ */
+ EXPORT void DisableNotifications(QString id);
+//=====================================================================
+ /**
+ * Blocks the user specified in the ID parameter as the authenticating user.
+ * Returns the blocked user in the requested format when successful.
+ * @param id Required. The ID or screen_name of the user to block.
+ */
+ EXPORT void BlockUser(QString id);
+//=====================================================================
+ /**
+ * Un-blocks the user specified in the ID parameter as the authenticating user.
+ * Returns the un-blocked user in the requested format when successful.
+ * @param id Required. The ID or screen_name of the user to un-block.
+ */
+ EXPORT void UnBlockUser(QString id);
+//=====================================================================
+};
+
+
+#endif // MythTwitter_H
Index: mythplugins/mythtwitter/mythtwitter/mythtwittertimeline.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwittertimeline.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwittertimeline.h (revision 0)
@@ -0,0 +1,69 @@
+#ifndef MYTHTWITTERTIMELINE_H
+#define MYTHTWITTERTIMELINE_H
+
+// MythTV headers
+#include
+#include
+#include
+
+class MythUIText;
+class MythUITextEdit;
+class MythUIButton;
+class MythUIButtonList;
+class MythDialogBox;
+
+/** \class MythTwitterTimeline
+ * \brief Plugin for simple sending of a Twitter tweet.
+ */
+class MythTwitterTimeline : public MythScreenType
+{
+ Q_OBJECT
+
+ public:
+ MythTwitterTimeline(MythScreenStack *parent, QString name);
+ ~MythTwitterTimeline();
+
+ bool Create(void);
+ void Init(void);
+ bool keyPressEvent(QKeyEvent *);
+ void doMenuPopup(void);
+
+ public slots:
+ void OnResponseReceived(Returnables::Response *resp);
+ void SwitchTimelinePublic(void);
+ void SwitchTimelineUser(void);
+ void SwitchTimelineSpecificUser(void);
+ void SwitchTimelineFriend(void);
+ void AddFriendshipUser(void);
+ void RemoveFriendshipUser(void);
+ void loginSettingsPopup(void);
+ void doRefresh(void);
+ void doSettingsRefresh(void);
+ void updateCount(void);
+ void doDeleteMenu(void);
+ void doRemoveTweet(bool dodelete);
+ void ViewUserPopup(void);
+ void doViewUser(QString username);
+ void doViewPopup(void);
+
+ private:
+ QString m_login;
+ QString m_password;
+ QString m_currentTimeline;
+ QString m_source;
+ bool m_validlogin;
+
+ HttpComms *m_httpcomms;
+ MythTwitter *m_twitter;
+
+ MythUITextEdit *m_tweet;
+ MythUIButton *m_send;
+ MythUIButtonList *m_timelineList;
+ MythUIText *m_count;
+
+ private slots:
+ void sendTweet();
+ void DisplayList(QLinkedList list, QString header);
+};
+
+#endif /* MythTwitterTimeline_H */
Index: mythplugins/mythtwitter/mythtwitter/mythtwitter.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitter.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitter.cpp (revision 0)
@@ -0,0 +1,126 @@
+// POSIX headers
+#include
+
+// C headers
+#include
+
+// QT headers
+#include
+#include
+#include
+#include
+#include
+#include
+
+// MythTV headers
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+// MythTwitter headers
+#include "mythtwitter.h"
+
+#define LOC QString("MythTwitterSend: ")
+#define LOC_WARN QString("MythTwitterSend, Warning: ")
+#define LOC_ERR QString("MythTwitterSend, Error: ")
+
+/** \brief Creates a new MythTwitterSend Screen
+ * \param parent Pointer to the screen stack
+ * \param name The name of the window
+ */
+MythTwitterSend::MythTwitterSend(MythScreenStack *parent, QString name) :
+ MythScreenType(parent, name),
+ m_login(NULL), m_password(NULL),
+ m_source("MythChirp"), m_twitter(),
+ m_tweet(NULL), m_send(NULL),
+ m_cancel(NULL)
+{
+ // Setup cache directory
+
+ QString fileprefix = GetConfDir();
+
+ QDir dir(fileprefix);
+ if (!dir.exists())
+ dir.mkdir(fileprefix);
+ fileprefix += "/MythTwitter";
+ dir = QDir(fileprefix);
+ if (!dir.exists())
+ dir.mkdir(fileprefix);
+
+ m_login = gContext->GetSetting("mythtwitter.LoginName", "login");
+ m_password = gContext->GetSetting("mythtwitter.Password", "password");
+}
+
+MythTwitterSend::~MythTwitterSend()
+{
+}
+
+bool MythTwitterSend::Create(void)
+{
+
+ bool foundtheme = false;
+
+ // Load the theme for this screen
+ foundtheme = LoadWindowFromXML("twitter-ui.xml", "twitter", this);
+
+ if (!foundtheme)
+ return false;
+
+ m_tweet = dynamic_cast (GetChild("tweet"));
+ m_send = dynamic_cast (GetChild("send"));
+ m_cancel = dynamic_cast (GetChild("cancel"));
+
+ if (!m_tweet || !m_send || !m_cancel)
+ {
+ VERBOSE(VB_IMPORTANT, "Theme is missing critical theme elements.");
+ return false;
+ }
+
+ SetFocusWidget(m_tweet);
+
+ connect(m_send, SIGNAL(Clicked()), this, SLOT(sendTweet()));
+ connect(m_cancel, SIGNAL(Clicked()), this, SLOT(Close()));
+ connect(m_tweet, SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
+ connect(m_send, SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
+ connect(m_cancel, SIGNAL(TakingFocus()), SLOT(slotFocusChanged()));
+
+ if (!BuildFocusList())
+ VERBOSE(VB_IMPORTANT, "Failed to build a focuslist. Something is wrong");
+
+ return true;
+}
+
+bool MythTwitterSend::keyPressEvent(QKeyEvent *event)
+{
+ if (GetFocusWidget()->keyPressEvent(event))
+ return true;
+
+ bool handled = false;
+
+ if (!handled && MythScreenType::keyPressEvent(event))
+ handled = true;
+
+ return handled;
+}
+
+void MythTwitterSend::slotFocusChanged(void)
+{
+}
+
+void MythTwitterSend::sendTweet()
+{
+ VERBOSE(VB_IMPORTANT, QString("Sending a tweet with the following contents using a GPLv2 API: %1").arg(m_tweet->GetText()));
+ m_twitter.Login(m_login, m_password);
+ m_twitter.PostNewStatus(m_tweet->GetText(), 0, m_source);
+ m_twitter.Logout();
+
+ Close();
+}
+
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterdecipher.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterdecipher.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterdecipher.cpp (revision 0)
@@ -0,0 +1,811 @@
+#include "mythtwitterdecipher.h"
+#include
+#include
+#include
+
+
+//=====================================================================
+Decipher* Decipher::instance = NULL;
+QString Decipher::nStatus = "status";
+QString Decipher::nCreatedAt = "created_at";
+QString Decipher::nId = "id";
+QString Decipher::nText = "text";
+QString Decipher::nSource = "source";
+QString Decipher::nTruncated = "truncated";
+QString Decipher::nInReplyToStatusId = "in_reply_to_status_id";
+QString Decipher::nInReplyToUserId = "in_reply_to_user_id";
+QString Decipher::nFavorited = "favorited";
+QString Decipher::nUser = "user";
+QString Decipher::nName = "name";
+QString Decipher::nScreenName = "screen_name";
+QString Decipher::nDescription = "description";
+QString Decipher::nLocation = "location";
+QString Decipher::nProfileImageUrl = "profile_image_url";
+QString Decipher::nUrl = "url";
+QString Decipher::nProtected = "protected";
+QString Decipher::nFollowersCount = "followers_count";
+QString Decipher::nOk = "ok";
+QString Decipher::nProfileBackgroundColor = "profile_background_color";
+QString Decipher::nProfileTextColor = "profile_text_color";
+QString Decipher::nProfileLinkColor = "profile_link_color";
+QString Decipher::nProfileSidebarFillColor = "profile_sidebar_fill_color";
+QString Decipher::nProfileSidebarBorderColor = "profile_sidebar_border_color";
+QString Decipher::nFriendsCount = "friends_count";
+QString Decipher::nFavoritesCount = "favourites_count";
+QString Decipher::nUtcOffset = "utc_offset";
+QString Decipher::nTimeZone = "time_zone";
+QString Decipher::nProfileBackgroundImageUrl = "profile_background_image_url";
+QString Decipher::nProfileBackgroundTiled = "profile_background_tile";
+QString Decipher::nStatusesCount = "statuses_count";
+QString Decipher::nDirectMessage = "direct_message";
+QString Decipher::nSenderId = "sender_id";
+QString Decipher::nRecipientId = "recipient_id";
+QString Decipher::nSenderScreenName = "sender_screen_name";
+QString Decipher::nRecipientScreenName = "recipient_screen_name";
+QString Decipher::nSender = "sender";
+QString Decipher::nRecipient = "recipient";
+QString Decipher::nFriends = "friends";
+QString Decipher::nHash = "hash";
+QString Decipher::nResetTime = "reset-time";
+QString Decipher::nResetTimeSeconds = "reset-time-in-seconds";
+QString Decipher::nRemainingHits = "remaining-hits";
+QString Decipher::nHourlyLimit = "hourly-limit";
+QString Decipher::nInReplyToScreenName = "in_reply_to_screen_name";
+QString Decipher::nFollowing = "following";
+QString Decipher::nNotifications = "notifications";
+QString Decipher::nID = "id";
+//=====================================================================
+Decipher::Decipher()
+{}
+//=====================================================================
+Decipher::~Decipher()
+{}
+//=====================================================================
+Decipher* Decipher::Instance()
+{
+ if(instance == NULL)
+ {
+ instance = new Decipher();
+ }
+
+ return instance;
+}
+//=====================================================================
+QLinkedList Decipher::GetStatusElementList(const QString &xml)
+{
+ QDomDocument doc;
+ QDomNodeList nodeList;
+ QLinkedList statusElementList;
+
+ doc.setContent(xml);
+ nodeList = doc.elementsByTagName(nStatus);
+
+ for(int i=0; istatus,node);
+ node = node.namedItem(nUser).toElement();
+ PopulateUser(item->user,node);
+
+ statusElementList.append(item);
+ }
+ return statusElementList;
+}
+//=====================================================================
+QLinkedList Decipher::GetIDsList(const QString &xml)
+{
+ QDomDocument doc;
+ QDomNodeList nodeList;
+ QLinkedList IDsList;
+
+ doc.setContent(xml);
+ nodeList = doc.elementsByTagName(nID);
+
+ for(int i=0; i Decipher::GetBasicUserInfoElementList(const QString &xml)
+{
+ QDomDocument doc;
+ QDomNodeList nodeList;
+ QLinkedList basicUserInfoElementList;
+
+ doc.setContent(xml);
+ nodeList = doc.elementsByTagName(nUser);
+
+ for(int i=0; iuser,node);
+ node = node.namedItem(nStatus).toElement();
+ Populate_biStatus(item->status,node);
+
+ basicUserInfoElementList.append(item);
+ }
+ return basicUserInfoElementList;
+}
+//=====================================================================
+QLinkedList Decipher::GetExtUserInfoElementList(const QString &xml)
+{
+ QDomDocument doc;
+ QDomNodeList nodeList;
+ QLinkedList extUserInfoElementList;
+
+ doc.setContent(xml);
+ nodeList = doc.elementsByTagName(nUser);
+
+ for(int i=0; iuser,node);
+ PopulateDetails(item->details,node);
+ node = node.namedItem(nStatus).toElement();
+ Populate_biStatus(item->status, node);
+
+ extUserInfoElementList.append(item);
+ }
+ return extUserInfoElementList;
+}
+//=====================================================================
+QLinkedList Decipher::GetDirectMessageList(const QString &xml)
+{
+ QDomDocument doc;
+ QDomNodeList nodeList;
+ QLinkedList directMessageList;
+
+ doc.setContent(xml);
+ nodeList = doc.elementsByTagName(nDirectMessage);
+
+ for(int i=0; iheaderInfo,node);
+ nodeSender = node.namedItem(nSender).toElement();
+ PopulateUser(directMessage->sender,nodeSender);
+ nodeRecipient = node.namedItem(nRecipient).toElement();
+ PopulateUser(directMessage->recipient,nodeRecipient);
+
+ directMessageList.append(directMessage);
+ }
+
+ return directMessageList;
+}
+//=====================================================================
+void Decipher::Populate_seStatus(Returnables::seStatus &status, const QDomElement &node)
+{
+ status.createdAt = node.namedItem(nCreatedAt).toElement().text();
+ status.id = node.namedItem(nId).toElement().text().toULongLong();
+ status.text = node.namedItem(nText).toElement().text();
+ status.source = node.namedItem(nSource).toElement().text();
+ status.truncated = (node.namedItem(nTruncated).toElement().text().toLower() == "true") ? true : false;
+ status.inReplyToStatusId = node.namedItem(nInReplyToStatusId).toElement().text().toULongLong();
+ status.inReplyToUserId = node.namedItem(nInReplyToUserId).toElement().text().toULongLong();
+ status.favorited = (node.namedItem(nFavorited).toElement().text().toLower() == "true") ? true : false;
+}
+//=====================================================================
+void Decipher::Populate_biStatus(Returnables::biStatus &status, const QDomElement &node)
+{
+ status.createdAt = node.namedItem(nCreatedAt).toElement().text();
+ status.id = node.namedItem(nId).toElement().text().toULongLong();
+ status.text = node.namedItem(nText).toElement().text();
+ status.source = node.namedItem(nSource).toElement().text();
+ status.truncated = (node.namedItem(nTruncated).toElement().text().toLower() == "true") ? true : false;
+ status.inReplyToStatusId = node.namedItem(nInReplyToStatusId).toElement().text().toULongLong();
+ status.inReplyToUserId = node.namedItem(nInReplyToUserId).toElement().text().toULongLong();
+ status.favorited = (node.namedItem(nFavorited).toElement().text().toLower() == "true") ? true : false;
+ status.inReplyToScreenName = node.namedItem(nInReplyToScreenName).toElement().text();
+}
+//=====================================================================
+void Decipher::PopulateUser(Returnables::User &user, const QDomElement &node)
+{
+ user.id = node.namedItem(nId).toElement().text().toUInt();
+ user.name = node.namedItem(nName).toElement().text();
+ user.screenName = node.namedItem(nScreenName).toElement().text();
+ user.description = node.namedItem(nDescription).toElement().text();
+ user.location = node.namedItem(nLocation).toElement().text();
+ user.profileImageUrl = node.namedItem(nProfileImageUrl).toElement().text();
+ user.url = node.namedItem(nUrl).toElement().text();
+ user.isProtected = (node.namedItem(nProtected).toElement().text().toLower() == "true") ? true : false;
+ user.followersCount = node.namedItem(nFollowersCount).toElement().text().toUInt();
+}
+//=====================================================================
+void Decipher::PopulateDetails(Returnables::Details &details, const QDomElement &node)
+{
+ details.profileBackgroundColor = node.namedItem(nProfileBackgroundColor).toElement().text();
+ details.profileTextColor = node.namedItem(nProfileTextColor).toElement().text();
+ details.profileLinkColor = node.namedItem(nProfileLinkColor).toElement().text();
+ details.profileSidebarFillColor = node.namedItem(nProfileSidebarFillColor).toElement().text();
+ details.profileSidebarBorderColor = node.namedItem(nProfileSidebarBorderColor).toElement().text();
+ details.friendsCount = node.namedItem(nFriendsCount).toElement().text().toUInt();
+ details.createdAt = node.namedItem(nCreatedAt).toElement().text();
+ details.favoritesCount = node.namedItem(nFavoritesCount).toElement().text().toUInt();
+ details.utcOffset = node.namedItem(nUtcOffset).toElement().text().toInt();
+ details.timeZone = node.namedItem(nTimeZone).toElement().text();
+ details.profileBackgroundImageUrl = node.namedItem(nProfileBackgroundImageUrl).toElement().text();
+ details.profileBackgroundTiled = (node.namedItem(nProfileBackgroundTiled).toElement().text().toLower() == "true") ? true : false;
+ details.following = (node.namedItem(nFollowing).toElement().text().toLower() == "true") ? true : false;
+ details.notifications = (node.namedItem(nNotifications).toElement().text().toLower() == "true") ? true : false;
+ details.statusesCount = node.namedItem(nStatusesCount).toElement().text().toUInt();
+}
+//=====================================================================
+void Decipher::PopulateDirectHeader(Returnables::DirectHeader &header, const QDomElement &node)
+{
+ header.createdAt = node.namedItem(nCreatedAt).toElement().text();
+ header.id = node.namedItem(nId).toElement().text().toULongLong();
+ header.recipientId = node.namedItem(nRecipientId).toElement().text().toUInt();
+ header.recipientScreenName = node.namedItem(nRecipientScreenName).toElement().text();
+ header.senderId = node.namedItem(nSenderId).toElement().text().toUInt();
+ header.senderScreenName = node.namedItem(nSenderScreenName).toElement().text();
+ header.text = node.namedItem(nText).toElement().text();
+}
+//=====================================================================
+void Decipher::PopulateApiRequests(Returnables::ApiRequests &apiRequests, const QDomElement &node)
+{
+ apiRequests.hourlyLimit = node.namedItem(nHourlyLimit).toElement().text().toUInt();
+ apiRequests.remainingHits = node.namedItem(nRemainingHits).toElement().text().toUInt();
+ apiRequests.resetTime = node.namedItem(nResetTime).toElement().text();
+ apiRequests.resetTimeSeconds = node.namedItem(nResetTimeSeconds).toElement().text().toUInt();
+}
+//=====================================================================
+Returnables::PublicTimeline* Decipher::PublicTimeline(const QString &xml)
+{
+ Returnables::PublicTimeline *publicTimeline = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ publicTimeline = new Returnables::PublicTimeline();
+ publicTimeline->list = list;
+ publicTimeline->reqID = Returnables::PUBLIC_TIMELINE;
+ }
+
+ return publicTimeline;
+}
+//=====================================================================
+Returnables::FriendsTimeline* Decipher::FriendsTimeline(const QString &xml)
+{
+ Returnables::FriendsTimeline *friendsTimeline = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ friendsTimeline = new Returnables::FriendsTimeline();
+ friendsTimeline->list = list;
+ friendsTimeline->reqID = Returnables::FRIENDS_TIMELINE;
+ }
+
+ return friendsTimeline;
+}
+//=====================================================================
+Returnables::SingleStatus* Decipher::SingleStatus(const QString &xml)
+{
+ Returnables::SingleStatus *singleStatus = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ singleStatus = new Returnables::SingleStatus();
+ singleStatus->status = list.first();
+ singleStatus->reqID = Returnables::SINGLE_STATUS;
+ }
+
+ return singleStatus;
+}
+//=====================================================================
+Returnables::FeaturedUsers* Decipher::FeaturedUsers(const QString &xml)
+{
+ Returnables::FeaturedUsers *featuredUsers = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ featuredUsers = new Returnables::FeaturedUsers();
+ featuredUsers->list = list;
+ featuredUsers->reqID = Returnables::FEATURED_USERS;
+ }
+
+ return featuredUsers;
+}
+//=====================================================================
+Returnables::VerifyCredentials* Decipher::VerifyCredentials(const QString &xml)
+{
+ Returnables::VerifyCredentials *verifyCredentials = NULL;
+ QLinkedList list = GetExtUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ verifyCredentials = new Returnables::VerifyCredentials;
+ verifyCredentials->userExt = list.first();
+ verifyCredentials->reqID = Returnables::VERIFY_CREDENTIALS;
+ }
+ return verifyCredentials;
+}
+//=====================================================================
+Returnables::TwitterUp* Decipher::TwitterUp(const QString &xml)
+{
+ Returnables::TwitterUp *twitterUp = NULL;
+ QDomDocument doc;
+ QDomElement elem;
+
+ doc.setContent(xml);
+ elem = doc.namedItem(nOk).toElement();
+
+ if(!elem.isNull())
+ {
+ twitterUp = new Returnables::TwitterUp();
+ twitterUp->up = (elem.text().toLower().contains("true")) ? true : false;
+ twitterUp->reqID = Returnables::TWITTER_UP;
+ }
+
+ return twitterUp;
+}
+//=====================================================================
+Returnables::UserTimeline* Decipher::UserTimeline(const QString &xml)
+{
+ Returnables::UserTimeline *userTimeline = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ userTimeline = new Returnables::UserTimeline();
+ userTimeline->list = list;
+ userTimeline->reqID = Returnables::USER_TIMELINE;
+ }
+
+ return userTimeline;
+}
+//=====================================================================
+Returnables::Favorites* Decipher::Favorites(const QString &xml)
+{
+ Returnables::Favorites *favorites = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ favorites = new Returnables::Favorites();
+ favorites->list = list;
+ favorites->reqID = Returnables::FAVORITES;
+ }
+
+ return favorites;
+}
+//=====================================================================
+Returnables::NewStatus* Decipher::NewStatus(const QString &xml)
+{
+ Returnables::NewStatus *newStatus = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ newStatus = new Returnables::NewStatus();
+ newStatus->status = list.first();
+ newStatus->reqID = Returnables::NEW_STATUS;
+ }
+
+ return newStatus;
+}
+//=====================================================================
+Returnables::RecentMentions* Decipher::RecentMentions(const QString &xml)
+{
+ Returnables::RecentMentions *mentions = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ mentions = new Returnables::RecentMentions();
+ mentions->list = list;
+ mentions->reqID = Returnables::RECENT_MENTIONS;
+ }
+
+ return mentions;
+}
+//=====================================================================
+Returnables::RemoveStatus* Decipher::RemoveStatus(const QString &xml)
+{
+ Returnables::RemoveStatus *removedStatus = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ removedStatus = new Returnables::RemoveStatus();
+ removedStatus->status = list.first();
+ removedStatus->reqID = Returnables::REMOVE_STATUS;
+ }
+
+ return removedStatus;
+}
+
+//=====================================================================
+Returnables::Friends* Decipher::Friends(const QString &xml)
+{
+ Returnables::Friends *friends = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ friends = new Returnables::Friends();
+ friends->list = list;
+ friends->reqID = Returnables::FRIENDS;
+ }
+
+ return friends;
+}
+//=====================================================================
+Returnables::Followers* Decipher::Followers(const QString &xml)
+{
+ Returnables::Followers *followers = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ followers = new Returnables::Followers();
+ followers->list = list;
+ followers->reqID = Returnables::FOLLOWERS;
+ }
+
+ return followers;
+}
+//=====================================================================
+Returnables::UserDetails* Decipher::UserDetails(const QString &xml)
+{
+ Returnables::UserDetails *userDetails = NULL;
+ QLinkedList list = GetExtUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ userDetails = new Returnables::UserDetails();
+ userDetails->userExt = list.first();
+ userDetails->reqID = Returnables::USER_DETAILS;
+ }
+//Not in API
+// elem = elem.firstChildElement(nStatus);
+// success = (success && !elem.isNull()) ? true : false;
+// PopulateStatus(*userDetails->status,elem);
+
+ return userDetails;
+}
+//=====================================================================
+Returnables::SentDirectMessages* Decipher::SentDirectMessages(const QString &xml)
+{
+ Returnables::SentDirectMessages *sentDirectMessage = NULL;
+ QLinkedList list = GetDirectMessageList(xml);
+
+ if(!list.isEmpty())
+ {
+ sentDirectMessage = new Returnables::SentDirectMessages();
+ sentDirectMessage->list = list;
+ sentDirectMessage->reqID = Returnables::SENT_DIRECT_MESSAGES;
+ }
+
+ return sentDirectMessage;
+}
+//=====================================================================
+Returnables::ReceivedDirectMessages* Decipher::ReceivedDirectMessages(const QString &xml)
+{
+ Returnables::ReceivedDirectMessages *receivedDirectMessages = NULL;
+ QLinkedList list = GetDirectMessageList(xml);
+
+ if(!list.isEmpty())
+ {
+ receivedDirectMessages = new Returnables::ReceivedDirectMessages();
+ receivedDirectMessages->list = list;
+ receivedDirectMessages->reqID = Returnables::RECEIVED_DIRECT_MESSAGES;
+ }
+
+ return receivedDirectMessages;
+}
+//=====================================================================
+Returnables::SendDirectMessage* Decipher::SendDirectMessage(const QString &xml)
+{
+ Returnables::SendDirectMessage *sendDirectMessage = NULL;
+ QLinkedList list = GetDirectMessageList(xml);
+
+ if(!list.isEmpty())
+ {
+ sendDirectMessage = new Returnables::SendDirectMessage();
+ sendDirectMessage->message = list.first();
+ sendDirectMessage->reqID = Returnables::SEND_DIRECT_MESSAGE;
+ }
+
+ return sendDirectMessage;
+}
+//=====================================================================
+Returnables::RemoveDirectMessage* Decipher::RemoveDirectMessage(const QString &xml)
+{
+ Returnables::RemoveDirectMessage *removeDirectMessage = NULL;
+ QLinkedList list = GetDirectMessageList(xml);
+
+ if(!list.isEmpty())
+ {
+ removeDirectMessage = new Returnables::RemoveDirectMessage();
+ removeDirectMessage->message = list.first();
+ removeDirectMessage->reqID = Returnables::REMOVE_DIRECT_MESSAGE;
+ }
+
+ return removeDirectMessage;
+}
+//=====================================================================
+Returnables::AddFriendship* Decipher::AddFriendShip(const QString &xml)
+{
+ Returnables::AddFriendship *addFriendship = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ addFriendship = new Returnables::AddFriendship();
+ addFriendship->user = list.first();
+ addFriendship->reqID = Returnables::ADD_FRIENDSHIP;
+ }
+
+ return addFriendship;
+}
+//=====================================================================
+Returnables::RemoveFriendship* Decipher::RemoveFriendship(const QString &xml)
+{
+ Returnables::RemoveFriendship *removeFriendship = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ removeFriendship = new Returnables::RemoveFriendship();
+ removeFriendship->user = list.first();
+ removeFriendship->reqID = Returnables::REMOVE_FRIENDSHIP;
+ }
+
+ return removeFriendship;
+}
+//=====================================================================
+Returnables::FriendshipExist* Decipher::FriendshipExist(const QString &xml)
+{
+ Returnables::FriendshipExist* friendshipExists = NULL;
+ QDomDocument doc;
+ QDomElement elem;
+
+ doc.setContent(xml);
+ elem = doc.namedItem(nFriends).toElement();
+
+ if(!elem.isNull())
+ {
+ friendshipExists = new Returnables::FriendshipExist();
+ friendshipExists->friends = (elem.text().toLower().contains("true")) ? true : false;
+ friendshipExists->reqID = Returnables::FRIENDSHIP_EXISTS;
+ }
+
+ return friendshipExists;
+}
+//=====================================================================
+Returnables::DeliveryDevice* Decipher::DeliveryDevice(const QString &xml)
+{
+ Returnables::DeliveryDevice *deliveryDevice = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ deliveryDevice = new Returnables::DeliveryDevice();
+ deliveryDevice->user = list.first();
+ deliveryDevice->reqID = Returnables::DELIVERY_DEVICE;
+ }
+
+ return deliveryDevice;
+}
+//=====================================================================
+Returnables::ApiRequests* Decipher::ApiRequests(const QString &xml)
+{
+ Returnables::ApiRequests* apiRequests = NULL;
+ QDomDocument doc;
+ QDomElement elem;
+
+ doc.setContent(xml);
+ elem = doc.namedItem(nHash).toElement();
+
+ if(!elem.isNull())
+ {
+ apiRequests = new Returnables::ApiRequests();
+ PopulateApiRequests(*apiRequests,elem);
+ apiRequests->reqID = Returnables::API_REQUESTS;
+ }
+
+ return apiRequests;
+}
+//=====================================================================
+Returnables::AddFavorite* Decipher::AddFavorite(const QString &xml)
+{
+ Returnables::AddFavorite *addFavorite = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ addFavorite = new Returnables::AddFavorite();
+ addFavorite->status = list.first();
+ addFavorite->reqID = Returnables::ADD_FAVORITE;
+ }
+
+ return addFavorite;
+}
+//=====================================================================
+Returnables::RemoveFavorite* Decipher::RemoveFavorite(const QString &xml)
+{
+ Returnables::RemoveFavorite *removeFavorite = NULL;
+ QLinkedList list = GetStatusElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ removeFavorite = new Returnables::RemoveFavorite();
+ removeFavorite->status = list.first();
+ removeFavorite->reqID = Returnables::REMOVE_FAVORITE;
+ }
+
+ return removeFavorite;
+}
+//=====================================================================
+Returnables::ProfileColors* Decipher::ProfileColors(const QString &xml)
+{
+ Returnables::ProfileColors *profileColors = NULL;
+ QLinkedList list = GetExtUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ profileColors = new Returnables::ProfileColors();
+ profileColors->userExt = list.first();
+ profileColors->reqID = Returnables::PROFILE_COLORS;
+ }
+
+ return profileColors;
+}
+//=====================================================================
+Returnables::ProfileImage* Decipher::ProfileImage(const QString &xml)
+{
+ Returnables::ProfileImage *profileImage = NULL;
+ QLinkedList list = GetExtUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ profileImage = new Returnables::ProfileImage;
+ profileImage->userExt = list.first();
+ profileImage->reqID = Returnables::PROFILE_IMAGE;
+ }
+
+ return profileImage;
+}
+//=====================================================================
+Returnables::ProfileBackgroundImage* Decipher::ProfileBackgroundImage(const QString &xml)
+{
+ Returnables::ProfileBackgroundImage *profileBackgroundImage = NULL;
+ QLinkedList list = GetExtUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ profileBackgroundImage = new Returnables::ProfileBackgroundImage;
+ profileBackgroundImage->userExt = list.first();
+ profileBackgroundImage->reqID = Returnables::PROFILE_BACKGROUND_IMAGE;
+ }
+
+ return profileBackgroundImage;
+}
+//=====================================================================
+Returnables::Profile* Decipher::Profile(const QString &xml)
+{
+ Returnables::Profile *profile = NULL;
+ QLinkedList list = GetExtUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ profile = new Returnables::Profile;
+ profile->userExt = list.first();
+ profile->reqID = Returnables::PROFILE;
+ }
+
+ return profile;
+}
+//=====================================================================
+Returnables::EnableNotifications* Decipher::EnableNotifications(const QString &xml)
+{
+ Returnables::EnableNotifications *enableNotifications = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ enableNotifications = new Returnables::EnableNotifications();
+ enableNotifications->user = list.first();
+ enableNotifications->reqID = Returnables::ENABLE_NOTIFICATIONS;
+ }
+
+ return enableNotifications;
+}
+//=====================================================================
+Returnables::DisableNotifications* Decipher::DisableNotifications(const QString &xml)
+{
+ Returnables::DisableNotifications *disableNotifications = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ disableNotifications = new Returnables::DisableNotifications();
+ disableNotifications->user = list.first();
+ disableNotifications->reqID = Returnables::DISABLE_NOTIFICATIONS;
+ }
+
+ return disableNotifications;
+}
+//=====================================================================
+Returnables::BlockUser* Decipher::BlockUser(const QString &xml)
+{
+ Returnables::BlockUser *blockUser = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ blockUser = new Returnables::BlockUser();
+ blockUser->user = list.first();
+ blockUser->reqID = Returnables::BLOCK_USER;
+ }
+
+ return blockUser;
+}
+//=====================================================================
+Returnables::UnBlockUser* Decipher::UnBlockUser(const QString &xml)
+{
+ Returnables::UnBlockUser *unBlockUser = NULL;
+ QLinkedList list = GetBasicUserInfoElementList(xml);
+
+ if(!list.isEmpty())
+ {
+ unBlockUser = new Returnables::UnBlockUser();
+ unBlockUser->user = list.first();
+ unBlockUser->reqID = Returnables::UNBLOCK_USER;
+ }
+
+ return unBlockUser;
+}
+//=====================================================================
+Returnables::FriendsIDs* Decipher::FriendsIDs(const QString &xml)
+{
+ Returnables::FriendsIDs *friendsIDs = NULL;
+ QLinkedList list = GetIDsList(xml);
+
+ if(!list.isEmpty())
+ {
+ friendsIDs = new Returnables::FriendsIDs();
+ friendsIDs->list = list;
+ friendsIDs->reqID = Returnables::FRIENDS_IDS;
+ }
+ return friendsIDs;
+}
+//=====================================================================
+Returnables::FollowersIDs* Decipher::FollowersIDs(const QString &xml)
+{
+ Returnables::FollowersIDs *followersIDs = NULL;
+ QLinkedList list = GetIDsList(xml);
+
+ if(!list.isEmpty())
+ {
+ followersIDs = new Returnables::FollowersIDs;
+ followersIDs->list = list;
+ followersIDs->reqID = Returnables::FOLLOWERS_IDS;
+ }
+
+ return followersIDs;
+}
+//=====================================================================
Index: mythplugins/mythtwitter/mythtwitter/mythtwitter.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitter.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitter.h (revision 0)
@@ -0,0 +1,43 @@
+#ifndef MYTHTWITTER_H
+#define MYTHTWITTER_H
+
+// MythTV headers
+#include
+#include "mythtwitterlib.h"
+
+class MythUIText;
+class MythUITextEdit;
+class MythUIButton;
+class MythDialogBox;
+
+/** \class MythTwitterSend
+ * \brief Plugin for simple sending of a Twitter tweet.
+ */
+class MythTwitterSend : public MythScreenType
+{
+ Q_OBJECT
+
+ public:
+ MythTwitterSend(MythScreenStack *parent, QString name);
+ ~MythTwitterSend();
+
+ bool Create(void);
+ bool keyPressEvent(QKeyEvent *);
+
+ private:
+
+ QString m_login;
+ QString m_password;
+ QString m_source;
+ MythTwitter m_twitter;
+
+ MythUITextEdit *m_tweet;
+ MythUIButton *m_send;
+ MythUIButton *m_cancel;
+
+ private slots:
+ void sendTweet();
+ void slotFocusChanged();
+};
+
+#endif /* MYTHTWITTER_H */
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterdecipher.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterdecipher.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterdecipher.h (revision 0)
@@ -0,0 +1,124 @@
+#ifndef MythTwitterDecipher_H
+#define MythTwitterDecipher_H
+
+#include
+#include
+#include "mythtwitterreturnables.h"
+
+class QDomElement;
+
+class Decipher
+{
+ private:
+ Decipher();
+ static Decipher *instance;
+
+ public:
+ virtual ~Decipher();
+ static Decipher *Instance();
+
+ public:
+ Returnables::FriendsTimeline* FriendsTimeline(const QString &xml);
+ Returnables::PublicTimeline* PublicTimeline(const QString &xml);
+ Returnables::SingleStatus* SingleStatus(const QString &xml);
+ Returnables::FeaturedUsers* FeaturedUsers(const QString &xml);
+ Returnables::VerifyCredentials* VerifyCredentials(const QString &xml);
+ Returnables::TwitterUp* TwitterUp(const QString &xml);
+ Returnables::UserTimeline* UserTimeline(const QString &xml);
+ Returnables::Favorites* Favorites(const QString &xml);
+ Returnables::NewStatus* NewStatus(const QString &xml);
+ Returnables::RecentMentions* RecentMentions(const QString &xml);
+ Returnables::RemoveStatus* RemoveStatus(const QString &xml);
+ Returnables::Friends* Friends(const QString &xml);
+ Returnables::Followers* Followers(const QString &xml);
+ Returnables::UserDetails* UserDetails(const QString &xml);
+ Returnables::SentDirectMessages* SentDirectMessages(const QString &xml);
+ Returnables::ReceivedDirectMessages* ReceivedDirectMessages(const QString &xml);
+ Returnables::SendDirectMessage* SendDirectMessage(const QString &xml);
+ Returnables::RemoveDirectMessage* RemoveDirectMessage(const QString &xml);
+ Returnables::AddFriendship* AddFriendShip(const QString &xml);
+ Returnables::RemoveFriendship* RemoveFriendship(const QString &xml);
+ Returnables::FriendshipExist* FriendshipExist(const QString &xml);
+ Returnables::DeliveryDevice* DeliveryDevice(const QString &xml);
+ Returnables::ApiRequests* ApiRequests(const QString &xml);
+ Returnables::AddFavorite* AddFavorite(const QString &xml);
+ Returnables::RemoveFavorite* RemoveFavorite(const QString &xml);
+ Returnables::ProfileColors* ProfileColors(const QString &xml);
+ Returnables::ProfileImage* ProfileImage(const QString &xml);
+ Returnables::ProfileBackgroundImage* ProfileBackgroundImage(const QString &xml);
+ Returnables::Profile* Profile(const QString &xml);
+ Returnables::EnableNotifications* EnableNotifications(const QString &xml);
+ Returnables::DisableNotifications* DisableNotifications(const QString &xml);
+ Returnables::BlockUser* BlockUser(const QString &xml);
+ Returnables::UnBlockUser* UnBlockUser(const QString &xml);
+ Returnables::FriendsIDs* FriendsIDs(const QString &xml);
+ Returnables::FollowersIDs* FollowersIDs(const QString &xml);
+
+ private:
+ enum Parent { USER, STATUS };
+ QLinkedList GetStatusElementList(const QString &xml);
+ QLinkedList GetBasicUserInfoElementList(const QString &xml);
+ QLinkedList GetExtUserInfoElementList(const QString &xml);
+ QLinkedList GetIDsList(const QString &xml);
+ QLinkedList GetDirectMessageList(const QString &xml);
+
+ void Populate_seStatus(Returnables::seStatus &status, const QDomElement &node);
+ void Populate_biStatus(Returnables::biStatus &status, const QDomElement &node);
+ void PopulateUser(Returnables::User &user, const QDomElement &node);
+ void PopulateDetails(Returnables::Details &details, const QDomElement &node);
+ void PopulateDirectHeader(Returnables::DirectHeader &header, const QDomElement &node);
+ void PopulateApiRequests(Returnables::ApiRequests &apiRequests, const QDomElement &node);
+
+ private:
+ static QString nStatus;
+ static QString nCreatedAt;
+ static QString nId;
+ static QString nText;
+ static QString nSource;
+ static QString nTruncated;
+ static QString nInReplyToStatusId;
+ static QString nInReplyToUserId;
+ static QString nFavorited;
+ static QString nUser;
+ static QString nName;
+ static QString nScreenName;
+ static QString nDescription;
+ static QString nLocation;
+ static QString nProfileImageUrl;
+ static QString nUrl;
+ static QString nProtected;
+ static QString nFollowersCount;
+ static QString nOk;
+ static QString nProfileBackgroundColor;
+ static QString nProfileTextColor;
+ static QString nProfileLinkColor;
+ static QString nProfileSidebarFillColor;
+ static QString nProfileSidebarBorderColor;
+ static QString nFriendsCount;
+ static QString nFavoritesCount;
+ static QString nUtcOffset;
+ static QString nTimeZone;
+ static QString nProfileBackgroundImageUrl;
+ static QString nProfileBackgroundTiled;
+ static QString nStatusesCount;
+ static QString nDirectMessage;
+ static QString nSenderId;
+ static QString nRecipientId;
+ static QString nSenderScreenName;
+ static QString nRecipientScreenName;
+ static QString nSender;
+ static QString nRecipient;
+ static QString nFriends;
+ static QString nHash;
+ static QString nResetTime;
+ static QString nResetTimeSeconds;
+ static QString nRemainingHits;
+ static QString nHourlyLimit;
+ static QString nInReplyToScreenName;
+ static QString nFollowing;
+ static QString nNotifications;
+ static QString nID;
+};
+
+
+#endif //Decipher_H
Index: mythplugins/mythtwitter/mythtwitter/mythtwittercore.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwittercore.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwittercore.cpp (revision 0)
@@ -0,0 +1,1057 @@
+#include "mythtwittercore.h"
+#include "mythtwitterdecipher.h"
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+//=====================================================================
+QString Core::TWITTER_HOST = gContext->GetSetting(
+ "mythtwitter.TwitterHost", "twitter.com");
+QString Core::VERIFY_CREDENTIALS_URL = "/account/verify_credentials.xml";
+QString Core::PUBLIC_TIMELINE_URL = "/statuses/public_timeline.xml";
+QString Core::GET_SINGLE_STATUS_URL = "/statuses/show/[req-id].xml";
+QString Core::FEATURED_USERS_URL = "/statuses/featured.xml";
+QString Core::LOGOUT_URL = "/account/end_session";
+QString Core::IS_TWITTER_UP_URL = "/help/test.xml";
+QString Core::USERS_TIMELINE_URL = "/statuses/user_timeline[/opt-user].xml";
+QString Core::GET_FAVORITES_URL = "/favorites[/opt-user].xml";
+QString Core::FRIENDS_TIMELINE_URL = "/statuses/friends_timeline.xml";
+QString Core::POST_NEW_STATUS_URL = "/statuses/update.xml";
+QString Core::GET_MENTIONS_URL = "/statuses/mentions.xml";
+QString Core::REMOVE_STATUS_URL = "/statuses/destroy/[req-id].xml";
+QString Core::GET_FRIENDS_URL = "/statuses/friends[/opt-user].xml";
+QString Core::GET_FOLLOWERS_URL = "/statuses/followers[/opt-user].xml";
+QString Core::GET_USER_DETAILS_URL = "/users/show[/req-user].xml";
+QString Core::GET_SENT_DIRECT_MESSAGES_URL = "/direct_messages/sent.xml";
+QString Core::GET_RECEIVED_DIRECT_MESSAGES_URL = "/direct_messages.xml";
+QString Core::SEND_NEW_DIRECT_MESSAGE_URL = "/direct_messages/new.xml";
+QString Core::REMOVE_DIRECT_MESSAGE_URL = "/direct_messages/destroy/[req-id].xml";
+QString Core::CREATE_FRIENDSHIP_URL = "/friendships/create/[req-user].xml";
+QString Core::REMOVE_FRIENDSHIP_URL = "/friendships/destroy/[req-user].xml";
+QString Core::FRIENDSHIP_EXIST_URL = QString("http://%1/friendships/exists.xml").arg(Core::TWITTER_HOST);
+QString Core::UPDATE_DELIVERY_DEVICE_URL = "/account/update_delivery_device.xml";
+QString Core::REMAINING_API_REQUESTS_URL = "/account/rate_limit_status.xml";
+QString Core::ADD_FAVORITE_URL = "/favorites/create/[req-id].xml";
+QString Core::REMOVE_FAVORITE_URL = "/favorites/destroy/[req-id].xml";
+QString Core::PROFILE_COLORS_URL = "/account/update_profile_colors.xml";
+QString Core::PROFILE_IMAGE_URL = "/account/update_profile_image.xml";
+QString Core::PROFILE_BACKGROUND_IMAGE_URL = "/account/update_profile_background_image.xml";
+QString Core::PROFILE_URL = "/account/update_profile.xml";
+QString Core::ENABLE_NOTIFICATIONS_URL = "/notifications/follow/[req-id].xml";
+QString Core::DISABLE_NOTIFICATIONS_URL = "/notifications/leave/[req-id].xml";
+QString Core::BLOCK_USER_URL = "/blocks/create/[req-id].xml";
+QString Core::UNBLOCK_USER_URL = "/blocks/destroy/[req-id].xml";
+QString Core::FRIENDS_IDS_URL = "/friends/ids[/req-id].xml";
+QString Core::FOLLOWERS_IDS_URL = "/followers/ids[/req-id].xml";
+//=====================================================================
+Core::Core()
+{
+ VERBOSE(VB_IMPORTANT|VB_EXTRA, QString("Connecting to host %1").arg(TWITTER_HOST));
+ m_eventLoop = new QEventLoop(this);
+ if (TWITTER_HOST.startsWith("identi.ca"))
+ m_http = new QHttp(TWITTER_HOST, QHttp::ConnectionModeHttps);
+ else
+ m_http = new QHttp(TWITTER_HOST);
+
+ MakeConnections();
+}
+//=====================================================================
+Core::~Core()
+{
+ if(m_eventLoop)
+ delete m_eventLoop;
+ if(m_http)
+ delete m_http;
+}
+//=====================================================================
+void Core::SetProxy(SERVER::PROXY_TYPE type, const QString hostName, \
+ quint16 port, const QString user, const QString password)
+{
+ QNetworkProxy::ProxyType proxy_type = QNetworkProxy::NoProxy;
+ switch(type)
+ {
+ case SERVER::NO_PROXY:
+ proxy_type = QNetworkProxy::NoProxy;
+ break;
+ case SERVER::SOCKS5_PROXY:
+ proxy_type = QNetworkProxy::Socks5Proxy;
+ break;
+ case SERVER::HTTP_PROXY:
+ proxy_type = QNetworkProxy::HttpProxy;
+ break;
+ }
+
+ QNetworkProxy m_proxy = QNetworkProxy(proxy_type, hostName, port, user, password);
+ m_http->setProxy(m_proxy);
+}
+//=====================================================================
+void Core::Abort()
+{
+ m_http->abort();
+}
+//=====================================================================
+void Core::MakeConnections()
+{
+ connect(m_http, SIGNAL(dataReadProgress(int, int)), this, SLOT(DataReadProgress(int, int)));
+ connect(m_http, SIGNAL(requestStarted(int)), this, SLOT(RequestStarted(int)));
+ connect(m_http, SIGNAL(requestFinished(int,bool)), this, SLOT(ReqFinished(int, bool)));
+ connect(m_http, SIGNAL(done(bool)), this, SLOT(Done(bool)));
+ connect(this, SIGNAL(QueryDone()), m_eventLoop, SLOT(quit()));
+}
+//=====================================================================
+void Core::Done ( bool /*error*/ )
+{
+ emit QueryDone();
+}
+//=====================================================================
+void Core::DataReadProgress ( int /*done*/, int /*total*/ )
+{
+ //emit OnMessageReceived(QString::number(done).toStdString()+" / "+QString::number(total).toStdString());
+}
+//=====================================================================
+int Core::MakeGetRequest(QString req,Returnables::RequestId reqId)
+{
+ if (TWITTER_HOST.startsWith("identi.ca"))
+ req.prepend("/api");
+
+ VERBOSE(VB_IMPORTANT|VB_EXTRA, QString("Connecting to %1").arg(req));
+ int id;
+ QBuffer *tempBuffer = new QBuffer;
+ tempBuffer->open(QIODevice::ReadWrite);
+ id = m_http->get(req,tempBuffer);
+ m_buffer[id].buffer = tempBuffer;
+ m_buffer[id].requestid = reqId;
+ return id;
+}
+//=====================================================================
+int Core::MakePostRequest(QString path,QByteArray req,Returnables::RequestId reqId, bool isMultipart)
+{
+ if (TWITTER_HOST.startsWith("identi.ca"))
+ path.prepend("/api");
+
+ int id;
+ QBuffer *tempBuffer = new QBuffer;
+ tempBuffer->open(QIODevice::ReadWrite);
+
+ if(isMultipart)
+ {
+ id = m_http->request(header, req, tempBuffer);
+ } else {
+ id = m_http->post(path,req,tempBuffer);
+ }
+ m_buffer[id].buffer = tempBuffer;
+ m_buffer[id].requestid = reqId;
+ return id;
+}
+//=====================================================================
+void Core::RequestStarted(int /*id*/)
+{}
+//=====================================================================
+void Core::ReqFinished(int id, bool error)
+{
+ if (error)
+ {
+ VERBOSE(VB_IMPORTANT, QString("Errored on connection with "
+ "string %1").arg(m_http->errorString()));
+ }
+
+ QString response;
+ QHttpResponseHeader head;
+
+ if(error)
+ {
+ emit OnErrorString(m_http->errorString());
+ emit OnError(m_http->error());
+ }
+
+ if(m_buffer[id].buffer)
+ response = QString(m_buffer[id].buffer->data());
+ else
+ response = QString::null;
+
+ if(!response.isNull())
+ {
+ head = m_http->lastResponse();
+ if(head.isValid())
+ responseHeaderReceived(head);
+
+ switch(m_buffer[id].requestid)
+ {
+ case Returnables::PUBLIC_TIMELINE:
+ Returnables::PublicTimeline *pTimeline;
+ pTimeline = Decipher::Instance()->PublicTimeline(response);
+ emit OnResponseReceived(pTimeline);
+ break;
+ case Returnables::FRIENDS_TIMELINE:
+ Returnables::FriendsTimeline *fTimeline;
+ fTimeline = Decipher::Instance()->FriendsTimeline(response);
+ emit OnResponseReceived(fTimeline);
+ break;
+ case Returnables::SINGLE_STATUS:
+ Returnables::SingleStatus *singleStatus;
+ singleStatus = Decipher::Instance()->SingleStatus(response);
+ emit OnResponseReceived(singleStatus);
+ break;
+ case Returnables::FEATURED_USERS:
+ Returnables::FeaturedUsers *featuredUsers;
+ featuredUsers = Decipher::Instance()->FeaturedUsers(response);
+ emit OnResponseReceived(featuredUsers);
+ break;
+ case Returnables::VERIFY_CREDENTIALS:
+ Returnables::VerifyCredentials *verifyCredentials;
+ verifyCredentials = Decipher::Instance()->VerifyCredentials(response);
+ emit OnResponseReceived(verifyCredentials);
+ break;
+ case Returnables::TWITTER_UP:
+ Returnables::TwitterUp *twitterUp;
+ twitterUp = Decipher::Instance()->TwitterUp(response);
+ emit OnResponseReceived(twitterUp);
+ break;
+ case Returnables::USER_TIMELINE:
+ Returnables::UserTimeline *userTimeline;
+ userTimeline = Decipher::Instance()->UserTimeline(response);
+ emit OnResponseReceived(userTimeline);
+ break;
+ case Returnables::FAVORITES:
+ Returnables::Favorites *favorites;
+ favorites = Decipher::Instance()->Favorites(response);
+ emit OnResponseReceived(favorites);
+ break;
+ case Returnables::NEW_STATUS:
+ Returnables::NewStatus *newStatus;
+ newStatus = Decipher::Instance()->NewStatus(response);
+ emit OnResponseReceived(newStatus);
+ break;
+ case Returnables::RECENT_MENTIONS:
+ Returnables::RecentMentions *mentions;
+ mentions = Decipher::Instance()->RecentMentions(response);
+ emit OnResponseReceived(mentions);
+ break;
+ case Returnables::REMOVE_STATUS:
+ Returnables::RemoveStatus *removedStatus;
+ removedStatus = Decipher::Instance()->RemoveStatus(response);
+ emit OnResponseReceived(removedStatus);
+ break;
+ case Returnables::FRIENDS:
+ Returnables::Friends *friends;
+ friends = Decipher::Instance()->Friends(response);
+ emit OnResponseReceived(friends);
+ break;
+ case Returnables::FOLLOWERS:
+ Returnables::Followers *followers;
+ followers = Decipher::Instance()->Followers(response);
+ emit OnResponseReceived(followers);
+ break;
+ case Returnables::USER_DETAILS:
+ Returnables::UserDetails *userDetails;
+ userDetails = Decipher::Instance()->UserDetails(response);
+ emit OnResponseReceived(userDetails);
+ break;
+ case Returnables::SENT_DIRECT_MESSAGES:
+ Returnables::SentDirectMessages *sentDirectMessages;
+ sentDirectMessages = Decipher::Instance()->SentDirectMessages(response);
+ emit OnResponseReceived(sentDirectMessages);
+ break;
+ case Returnables::RECEIVED_DIRECT_MESSAGES:
+ Returnables::ReceivedDirectMessages *receivedDirectMessages;
+ receivedDirectMessages = Decipher::Instance()->ReceivedDirectMessages(response);
+ emit OnResponseReceived(receivedDirectMessages);
+ break;
+ case Returnables::SEND_DIRECT_MESSAGE:
+ Returnables::SendDirectMessage *sendDirectMessage;
+ sendDirectMessage = Decipher::Instance()->SendDirectMessage(response);
+ emit OnResponseReceived(sendDirectMessage);
+ break;
+ case Returnables::REMOVE_DIRECT_MESSAGE:
+ Returnables::RemoveDirectMessage *removeDirectMessage;
+ removeDirectMessage = Decipher::Instance()->RemoveDirectMessage(response);
+ emit OnResponseReceived(removeDirectMessage);
+ break;
+ case Returnables::ADD_FRIENDSHIP:
+ Returnables::AddFriendship *addFriendship;
+ addFriendship = Decipher::Instance()->AddFriendShip(response);
+ emit OnResponseReceived(addFriendship);
+ break;
+ case Returnables::REMOVE_FRIENDSHIP:
+ Returnables::RemoveFriendship *removeFriendship;
+ removeFriendship = Decipher::Instance()->RemoveFriendship(response);
+ emit OnResponseReceived(removeFriendship);
+ break;
+ case Returnables::FRIENDSHIP_EXISTS:
+ Returnables::FriendshipExist *friendshipExists;
+ friendshipExists = Decipher::Instance()->FriendshipExist(response);
+ emit OnResponseReceived(friendshipExists);
+ break;
+ case Returnables::DELIVERY_DEVICE:
+ Returnables::DeliveryDevice *deliveryDevice;
+ deliveryDevice = Decipher::Instance()->DeliveryDevice(response);
+ emit OnResponseReceived(deliveryDevice);
+ break;
+ case Returnables::API_REQUESTS:
+ Returnables::ApiRequests *apiRequests;
+ apiRequests = Decipher::Instance()->ApiRequests(response);
+ emit OnResponseReceived(apiRequests);
+ break;
+ case Returnables::ADD_FAVORITE:
+ Returnables::AddFavorite *addFavorite;
+ addFavorite = Decipher::Instance()->AddFavorite(response);
+ emit OnResponseReceived(addFavorite);
+ break;
+ case Returnables::REMOVE_FAVORITE:
+ Returnables::RemoveFavorite *removeFavorite;
+ removeFavorite = Decipher::Instance()->RemoveFavorite(response);
+ emit OnResponseReceived(removeFavorite);
+ break;
+ case Returnables::PROFILE_COLORS:
+ Returnables::ProfileColors *profileColors;
+ profileColors = Decipher::Instance()->ProfileColors(response);
+ emit OnResponseReceived(profileColors);
+ break;
+ case Returnables::PROFILE_IMAGE:
+ Returnables::ProfileImage *profileImage;
+ profileImage = Decipher::Instance()->ProfileImage(response);
+ emit OnResponseReceived(profileImage);
+ break;
+ case Returnables::PROFILE_BACKGROUND_IMAGE:
+ Returnables::ProfileBackgroundImage *profileBackgroundImage;
+ profileBackgroundImage = Decipher::Instance()->ProfileBackgroundImage(response);
+ emit OnResponseReceived(profileBackgroundImage);
+ break;
+ case Returnables::PROFILE:
+ Returnables::Profile *profile;
+ profile = Decipher::Instance()->Profile(response);
+ emit OnResponseReceived(profile);
+ break;
+ case Returnables::ENABLE_NOTIFICATIONS:
+ Returnables::EnableNotifications *enableNotifications;
+ enableNotifications = Decipher::Instance()->EnableNotifications(response);
+ emit OnResponseReceived(enableNotifications);
+ break;
+ case Returnables::DISABLE_NOTIFICATIONS:
+ Returnables::DisableNotifications *disableNotifications;
+ disableNotifications = Decipher::Instance()->DisableNotifications(response);
+ emit OnResponseReceived(disableNotifications);
+ break;
+ case Returnables::BLOCK_USER:
+ Returnables::BlockUser *blockUser;
+ blockUser = Decipher::Instance()->BlockUser(response);
+ emit OnResponseReceived(blockUser);
+ break;
+ case Returnables::UNBLOCK_USER:
+ Returnables::UnBlockUser *unBlockUser;
+ unBlockUser = Decipher::Instance()->UnBlockUser(response);
+ emit OnResponseReceived(unBlockUser);
+ break;
+ case Returnables::FRIENDS_IDS:
+ Returnables::FriendsIDs *friendsIDs;
+ friendsIDs = Decipher::Instance()->FriendsIDs(response);
+ emit OnResponseReceived(friendsIDs);
+ break;
+ case Returnables::FOLLOWERS_IDS:
+ Returnables::FollowersIDs *followersIDs;
+ followersIDs = Decipher::Instance()->FollowersIDs(response);
+ emit OnResponseReceived(followersIDs);
+ break;
+ default:
+ emit OnMessageReceived(response);
+ }
+ }
+
+ if(m_buffer[id].buffer)
+ {
+ m_buffer[id].buffer->close();
+ delete m_buffer[id].buffer;
+ m_buffer[id].buffer = NULL;
+ }
+}
+//=====================================================================
+void Core::responseHeaderReceived(const QHttpResponseHeader &resp)
+{
+ switch(resp.statusCode())
+ {
+ case SERVER::OK:
+ emit OnStatusReceived(SERVER::OK);
+ break;
+ case SERVER::NOT_MODIFIED:
+ emit OnStatusReceived(SERVER::NOT_MODIFIED);
+ break;
+ case SERVER::BAD_REQUEST:
+ emit OnStatusReceived(SERVER::BAD_REQUEST);
+ break;
+ case SERVER::NOT_AUTHORIZED:
+ emit OnStatusReceived(SERVER::NOT_AUTHORIZED);
+ break;
+ case SERVER::FORBIDDEN:
+ emit OnStatusReceived(SERVER::FORBIDDEN);
+ break;
+ case SERVER::NOT_FOUND:
+ emit OnStatusReceived(SERVER::NOT_FOUND);
+ break;
+ case SERVER::INTERNAL_SERVER_ERROR:
+ emit OnStatusReceived(SERVER::INTERNAL_SERVER_ERROR);
+ break;
+ case SERVER::BAD_GATEWAY:
+ emit OnStatusReceived(SERVER::BAD_GATEWAY);
+ break;
+ case SERVER::SERVICE_UNAVAILABLE:
+ emit OnStatusReceived(SERVER::SERVICE_UNAVAILABLE);
+ break;
+ default:
+ emit OnStatusReceived(SERVER::UNKNOWN);
+ break;
+ }
+}
+//=====================================================================
+void Core::GetPublicTimeline()
+{
+ MakeGetRequest(PUBLIC_TIMELINE_URL,Returnables::PUBLIC_TIMELINE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetSingleStatus(QString id)
+{
+ QString req;
+ req = GET_SINGLE_STATUS_URL;
+ req.replace("[req-id]",id);
+ MakeGetRequest(req,Returnables::SINGLE_STATUS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFeaturedUsers()
+{
+ MakeGetRequest(FEATURED_USERS_URL,Returnables::FEATURED_USERS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::Login(QString user, QString passw)
+{
+ m_http->setUser(user, passw);
+ VerifyCredentials();
+}
+//=====================================================================
+void Core::Logout()
+{
+ m_http->setUser("","");
+ MakePostRequest(LOGOUT_URL,"",Returnables::LOGOUT);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::SetLoginInfo(QString user, QString passw)
+{
+ m_http->setUser(user, passw);
+}
+//=====================================================================
+void Core::IsTwitterUp()
+{
+ MakeGetRequest(IS_TWITTER_UP_URL,Returnables::TWITTER_UP);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetUsersTimeline(SERVER::Option2 *opt /*=NULL*/)
+{
+ QString buildUrl = USERS_TIMELINE_URL;
+
+ if(opt)
+ {
+ QString id = opt->id;
+ QString user_id = QString::number(opt->user_id);
+ QString screen_name = opt->screen_name;
+ QString since_id = QString::number(opt->since_id);
+ QString max_id = QString::number(opt->max_id);
+ QString page = QString::number(opt->page);
+
+ if(!id.isEmpty())
+ buildUrl.replace("[/opt-user]","/"+id);
+ else
+ buildUrl.replace("[/opt-user]","");
+
+ buildUrl += "?user_id="+user_id;
+ buildUrl += "&screen_name="+screen_name;
+ buildUrl += "&since_id="+since_id;
+ buildUrl += "&max_id="+max_id;
+ buildUrl += "&page="+page;
+ }
+ else
+ {
+ buildUrl.replace("[/opt-user]","");
+ }
+
+ MakeGetRequest(buildUrl,Returnables::USER_TIMELINE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFavorites(QString user /*=""*/, unsigned int page /*=1*/)
+{
+ QString buildUrl = GET_FAVORITES_URL;
+
+ if(!user.isEmpty())
+ buildUrl.replace("[/opt-user]","/"+user);
+ else
+ buildUrl.replace("[/opt-user]","");
+
+ buildUrl += "?page="+QString::number(page);
+
+ MakeGetRequest(buildUrl,Returnables::FAVORITES);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFriendsTimeline(SERVER::Option1 *opt /*=NULL*/)
+{
+ QString buildUrl = FRIENDS_TIMELINE_URL;
+
+ if(opt)
+ {
+ QString since_id = QString::number(opt->since_id);
+ QString max_id = QString::number(opt->max_id);
+ QString count = QString::number(opt->count);
+ QString page = QString::number(opt->page);
+
+ buildUrl += "&since_id="+since_id;
+ buildUrl += "&max_id="+max_id;
+ buildUrl += "&count="+count;
+ buildUrl += "&page="+page;
+ }
+
+ MakeGetRequest(buildUrl,Returnables::FRIENDS_TIMELINE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::PostNewStatus(QString status, QString in_reply_to_status_id, QString source)
+{
+ QByteArray encodedUrl, req;
+ encodedUrl = QUrl::toPercentEncoding(status);
+
+ req = "status=";
+ req += encodedUrl;
+
+ if(!in_reply_to_status_id.isEmpty())
+ {
+ req += "&in_reply_to_status_id=";
+ req += in_reply_to_status_id;
+ }
+
+ if(!source.isEmpty())
+ {
+ req += "&source=";
+ req += source;
+ }
+
+ MakePostRequest(POST_NEW_STATUS_URL,req,Returnables::NEW_STATUS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetRecentMentions(SERVER::Option3 *opt /*=NULL*/)
+{
+ QString buildUrl = GET_MENTIONS_URL;
+
+ if(opt)
+ {
+ QString since_id = QString::number(opt->since_id);
+ QString max_id = QString::number(opt->max_id);
+ QString page = QString::number(opt->page);
+
+ buildUrl += "?since_id="+since_id;
+ buildUrl += "&max_id="+max_id;
+ buildUrl += "&page="+page;
+ }
+
+ MakeGetRequest(buildUrl,Returnables::RECENT_MENTIONS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::RemoveStatus(QString id)
+{
+ QString buildUrl = REMOVE_STATUS_URL;
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::REMOVE_STATUS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFriends(SERVER::Option4 *opt /*=NULL*/)
+{
+ QString buildUrl = GET_FRIENDS_URL;
+
+ if(opt)
+ {
+ QString id = opt->id;
+ QString user_id = QString::number(opt->user_id);
+ QString screen_name = opt->screen_name;
+ QString page = QString::number(opt->page);
+
+ if(!id.isEmpty())
+ buildUrl.replace("[/opt-user]","/"+id);
+ else
+ buildUrl.replace("[/opt-user]","");
+
+ buildUrl += "?user_id="+user_id;
+ buildUrl += "&screen_name="+screen_name;
+ buildUrl += "&page="+page;
+ }
+ else
+ {
+ buildUrl.replace("[/opt-user]","");
+ }
+
+ MakeGetRequest(buildUrl,Returnables::FRIENDS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFollowers(SERVER::Option4 *opt /*=NULL*/)
+{
+ QString buildUrl = GET_FOLLOWERS_URL;
+
+ if(opt)
+ {
+ QString id = opt->id;
+ QString user_id = QString::number(opt->user_id);
+ QString screen_name = opt->screen_name;
+ QString page = QString::number(opt->page);
+
+ if(!id.isEmpty())
+ buildUrl.replace("[/opt-user]","/"+id);
+ else
+ buildUrl.replace("[/opt-user]","");
+
+ buildUrl += "?user_id="+user_id;
+ buildUrl += "&screen_name="+screen_name;
+ buildUrl += "&page="+page;
+ }
+ else
+ {
+ buildUrl.replace("[/opt-user]","");
+ }
+
+ MakeGetRequest(buildUrl,Returnables::FOLLOWERS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetUserDetails(QString id, QString user_id, QString screen_name)
+{
+ if( !id.isEmpty() || !user_id.isEmpty() || !screen_name.isEmpty() )
+ {
+ QString buildUrl = GET_USER_DETAILS_URL;
+
+ if(!id.isEmpty())
+ {
+ buildUrl.replace("[/req-user]", "/" + id);
+ }
+ else if(!user_id.isEmpty())
+ {
+ buildUrl.replace("[/req-user]", "");
+ buildUrl += "?user_id=" + user_id;
+ }
+ else if(!screen_name.isEmpty())
+ {
+ buildUrl.replace("[/req-user]", "");
+ buildUrl += "?screen_name=" + screen_name;
+ }
+
+ MakeGetRequest(buildUrl,Returnables::USER_DETAILS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+ }
+}
+//=====================================================================
+void Core::GetSentDirectMessages(SERVER::Option5 *opt /*=NULL*/)
+{
+ QString buildUrl = GET_SENT_DIRECT_MESSAGES_URL;
+
+ if(opt)
+ {
+ QString since_id = QString::number(opt->since_id);
+ QString page = QString::number(opt->page);
+
+ buildUrl += "&since_id="+since_id;
+ buildUrl += "&page="+page;
+ }
+
+ MakeGetRequest(buildUrl,Returnables::SENT_DIRECT_MESSAGES);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetReceivedDirectMessages(SERVER::Option5 *opt /*=NULL*/)
+{
+ QString buildUrl = GET_RECEIVED_DIRECT_MESSAGES_URL;
+
+ if(opt)
+ {
+ QString since_id = QString::number(opt->since_id);
+ QString page = QString::number(opt->page);
+
+ buildUrl += "&since_id="+since_id;
+ buildUrl += "&page="+page;
+ }
+
+ MakeGetRequest(buildUrl,Returnables::RECEIVED_DIRECT_MESSAGES);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::SendDirectMessage(QString user, QString text)
+{
+ QByteArray encodedText, req;
+ encodedText = QUrl::toPercentEncoding(text);
+
+ req = "user=";
+ req += user.toAscii();
+ req += "&";
+ req += "text=";
+ req += encodedText;
+
+ MakePostRequest(SEND_NEW_DIRECT_MESSAGE_URL,req,Returnables::SEND_DIRECT_MESSAGE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=================================================================================================================
+void Core::RemoveDirectMessage(QString id)
+{
+ QString buildUrl = REMOVE_DIRECT_MESSAGE_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::REMOVE_DIRECT_MESSAGE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::AddFriendship(QString user, bool follow)
+{
+ QByteArray req;
+ QString buildUrl;
+
+ buildUrl = CREATE_FRIENDSHIP_URL;
+ buildUrl = buildUrl.replace("[req-user]",user);
+
+ req = "follow=";
+ req += follow ? "true" : "false";
+
+ MakePostRequest(buildUrl,req,Returnables::ADD_FRIENDSHIP);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::RemoveFriendship(QString user)
+{
+ QString buildUrl = REMOVE_FRIENDSHIP_URL;
+
+ buildUrl = buildUrl.replace("[req-user]",user);
+
+ MakePostRequest(buildUrl,"",Returnables::REMOVE_FRIENDSHIP);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::FriendshipExist(QString user_a, QString user_b)
+{
+ QString buildUrl = FRIENDSHIP_EXIST_URL;
+
+ buildUrl += "?user_a="+user_a;
+ buildUrl += "&user_b="+user_b;
+
+ MakeGetRequest(buildUrl,Returnables::FRIENDSHIP_EXISTS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::VerifyCredentials()
+{
+ MakeGetRequest(VERIFY_CREDENTIALS_URL,Returnables::VERIFY_CREDENTIALS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::UpdateDeliveryDevice(SERVER::DEVICES device)
+{
+ QByteArray req;
+
+ switch(device)
+ {
+ case SERVER::SMS:
+ req = "device=sms";
+ break;
+ case SERVER::IM:
+ req = "device=im";
+ break;
+ case SERVER::NONE:
+ req = "device=none";
+ break;
+ }
+
+ MakePostRequest(UPDATE_DELIVERY_DEVICE_URL,req,Returnables::DELIVERY_DEVICE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::RemainingApiRequests()
+{
+ MakeGetRequest(REMAINING_API_REQUESTS_URL,Returnables::API_REQUESTS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::AddFavorite(QString id)
+{
+ QString buildUrl = ADD_FAVORITE_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::ADD_FAVORITE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::RemoveFavorite(QString id)
+{
+ QString buildUrl = REMOVE_FAVORITE_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::REMOVE_FAVORITE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::UpdateProfileColors(QString background_color, QString text_color, QString link_color, QString sidebar_fill_color, QString sidebar_border_color)
+{
+ QByteArray req = "";
+
+ if(!background_color.isEmpty())
+ {
+ req = "profile_background_color=";
+ req += background_color.remove("#").toAscii();
+ req += "&";
+ }
+ if(!text_color.isEmpty())
+ {
+ req += "profile_text_color=";
+ req += text_color.remove("#").toAscii();
+ req += "&";
+ }
+ if(!link_color.isEmpty())
+ {
+ req += "profile_link_color=";
+ req += link_color.remove("#").toAscii();
+ req += "&";
+ }
+ if(!sidebar_fill_color.isEmpty())
+ {
+ req += "profile_sidebar_fill_color=";
+ req += sidebar_fill_color.remove("#").toAscii();
+ req += "&";
+ }
+ if(!sidebar_border_color.isEmpty())
+ {
+ req += "profile_sidebar_border_color=";
+ req += sidebar_border_color.remove("#").toAscii();
+ }
+
+ if(req.endsWith("&")){ req.chop(1); }
+
+ MakePostRequest(PROFILE_COLORS_URL,req,Returnables::PROFILE_COLORS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::UpdateProfile(QString name, QString email, QString url, QString location, QString description)
+{
+ QByteArray req = "";
+
+ if(!name.isEmpty())
+ {
+ req = "name=";
+ req += QUrl::toPercentEncoding(name);
+ req += "&";
+ }
+ if(!email.isEmpty())
+ {
+ req += "email=";
+ req += QUrl::toPercentEncoding(email);
+ req += "&";
+ }
+ if(!url.isEmpty())
+ {
+ req += "url=";
+ req += QUrl::toPercentEncoding(url);
+ req += "&";
+ }
+ if(!location.isEmpty())
+ {
+ req += "location=";
+ req += QUrl::toPercentEncoding(location);
+ req += "&";
+ }
+ if(!description.isEmpty())
+ {
+ req += "description=";
+ req += QUrl::toPercentEncoding(description);
+ }
+
+ if(req.endsWith("&")){ req.chop(1); }
+
+ MakePostRequest(PROFILE_URL,req,Returnables::PROFILE);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::UpdateProfileImage(QString image)
+{
+ QByteArray req;
+
+ QFile file(image);
+ file.open(QIODevice::ReadOnly);
+
+ QString filename = file.fileName();
+ int pos = filename.lastIndexOf("/");
+ filename.remove(0, pos + 1);
+
+ QByteArray boundary = filename.toUtf8().toBase64();
+
+ header.setRequest("POST", PROFILE_IMAGE_URL, 1, 1);
+ header.setValue("Host", TWITTER_HOST);
+ header.setValue("Connection", "keep-alive");
+ header.setValue("Content-Type", "multipart/form-data; boundary=" + boundary);
+
+ req.append("--" + boundary + "\r\n");
+ req += "Content-Disposition: ";
+ req += "form-data; name=\"image\"; filename=\"" + filename.toUtf8() + "\"\r\n";
+ req += "Content-Type: image/png\r\n";
+ req += "\r\n";
+ req += file.readAll();
+ req += "\r\n";
+ req.append("--" + boundary + "--");
+ req += "\r\n";
+
+ header.setContentLength(req.length());
+
+ file.close();
+ MakePostRequest(PROFILE_IMAGE_URL, req, Returnables::PROFILE_IMAGE, true);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::UpdateProfileBackgroundImage(QString image, QString isTile)
+{
+ QByteArray req;
+ QFile file(image);
+ file.open(QIODevice::ReadOnly);
+
+ QString filename = file.fileName();
+ int pos = filename.lastIndexOf("/");
+ filename.remove(0, pos + 1);
+
+ QByteArray boundary = filename.toUtf8().toBase64();
+
+ header.setRequest("POST", PROFILE_BACKGROUND_IMAGE_URL, 1, 1);
+ header.setValue("Host", TWITTER_HOST);
+ header.setValue("Connection", "keep-alive");
+ header.setValue("Content-Type", "multipart/form-data; boundary=" + boundary);
+
+ req.append("--" + boundary + "\r\n");
+ req += "Content-Disposition: ";
+ req += "form-data; name=\"image\"; filename=\"" + filename.toUtf8() + "\"\r\n";
+ req += "Content-Type: image/png\r\n";
+ req += "\r\n";
+ req += file.readAll();
+ req += "\r\n";
+ req.append("--" + boundary + "\r\n");
+ req += "Content-Disposition: ";
+ req += "form-data; name=\"tile\"\r\n";
+ req += "\r\n";
+ req += isTile;
+ req += "\r\n";
+ req.append("--" + boundary + "--");
+ req += "\r\n";
+
+ header.setContentLength(req.length());
+
+ file.close();
+ MakePostRequest(PROFILE_BACKGROUND_IMAGE_URL, req, Returnables::PROFILE_BACKGROUND_IMAGE, true);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::EnableNotifications(QString id)
+{
+ QString buildUrl = ENABLE_NOTIFICATIONS_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::ENABLE_NOTIFICATIONS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::DisableNotifications(QString id)
+{
+ QString buildUrl = DISABLE_NOTIFICATIONS_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::DISABLE_NOTIFICATIONS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::BlockUser(QString id)
+{
+ QString buildUrl = BLOCK_USER_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::BLOCK_USER);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::UnBlockUser(QString id)
+{
+ QString buildUrl = UNBLOCK_USER_URL;
+
+ buildUrl = buildUrl.replace("[req-id]",id);
+
+ MakePostRequest(buildUrl,"",Returnables::UNBLOCK_USER);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFriendsIDs(QString id, QString user_id, QString screen_name)
+{
+ QString buildUrl = FRIENDS_IDS_URL;
+
+ if(!id.isEmpty())
+ {
+ buildUrl.replace("[/req-id]", "/" + id);
+ }
+ else if(!user_id.isEmpty())
+ {
+ buildUrl.replace("[/req-id]","");
+ buildUrl += "?user_id=" + user_id;
+ }
+ else if(!screen_name.isEmpty())
+ {
+ buildUrl.replace("[/req-id]","");
+ buildUrl += "?screen_name="+screen_name;
+ }
+ else
+ {
+ buildUrl.replace("[/req-id]","");
+ }
+
+ MakeGetRequest(buildUrl, Returnables::FRIENDS_IDS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+void Core::GetFollowersIDs(QString id, QString user_id, QString screen_name)
+{
+ QString buildUrl = FOLLOWERS_IDS_URL;
+
+ if(!id.isEmpty())
+ {
+ buildUrl.replace("[/req-id]", "/" + id);
+ }
+ else if(!user_id.isEmpty())
+ {
+ buildUrl.replace("[/req-id]","");
+ buildUrl += "?user_id=" + user_id;
+ }
+ else if(!screen_name.isEmpty())
+ {
+ buildUrl.replace("[/req-id]","");
+ buildUrl += "?screen_name="+screen_name;
+ }
+ else
+ {
+ buildUrl.replace("[/req-id]","");
+ }
+
+ MakeGetRequest(buildUrl, Returnables::FOLLOWERS_IDS);
+ m_eventLoop->exec(QEventLoop::AllEvents);
+}
+//=====================================================================
+
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterreturnables.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterreturnables.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterreturnables.h (revision 0)
@@ -0,0 +1,447 @@
+#ifndef MythTwitterReturnables_H
+#define MythTwitterReturnables_H
+
+#include
+#include
+#include "mythtwitterserver.h"
+
+namespace Returnables
+{
+ struct User
+ {
+ unsigned int id;
+ QString name;
+ QString screenName;
+ QString description;
+ QString location;
+ QString profileImageUrl;
+ QString url;
+ bool isProtected;
+ unsigned int followersCount;
+ };
+
+ struct Details
+ {
+ QString profileBackgroundColor;
+ QString profileTextColor;
+ QString profileLinkColor;
+ QString profileSidebarFillColor;
+ QString profileSidebarBorderColor;
+ unsigned int friendsCount;
+ QString createdAt;
+ unsigned int favoritesCount;
+ int utcOffset;
+ QString timeZone;
+ QString profileBackgroundImageUrl;
+ bool profileBackgroundTiled;
+ bool following;
+ bool notifications;
+ unsigned int statusesCount;
+ };
+
+//Status for "Status element"
+ struct seStatus
+ {
+ QString createdAt;
+ quint64 id;
+ QString text;
+ QString source;
+ bool truncated;
+ quint64 inReplyToStatusId;
+ quint64 inReplyToUserId;
+ bool favorited;
+ };
+
+//Status for "Basic user information element"
+ struct biStatus
+ {
+ QString createdAt;
+ quint64 id;
+ QString text;
+ QString source;
+ bool truncated;
+ quint64 inReplyToStatusId;
+ quint64 inReplyToUserId;
+ bool favorited;
+ QString inReplyToScreenName;
+ };
+
+ struct DirectHeader
+ {
+ quint64 id;
+ unsigned int senderId;
+ QString text;
+ unsigned int recipientId;
+ QString createdAt;
+ QString senderScreenName;
+ QString recipientScreenName;
+ };
+
+ struct DirectMessageElement
+ {
+ DirectHeader headerInfo;
+ User sender;
+ User recipient;
+ };
+
+//"Status element"
+ struct StatusElement
+ {
+ seStatus status;
+ User user;
+ };
+//"Basic user information element"
+ struct BasicUserInfoElement
+ {
+ biStatus status;
+ User user;
+ };
+//"Extended user information element"
+ struct ExtUserInfoElement
+ {
+ User user;
+ Details details;
+ biStatus status;
+ };
+
+ enum RequestId { PUBLIC_TIMELINE, FRIENDS_TIMELINE, USER_TIMELINE, SINGLE_STATUS, NEW_STATUS,\
+ RECENT_MENTIONS, REMOVE_STATUS, FRIENDS, FOLLOWERS, USER_DETAILS,\
+ RECEIVED_DIRECT_MESSAGES, SENT_DIRECT_MESSAGES, SEND_DIRECT_MESSAGE, REMOVE_DIRECT_MESSAGE,\
+ ADD_FRIENDSHIP, REMOVE_FRIENDSHIP, FRIENDSHIP_EXISTS, FRIENDS_IDS, FOLLOWERS_IDS, VERIFY_CREDENTIALS, LOGOUT,\
+ DELIVERY_DEVICE, PROFILE_COLORS, PROFILE_IMAGE, PROFILE_BACKGROUND_IMAGE,\
+ API_REQUESTS, PROFILE, FAVORITES, ADD_FAVORITE, REMOVE_FAVORITE,\
+ ENABLE_NOTIFICATIONS, DISABLE_NOTIFICATIONS, BLOCK_USER, UNBLOCK_USER,\
+ TWITTER_UP, FEATURED_USERS \
+ };
+
+ class Response
+ {
+ public:
+ Response() {}
+ virtual ~Response() {}
+ RequestId reqID;
+ };
+//Status Methods
+//==================================================================================================
+ class PublicTimeline : public Response
+ {
+ public:
+ PublicTimeline() {}
+ ~PublicTimeline() {}
+ QLinkedList list;
+ };
+ class FriendsTimeline : public Response
+ {
+ public:
+ FriendsTimeline() {}
+ ~FriendsTimeline() {}
+ QLinkedList list;
+ };
+ class UserTimeline : public Response
+ {
+ public:
+ UserTimeline() {}
+ ~UserTimeline() {}
+ QLinkedList list;
+ };
+//show
+ class SingleStatus : public Response
+ {
+ public:
+ SingleStatus() { status = new StatusElement; }
+ ~SingleStatus() { if(status) delete status;}
+ StatusElement *status;
+ };
+//update
+ class NewStatus : public Response
+ {
+ public:
+ NewStatus() { status = new StatusElement; }
+ ~NewStatus() { if(status) delete status; }
+ StatusElement* status;
+ };
+//mentions
+ class RecentMentions : public Response
+ {
+ public:
+ RecentMentions() {}
+ ~RecentMentions() {}
+ QLinkedList list;
+ };
+//destroy
+ class RemoveStatus : public Response
+ {
+ public:
+ RemoveStatus() { status = new StatusElement; }
+ ~RemoveStatus() { if(status) delete status; }
+ StatusElement *status;
+ };
+//==================================================================================================
+
+//User Methods
+//==================================================================================================
+ class Friends : public Response
+ {
+ public:
+ Friends() {}
+ ~Friends() {}
+ QLinkedList list;
+ };
+ class Followers : public Response
+ {
+ public:
+ Followers() {}
+ ~Followers() {}
+ QLinkedList list;
+ };
+//show
+ class UserDetails : public Response
+ {
+ public:
+ UserDetails() { userExt = new ExtUserInfoElement; }
+ ~UserDetails() { if(userExt) delete userExt; }
+ ExtUserInfoElement *userExt;
+ };
+//==================================================================================================
+
+//Direct Message Methods
+//==================================================================================================
+//direct_messages
+ class ReceivedDirectMessages : public Response
+ {
+ public:
+ ReceivedDirectMessages() {}
+ ~ReceivedDirectMessages() {}
+ QLinkedList list;
+ };
+//sent
+ class SentDirectMessages : public Response
+ {
+ public:
+ SentDirectMessages() {}
+ ~SentDirectMessages() {}
+ QLinkedList list;
+ };
+//new
+ class SendDirectMessage : public Response
+ {
+ public:
+ SendDirectMessage() { message = new DirectMessageElement; }
+ ~SendDirectMessage() { if(message) delete message; }
+ DirectMessageElement *message;
+ };
+//destroy
+ class RemoveDirectMessage : public Response
+ {
+ public:
+ RemoveDirectMessage() { message = new DirectMessageElement; }
+ ~RemoveDirectMessage() { if(message) delete message; }
+ DirectMessageElement *message;
+ };
+//==================================================================================================
+
+//Friendship Methods
+//==================================================================================================
+//create
+ class AddFriendship : public Response
+ {
+ public:
+ AddFriendship() { user = new BasicUserInfoElement; }
+ ~AddFriendship() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//destroy
+ class RemoveFriendship : public Response
+ {
+ public:
+ RemoveFriendship() { user = new BasicUserInfoElement; }
+ ~RemoveFriendship() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//exists
+ class FriendshipExist : public Response
+ {
+ public:
+ FriendshipExist() {}
+ ~FriendshipExist() {}
+ bool friends;
+ };
+//==================================================================================================
+
+//Social Graph Methods
+//==================================================================================================
+//friends/ids
+ class FriendsIDs : public Response
+ {
+ public:
+ FriendsIDs() {}
+ ~FriendsIDs() {}
+ QLinkedList list;
+ };
+//followers/ids
+ class FollowersIDs : public Response
+ {
+ public:
+ FollowersIDs() {}
+ ~FollowersIDs() {}
+ QLinkedList list;
+ };
+//==================================================================================================
+
+//Account Methods
+//==================================================================================================
+//verify_credentials
+ class VerifyCredentials : public Response
+ {
+ public:
+ VerifyCredentials() { userExt = new ExtUserInfoElement; }
+ ~VerifyCredentials() { if(userExt) delete userExt; }
+ ExtUserInfoElement *userExt;
+ };
+//update_delivery_device
+ class DeliveryDevice : public Response
+ {
+ public:
+ DeliveryDevice() { user = new BasicUserInfoElement; }
+ ~DeliveryDevice() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//update_profile_colors
+ class ProfileColors : public Response
+ {
+ public:
+ ProfileColors() { userExt = new ExtUserInfoElement; }
+ ~ProfileColors() { if(userExt) delete userExt; }
+ ExtUserInfoElement *userExt;
+ };
+//update_profile_image
+ class ProfileImage : public Response
+ {
+ public:
+ ProfileImage() { userExt = new ExtUserInfoElement; }
+ ~ProfileImage() { if(userExt) delete userExt; }
+ ExtUserInfoElement *userExt;
+ };
+//update_profile_background_image
+ class ProfileBackgroundImage : public Response
+ {
+ public:
+ ProfileBackgroundImage() { userExt = new ExtUserInfoElement; }
+ ~ProfileBackgroundImage() { if(userExt) delete userExt; }
+ ExtUserInfoElement *userExt;
+ };
+//rate_limit_status
+ class ApiRequests : public Response
+ {
+ public:
+ ApiRequests() {}
+ ~ApiRequests() {}
+ QString resetTime;
+ unsigned int resetTimeSeconds;
+ unsigned int remainingHits;
+ unsigned int hourlyLimit;
+ };
+ //update_profile
+ class Profile : public Response
+ {
+ public:
+ Profile() { userExt = new ExtUserInfoElement; }
+ ~Profile() { if(userExt) delete userExt; }
+ ExtUserInfoElement *userExt;
+ };
+//==================================================================================================
+
+//Favorite Methods
+//==================================================================================================
+ class Favorites : public Response
+ {
+ public:
+ Favorites() {}
+ ~Favorites() {}
+ QLinkedList list;
+ };
+//create
+ class AddFavorite : public Response
+ {
+ public:
+ AddFavorite() { status = new StatusElement; }
+ ~AddFavorite() { if(status) delete status; }
+ StatusElement *status;
+ };
+//destroy
+ class RemoveFavorite : public Response
+ {
+ public:
+ RemoveFavorite() { status = new StatusElement; }
+ ~RemoveFavorite() { if(status) delete status;}
+ StatusElement *status;
+ };
+//==================================================================================================
+
+//Notification Methods
+//==================================================================================================
+//follow
+ class EnableNotifications : public Response
+ {
+ public:
+ EnableNotifications() { user = new BasicUserInfoElement; }
+ ~EnableNotifications() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//leave
+ class DisableNotifications : public Response
+ {
+ public:
+ DisableNotifications() { user = new BasicUserInfoElement; }
+ ~DisableNotifications() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//==================================================================================================
+
+//Block Methods
+//==================================================================================================
+//create
+//==================================================================================================
+ class BlockUser : public Response
+ {
+ public:
+ BlockUser() { user = new BasicUserInfoElement; }
+ ~BlockUser() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//destroy
+ class UnBlockUser : public Response
+ {
+ public:
+ UnBlockUser() { user = new BasicUserInfoElement; }
+ ~UnBlockUser() { if(user) delete user; }
+ BasicUserInfoElement *user;
+ };
+//==================================================================================================
+
+//Help Methods
+//==================================================================================================
+//test
+ class TwitterUp : public Response
+ {
+ public:
+ TwitterUp() {}
+ ~TwitterUp() {}
+ bool up;
+ };
+//==================================================================================================
+
+//Not in API
+//==================================================================================================
+ class FeaturedUsers : public Response
+ {
+ public:
+ FeaturedUsers() {}
+ ~FeaturedUsers() {}
+ QLinkedList list;
+ };
+//==================================================================================================
+};
+
+
+#endif //MythTwitterReturnables_H
Index: mythplugins/mythtwitter/mythtwitter/mythtwittercore.h
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwittercore.h (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwittercore.h (revision 0)
@@ -0,0 +1,141 @@
+#ifndef MythTwitterCore_H
+#define MythTwitterCore_H
+
+#include
+#include
+#include
+#include
+#include
+#include "mythtwitterserver.h"
+#include "mythtwitterreturnables.h"
+
+class Core : public QObject
+{
+ Q_OBJECT;
+
+ public:
+ Core();
+ virtual ~Core();
+
+ public:
+ void GetPublicTimeline();
+ void GetSingleStatus(QString id);
+ void GetFeaturedUsers();
+ void Login(QString user, QString passw);
+ void Logout();
+ void SetLoginInfo(QString user, QString passw);
+ void SetProxy(SERVER::PROXY_TYPE type = SERVER::NO_PROXY, const QString hostName = QString(), \
+ quint16 port = 0, const QString user = QString(), const QString password = QString());
+ void IsTwitterUp();
+ void GetUsersTimeline(SERVER::Option2 *opt=NULL);
+ void GetFavorites(QString user="", unsigned int page=1);
+ void GetFriendsTimeline(SERVER::Option1 *opt=NULL);
+ void PostNewStatus(QString status, QString in_reply_to_status_id = "", QString source = "");
+ void GetRecentMentions(SERVER::Option3 *opt=NULL);
+ void RemoveStatus(QString id);
+ void GetFriends(SERVER::Option4 *opt=NULL);
+ void GetFollowers(SERVER::Option4 *opt=NULL);
+ void GetUserDetails(QString id = "", QString user_id= "", QString screen_name = "");
+ void GetSentDirectMessages(SERVER::Option5 *opt=NULL);
+ void GetReceivedDirectMessages(SERVER::Option5 *opt=NULL);
+ void SendDirectMessage(QString user, QString text);
+ void RemoveDirectMessage(QString id);
+ void AddFriendship(QString user, bool follow=true);
+ void RemoveFriendship(QString user);
+ void FriendshipExist(QString user_a, QString user_b);
+ void VerifyCredentials();
+ void UpdateDeliveryDevice(SERVER::DEVICES device);
+ void RemainingApiRequests();
+ void AddFavorite(QString id);
+ void RemoveFavorite(QString id);
+ void UpdateProfileColors(QString background_color = "", QString text_color = "", QString link_color = "", QString sidebar_fill_color = "", QString sidebar_border_color = "");
+ void UpdateProfileImage(QString image);
+ void UpdateProfileBackgroundImage(QString image, QString isTile);
+ void UpdateProfile(QString name = "", QString email = "", QString url = "", \
+ QString location = "", QString description = "");
+ void EnableNotifications(QString id);
+ void DisableNotifications(QString id);
+ void BlockUser(QString id);
+ void UnBlockUser(QString id);
+ void GetFriendsIDs(QString id = "", QString user_id = "", QString screen_name = "");
+ void GetFollowersIDs(QString id = "", QString user_id = "", QString screen_name = "");
+
+ public slots:
+ void RequestStarted(int id);
+ void ReqFinished(int id, bool error);
+ void DataReadProgress(int done, int total);
+ void Done(bool error);
+ void Abort();
+
+ signals:
+ void QueryDone();
+ void OnErrorString(QString error);
+ void OnError(QHttp::Error error);
+ void OnMessageReceived(QString message);
+ void OnStatusReceived(SERVER::RESP resp);
+ void OnResponseReceived(Returnables::Response *resp);
+
+ private:
+ struct Info
+ {
+ Info() { buffer = NULL; }
+ QBuffer *buffer;
+ Returnables::RequestId requestid;
+ };
+
+ private:
+ void MakeConnections();
+ void responseHeaderReceived(const QHttpResponseHeader &resp);
+ int MakeGetRequest(QString req,Returnables::RequestId reqId);
+ int MakePostRequest(QString path,QByteArray req,Returnables::RequestId reqId, bool isMultipart = false);
+
+ private:
+ QMap m_buffer;
+ QEventLoop *m_eventLoop;
+ QHttp *m_http;
+ QHttpRequestHeader header;
+
+ private:
+ static QString TWITTER_HOST;
+ static QString VERIFY_CREDENTIALS_URL;
+ static QString PUBLIC_TIMELINE_URL;
+ static QString GET_SINGLE_STATUS_URL;
+ static QString FEATURED_USERS_URL;
+ static QString LOGOUT_URL;
+ static QString IS_TWITTER_UP_URL;
+ static QString USERS_TIMELINE_URL;
+ static QString GET_FAVORITES_URL;
+ static QString FRIENDS_TIMELINE_URL;
+ static QString POST_NEW_STATUS_URL;
+ static QString GET_MENTIONS_URL;
+ static QString REMOVE_STATUS_URL;
+ static QString GET_FRIENDS_URL;
+ static QString GET_FOLLOWERS_URL;
+ static QString GET_USER_DETAILS_URL;
+ static QString GET_SENT_DIRECT_MESSAGES_URL;
+ static QString GET_RECEIVED_DIRECT_MESSAGES_URL;
+ static QString SEND_NEW_DIRECT_MESSAGE_URL;
+ static QString REMOVE_DIRECT_MESSAGE_URL;
+ static QString CREATE_FRIENDSHIP_URL;
+ static QString REMOVE_FRIENDSHIP_URL;
+ static QString FRIENDSHIP_EXIST_URL;
+ static QString UPDATE_DELIVERY_DEVICE_URL;
+ static QString REMAINING_API_REQUESTS_URL;
+ static QString ADD_FAVORITE_URL;
+ static QString REMOVE_FAVORITE_URL;
+ static QString PROFILE_COLORS_URL;
+ static QString PROFILE_IMAGE_URL;
+ static QString PROFILE_BACKGROUND_IMAGE_URL;
+ static QString PROFILE_URL;
+ static QString ENABLE_NOTIFICATIONS_URL;
+ static QString DISABLE_NOTIFICATIONS_URL;
+ static QString BLOCK_USER_URL;
+ static QString UNBLOCK_USER_URL;
+ static QString FRIENDS_IDS_URL;
+ static QString FOLLOWERS_IDS_URL;
+};
+
+#endif // Core_H
+
+
+
Index: mythplugins/mythtwitter/mythtwitter/mythtwitter.pro
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitter.pro (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitter.pro (revision 0)
@@ -0,0 +1,33 @@
+include ( ../../mythconfig.mak )
+include ( ../../settings.pro )
+include ( ../../programs-libs.pro )
+
+QT += network sql xml
+
+TEMPLATE = lib
+CONFIG += plugin thread warn_on debug
+TARGET = mythtwitter
+target.path = $${LIBDIR}/mythtv/plugins
+INSTALLS += target
+
+INCLUDEPATH += $${PREFIX}/include/mythtv
+INCLUDEPATH += $${PREFIX}/include/mythtv/libmythui
+INCLUDEPATH += $${PREFIX}/include/mythtv/libmythdb
+
+installfiles.path = $${PREFIX}/share/mythtv/mythtwitter
+
+INSTALLS += installfiles
+
+# Input
+HEADERS += mythtwitter.h mythtwitterconfig.h
+HEADERS += mythtwittertimeline.h
+HEADERS += mythtwittercore.h mythtwitterdecipher.h
+HEADERS += mythtwitterreturnables.h mythtwitterserver.h
+HEADERS += mythtwitterlib.h
+SOURCES += mythtwitterlib.cpp
+SOURCES += mythtwittercore.cpp mythtwitterdecipher.cpp
+SOURCES += mythtwitter.cpp mythtwitterconfig.cpp
+SOURCES += mythtwittertimeline.cpp
+SOURCES += main.cpp
+
+include ( ../../libs-targetfix.pro )
Index: mythplugins/mythtwitter/mythtwitter/main.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/main.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/main.cpp (revision 0)
@@ -0,0 +1,132 @@
+
+// C++ headers
+#include
+
+// QT headers
+#include
+
+// MythTV headers
+#include
+#include
+#include
+#include
+#include
+
+// MythTwitter headers
+#include "mythtwitterlib.h"
+#include "mythtwitter.h"
+#include "mythtwitterconfig.h"
+#include "mythtwittertimeline.h"
+
+using namespace std;
+
+void runTwitter(void);
+int RunTwitter(void);
+void runTwitterTimeline(void);
+int RunTwitterTimeline(void);
+void runTwitterSettings(void);
+int RunTwitterSettings(void);
+
+void setupKeys(void)
+{
+ REG_JUMPEX("MythTwitter", QT_TRANSLATE_NOOP("MythControls",
+ "Twitter Client"), "", runTwitter, false);
+ REG_JUMP("MythTwitter_Timeline", QT_TRANSLATE_NOOP("MythControls",
+ "Twitter Client Timeline"), "", runTwitterTimeline);
+ REG_JUMP("MythTwitter_Settings", QT_TRANSLATE_NOOP("MythControls",
+ "Twitter Client Settings"), "", runTwitterSettings);
+
+ REG_KEY("Twitter", "GETTWEETS",
+ QT_TRANSLATE_NOOP("MythControls", "Update Tweet List"), "U");
+}
+
+int mythplugin_init(const char *libversion)
+{
+ if (!gContext->TestPopupVersion("mythtwitter",
+ libversion,
+ MYTH_BINARY_VERSION))
+ return -1;
+
+ gContext->ActivateSettingsCache(false);
+
+ setupKeys();
+
+ return 0;
+}
+
+void runTwitter(void)
+{
+ RunTwitter();
+}
+
+void runTwitterSettings(void)
+{
+ RunTwitterSettings();
+}
+
+void runTwitterTimeline(void)
+{
+ RunTwitterTimeline();
+}
+
+int RunTwitter(void)
+{
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+
+ MythTwitterSend *mythtwitter = new MythTwitterSend(popupStack, "mythtwittersender");
+
+ if (mythtwitter->Create())
+ {
+ popupStack->AddScreen(mythtwitter);
+ return 0;
+ }
+ else
+ {
+ delete mythtwitter;
+ return -1;
+ }
+}
+
+int RunTwitterTimeline(void)
+{
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+
+ MythTwitterTimeline *mythtwittertimeline = new
+ MythTwitterTimeline(mainStack, "mythtwittertimeline");
+
+ if (mythtwittertimeline->Create())
+ {
+ mainStack->AddScreen(mythtwittertimeline);
+ return 0;
+ }
+ else
+ {
+ delete mythtwittertimeline;
+ return -1;
+ }
+}
+
+int RunTwitterSettings(void)
+{
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+
+ MythTwitterSettings *mythtwittersettings = new
+ MythTwitterSettings(mainStack, "mythtwittersettings");
+
+ if (mythtwittersettings->Create())
+ {
+ mainStack->AddScreen(mythtwittersettings);
+ return 0;
+ }
+ else
+ {
+ delete mythtwittersettings;
+ return -1;
+ }
+}
+
+int mythplugin_run(void)
+{
+ return RunTwitter();
+}
+
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterconfig.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterconfig.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterconfig.cpp (revision 0)
@@ -0,0 +1,108 @@
+#include
+
+// qt
+#include
+
+// myth
+#include
+#include
+#include
+
+#include "mythtwitterconfig.h"
+
+using namespace std;
+
+// ---------------------------------------------------
+
+MythTwitterSettings::MythTwitterSettings(MythScreenStack *parent, const char *name)
+ : MythScreenType(parent, name),
+ m_loginEdit(NULL), m_passwordEdit(NULL),
+ m_okButton(NULL), m_cancelButton(NULL)
+{
+}
+
+bool MythTwitterSettings::Create()
+{
+ bool foundtheme = false;
+
+ // Load the theme for this screen
+ foundtheme = LoadWindowFromXML("twitter-ui.xml", "twittersettings", this);
+
+ if (!foundtheme)
+ return false;
+
+// m_serviceList = dynamic_cast (GetChild("service"));
+ m_loginEdit = dynamic_cast (GetChild("login"));
+ m_passwordEdit = dynamic_cast (GetChild("password"));
+
+ m_okButton = dynamic_cast (GetChild("ok"));
+ m_cancelButton = dynamic_cast (GetChild("cancel"));
+
+ if (!m_loginEdit || !m_passwordEdit ||
+ !m_okButton || !m_cancelButton)
+ {
+ VERBOSE(VB_IMPORTANT, "Theme is missing critical theme elements.");
+ return false;
+ }
+
+ QString host = gContext->GetSetting("mythtwitter.TwitterHost");
+
+ m_loginEdit->SetText(gContext->GetSetting("mythtwitter.LoginName",
+ "login"));
+ m_passwordEdit->SetPassword(true);
+ m_passwordEdit->SetText(gContext->GetSetting("mythtwitter.Password",
+ "password"));
+
+// populateServices();
+
+// m_serviceList->SetValueByData(qVariantFromValue(host));
+
+ connect(m_okButton, SIGNAL(Clicked()), this, SLOT(slotSave()));
+ connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
+
+ if (!BuildFocusList())
+ VERBOSE(VB_IMPORTANT, "Failed to build a focuslist. Something is wrong");
+
+// SetFocusWidget(m_loginEdit);
+
+ return true;
+}
+
+MythTwitterSettings::~MythTwitterSettings()
+{
+}
+
+void MythTwitterSettings::slotSave(void)
+{
+// gContext->SaveSetting("mythtwitter.TwitterHost",
+// m_serviceList->GetDataValue().toString());
+ gContext->SaveSetting("mythtwitter.LoginName", m_loginEdit->GetText());
+ gContext->SaveSetting("mythtwitter.Password", m_passwordEdit->GetText());
+
+ Close();
+}
+
+void MythTwitterSettings::populateServices()
+{
+// MythUIButtonListItem *twitter =
+// new MythUIButtonListItem(m_serviceList,QString("Twitter.com"));
+// twitter->SetData(QString("twitter.com"));
+
+// MythUIButtonListItem *identica =
+// new MythUIButtonListItem(m_serviceList,QString("Identi.ca"));
+// identica->SetData(QString("identi.ca"));
+}
+
+
+bool MythTwitterSettings::keyPressEvent(QKeyEvent *event)
+{
+ if (GetFocusWidget()->keyPressEvent(event))
+ return true;
+
+ bool handled = false;
+
+ if (!handled && MythScreenType::keyPressEvent(event))
+ handled = true;
+
+ return handled;
+}
Index: mythplugins/mythtwitter/mythtwitter/mythtwittertimeline.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwittertimeline.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwittertimeline.cpp (revision 0)
@@ -0,0 +1,633 @@
+// POSIX headers
+#include
+
+// C headers
+#include
+
+// QT headers
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+// MythTV headers
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+// MythTwitter headers
+#include "mythtwittertimeline.h"
+#include "mythtwitterconfig.h"
+
+#define LOC QString("MythTwitterTimeline: ")
+#define LOC_WARN QString("MythTwitterTimeline, Warning: ")
+#define LOC_ERR QString("MythTwitterTimeline, Error: ")
+
+Q_DECLARE_METATYPE(Returnables::StatusElement);
+
+/** \brief Creates a new MythTwitterTimeline Screen
+ * \param parent Pointer to the screen stack
+ * \param name The name of the window
+ */
+MythTwitterTimeline::MythTwitterTimeline(MythScreenStack *parent, QString name) :
+ MythScreenType(parent, name),
+ m_currentTimeline(NULL),
+ m_source("MythChirp"), m_twitter(),
+ m_send(NULL), m_timelineList(NULL),
+ m_count(NULL)
+{
+ // Setup cache directory
+
+ QString fileprefix = GetConfDir();
+
+ QDir dir(fileprefix);
+ if (!dir.exists())
+ dir.mkdir(fileprefix);
+ fileprefix += "/MythTwitterTimeline";
+ dir = QDir(fileprefix);
+ if (!dir.exists())
+ dir.mkdir(fileprefix);
+
+ m_httpcomms = new HttpComms;
+ m_twitter = new MythTwitter();
+ m_currentTimeline = gContext->GetSetting(
+ "mythtwitter.CurrentTimeline", "Public");
+ m_login = gContext->GetSetting(
+ "mythtwitter.LoginName", "");
+ m_password = gContext->GetSetting(
+ "mythtwitter.Password", "");
+ if (!m_password.isEmpty() && !m_login.isEmpty())
+ {
+ m_twitter->Login(m_login, m_password);
+ m_validlogin = true;
+ }
+ else
+ m_validlogin = false;
+}
+
+MythTwitterTimeline::~MythTwitterTimeline()
+{
+ gContext->SaveSetting("mythtwitter.CurrentTimeline",
+ m_currentTimeline);
+
+ m_httpcomms->stop();
+ delete m_twitter;
+ delete m_httpcomms;
+}
+
+bool MythTwitterTimeline::Create(void)
+{
+
+ bool foundtheme = false;
+
+ // Load the theme for this screen
+ foundtheme = LoadWindowFromXML("twitter-ui.xml", "twittertimeline", this);
+
+ if (!foundtheme)
+ return false;
+
+ m_tweet = dynamic_cast (GetChild("tweet"));
+ m_send = dynamic_cast (GetChild("send"));
+ m_count = dynamic_cast (GetChild("count"));
+ m_timelineList = dynamic_cast (GetChild("timeline"));
+
+ if (!m_tweet || !m_send || !m_timelineList)
+ {
+ VERBOSE(VB_IMPORTANT, "Theme is missing critical theme elements.");
+ return false;
+ }
+
+ if (m_count)
+ m_count->SetText(tr("140 characters available"));
+
+ connect(m_timelineList, SIGNAL(itemClicked(MythUIButtonListItem *)),
+ SLOT(SwitchTimelineSpecificUser(void)));
+ connect(m_send, SIGNAL(Clicked()), this, SLOT(sendTweet()));
+ connect(m_tweet, SIGNAL(valueChanged()), this, SLOT(updateCount()));
+ connect(m_twitter,SIGNAL(OnResponseReceived(Returnables::Response *)), this,
+ SLOT(OnResponseReceived(Returnables::Response *)));
+
+ if (!m_validlogin)
+ {
+ m_send->SetVisible(false);
+ m_count->SetVisible(false);
+ m_tweet->SetVisible(false);
+ }
+
+ if (!BuildFocusList())
+ VERBOSE(VB_IMPORTANT, "Failed to build a focuslist. Something is wrong");
+
+ return true;
+}
+
+void MythTwitterTimeline::Init(void)
+{
+ if (!m_login.isEmpty())
+ {
+ if (m_currentTimeline == "Public")
+ m_twitter->GetPublicTimeline();
+ else if (m_currentTimeline == "User")
+ m_twitter->GetUsersTimeline();
+ else if (m_currentTimeline == "Friend")
+ m_twitter->GetFriendsTimeline();
+ else
+ m_twitter->GetPublicTimeline();
+ }
+ else
+ m_twitter->GetPublicTimeline();
+}
+
+bool MythTwitterTimeline::keyPressEvent(QKeyEvent *event)
+{
+ if (GetFocusWidget()->keyPressEvent(event))
+ return true;
+
+ bool handled = false;
+ QStringList actions;
+ handled = GetMythMainWindow()->TranslateKeyPress("Twitter", event, actions);
+
+ for (int i = 0; i < actions.size() && !handled; i++)
+ {
+ QString action = actions[i];
+ handled = true;
+
+ if (action == "MENU")
+ {
+ doMenuPopup();
+ }
+ else if (action == "GETTWEETS")
+ {
+ doRefresh();
+ }
+ else if (action == "DELETE" && m_validlogin)
+ {
+ doDeleteMenu();
+ }
+ else
+ handled = false;
+ }
+
+ if (!handled && MythScreenType::keyPressEvent(event))
+ handled = true;
+
+ return handled;
+}
+
+void MythTwitterTimeline::updateCount(void)
+{
+ m_count->SetText(tr("%1 of 140 characters available")
+ .arg(140 - m_tweet->GetText().count()));
+}
+
+void MythTwitterTimeline::doMenuPopup(void)
+{
+ QString label = tr("Twitter Options");
+
+ MythScreenStack *popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+
+ MythDialogBox *menuPopup = new MythDialogBox(label, popupStack,
+ "screensetupmenupopup");
+
+ if (menuPopup->Create())
+ {
+ popupStack->AddScreen(menuPopup);
+
+ menuPopup->SetReturnEvent(this, "options");
+
+ menuPopup->AddButton(tr("Refresh Tweets"), SLOT(doRefresh()));
+ menuPopup->AddButton(tr("Change Timeline"),
+ SLOT(doViewPopup()), true);
+ menuPopup->AddButton(tr("Twitter Login Settings"),
+ SLOT(loginSettingsPopup()));
+ if (GetFocusWidget() == m_timelineList)
+ {
+ if (m_validlogin)
+ menuPopup->AddButton(tr("Follow This User"),
+ SLOT(AddFriendshipUser()));
+ if (m_validlogin)
+ menuPopup->AddButton(tr("Don't Follow This User"),
+ SLOT(RemoveFriendshipUser()));
+ menuPopup->AddButton(tr("View This User's Timeline"),
+ SLOT(SwitchTimelineSpecificUser()));
+ if (m_validlogin)
+ menuPopup->AddButton(tr("Delete"), SLOT(doDeleteMenu()));
+ }
+ }
+ else
+ {
+ delete menuPopup;
+ }
+}
+
+void MythTwitterTimeline::doViewPopup(void)
+{
+ QString label = tr("View Options");
+
+ MythScreenStack *popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+
+ MythDialogBox *menuPopup = new MythDialogBox(label, popupStack,
+ "screensetupmenupopup");
+
+ if (menuPopup->Create())
+ {
+ popupStack->AddScreen(menuPopup);
+
+ menuPopup->SetReturnEvent(this, "options");
+
+ menuPopup->AddButton(tr("View a Specific User's Timeline"),
+ SLOT(ViewUserPopup()));
+ if (m_currentTimeline != "Public")
+ menuPopup->AddButton(tr("View Public Timeline"),
+ SLOT(SwitchTimelinePublic()));
+ if (m_currentTimeline != "User" && m_validlogin)
+ menuPopup->AddButton(tr("View Your Timeline"),
+ SLOT(SwitchTimelineUser()));
+ if (m_currentTimeline != "Friend" && m_validlogin)
+ menuPopup->AddButton(tr("View Friend Timeline"),
+ SLOT(SwitchTimelineFriend()));
+ }
+ else
+ {
+ delete menuPopup;
+ }
+}
+
+void MythTwitterTimeline::doDeleteMenu(void)
+{
+ QString message = tr("Are you sure you want to delete this tweet?");
+
+ MythScreenStack *popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+
+ MythConfirmationDialog *confirmdialog =
+ new MythConfirmationDialog(popupStack,message);
+
+ if (confirmdialog->Create())
+ popupStack->AddScreen(confirmdialog);
+
+ connect(confirmdialog, SIGNAL(haveResult(bool)),
+ SLOT(doRemoveTweet(bool)));
+}
+
+void MythTwitterTimeline::doRemoveTweet(bool dodelete)
+{
+ if (!dodelete)
+ return;
+ else
+ {
+ Returnables::StatusElement element =
+ qVariantValue(m_timelineList->GetDataValue());
+ VERBOSE(VB_IMPORTANT|VB_EXTRA, QString("MythTwitterTimeline::doRemoveTweet: "
+ "Removing Tweet with Status ID %1")
+ .arg(element.status.id));
+ QString idnum = QString::number(element.status.id);
+ m_twitter->RemoveStatus(idnum.toULongLong());
+ MythUIButtonListItem *delItem;
+ delItem = m_timelineList->GetItemByData(
+ qVariantFromValue(m_timelineList->GetDataValue()));
+ m_timelineList->RemoveItem(delItem);
+ if (m_timelineList->GetCount() == 0)
+ m_timelineList->SetVisible(false);
+ }
+}
+
+void MythTwitterTimeline::ViewUserPopup(void)
+{
+ QString message = tr("Enter the username you wish to view:");
+
+ MythScreenStack *popupStack =
+ GetMythMainWindow()->GetStack("popup stack");
+
+ MythTextInputDialog *userdialog =
+ new MythTextInputDialog(popupStack,message);
+
+ if (userdialog->Create())
+ popupStack->AddScreen(userdialog);
+
+ connect(userdialog, SIGNAL(haveResult(QString)),
+ SLOT(doViewUser(QString)), Qt::QueuedConnection);
+}
+
+void MythTwitterTimeline::doViewUser(QString username)
+{
+ m_currentTimeline = "User";
+ SERVER::Option2 *opt = new SERVER::Option2;
+ opt->id = username;
+ opt->user_id = 0;
+ m_twitter->GetUsersTimeline(opt);
+}
+
+void MythTwitterTimeline::SwitchTimelinePublic(void)
+{
+ m_currentTimeline = "Public";
+ m_twitter->GetPublicTimeline();
+}
+
+void MythTwitterTimeline::SwitchTimelineUser(void)
+{
+ m_currentTimeline = "User";
+ m_twitter->GetUsersTimeline();
+}
+
+void MythTwitterTimeline::SwitchTimelineSpecificUser(void)
+{
+ m_currentTimeline = "User";
+ Returnables::StatusElement element =
+ qVariantValue(m_timelineList->GetDataValue());
+ SERVER::Option2 *opt = new SERVER::Option2;
+ opt->user_id = QString::number(element.user.id).toULongLong();
+ m_twitter->GetUsersTimeline(opt);
+}
+
+void MythTwitterTimeline::AddFriendshipUser(void)
+{
+ Returnables::StatusElement element =
+ qVariantValue(m_timelineList->GetDataValue());
+ QString username = element.user.screenName;
+ m_twitter->AddFriendship(username);
+
+ QString message = tr("You are now following %1.").arg(username);
+
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+
+ MythConfirmationDialog *okPopup =
+ new MythConfirmationDialog(popupStack, message, false);
+
+ if (okPopup->Create())
+ popupStack->AddScreen(okPopup);
+ else
+ delete okPopup;
+}
+
+void MythTwitterTimeline::RemoveFriendshipUser(void)
+{
+ Returnables::StatusElement element =
+ qVariantValue(m_timelineList->GetDataValue());
+ QString username = element.user.screenName;
+ m_twitter->RemoveFriendship(username);
+
+ QString message = tr("You are no longer following %1.").arg(username);
+
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+
+ MythConfirmationDialog *okPopup =
+ new MythConfirmationDialog(popupStack, message, false);
+
+ if (okPopup->Create())
+ popupStack->AddScreen(okPopup);
+ else
+ delete okPopup;
+}
+
+void MythTwitterTimeline::SwitchTimelineFriend(void)
+{
+ m_currentTimeline = "Friend";
+ m_twitter->GetFriendsTimeline();
+}
+
+void MythTwitterTimeline::loginSettingsPopup(void)
+{
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+
+ MythTwitterSettings *mythtwittersettings = new
+ MythTwitterSettings(mainStack, "mythtwittersettings");
+
+ if (mythtwittersettings->Create())
+ {
+ connect(mythtwittersettings, SIGNAL(Exiting()), this,
+ SLOT(doSettingsRefresh()));
+ mainStack->AddScreen(mythtwittersettings);
+ }
+ else
+ delete mythtwittersettings;
+}
+
+void MythTwitterTimeline::sendTweet()
+{
+ if (m_tweet->GetText().count() > 140)
+ {
+ QString message = tr("Tweets are limited to 140 characters. "
+ "Erase some characters and try again.");
+
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+
+ MythConfirmationDialog *okPopup =
+ new MythConfirmationDialog(popupStack, message, false);
+
+ if (okPopup->Create())
+ popupStack->AddScreen(okPopup);
+ else
+ delete okPopup;
+
+ return;
+ }
+
+ if (!m_validlogin)
+ {
+ QString message = tr("You must have a valid Twitter login "
+ "to send tweets.");
+
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+
+ MythConfirmationDialog *okPopup =
+ new MythConfirmationDialog(popupStack, message, false);
+
+ if (okPopup->Create())
+ popupStack->AddScreen(okPopup);
+ else
+ delete okPopup;
+
+ return;
+ }
+
+ VERBOSE(VB_IMPORTANT|VB_EXTRA, QString("Sending a tweet with the "
+ "following contents: %1").arg(m_tweet->GetText()));
+ m_twitter->PostNewStatus(m_tweet->GetText(), 0, m_source);
+ m_tweet->SetText("");
+ doRefresh();
+}
+
+void MythTwitterTimeline::doRefresh()
+{
+ if (m_validlogin)
+ {
+ m_twitter->Login(m_login, m_password);
+ if (m_currentTimeline == "Public")
+ m_twitter->GetPublicTimeline();
+ else if (m_currentTimeline == "User")
+ m_twitter->GetUsersTimeline();
+ else if (m_currentTimeline == "Friend")
+ m_twitter->GetFriendsTimeline();
+ else
+ m_twitter->GetPublicTimeline();
+ }
+ else
+ m_twitter->GetPublicTimeline();
+}
+
+void MythTwitterTimeline::doSettingsRefresh()
+{
+ m_login = gContext->GetSetting(
+ "mythtwitter.LoginName", "");
+ m_password = gContext->GetSetting(
+ "mythtwitter.Password", "");
+ if (!m_password.isEmpty() && !m_login.isEmpty())
+ {
+ m_validlogin = true;
+ }
+ else
+ m_validlogin = false;
+
+ if (!m_validlogin)
+ {
+ m_send->SetVisible(false);
+ m_count->SetVisible(false);
+ m_tweet->SetVisible(false);
+ }
+ else
+ {
+ m_send->SetVisible(true);
+ m_count->SetVisible(true);
+ m_tweet->SetVisible(true);
+ }
+}
+
+void MythTwitterTimeline::DisplayList(QLinkedList list, QString header)
+{
+ Returnables::StatusElement *element = NULL;
+ m_timelineList->Reset();
+
+ while(!list.isEmpty())
+ {
+ element = list.takeFirst();
+
+ MythUIButtonListItem *item =
+ new MythUIButtonListItem(m_timelineList,QString("%1 - %2")
+ .arg(element->user.screenName).arg(element->status.text));
+ item->SetText(QString::number(element->status.id), "statusid");
+ item->SetText(element->status.text, "status");
+ item->SetText(element->status.source, "source");
+ item->SetText(element->status.createdAt, "time");
+ item->SetText(element->user.name, "username");
+ item->SetText(element->user.screenName, "screenname");
+ item->SetText(element->user.location, "location");
+ item->SetText(element->user.description, "description");
+ item->SetText(element->user.url, "url");
+ item->SetText(QString::number(element->user.followersCount), "followers");
+ item->SetText(QString::number(element->user.id), "userid");
+ item->SetText(header, "header");
+ item->SetText(QString::number(element->status.id), "statusid");
+ item->SetData(qVariantFromValue(*element));
+
+ if (!element->user.profileImageUrl.isEmpty())
+ {
+ QString fileprefix = GetConfDir();
+
+ QDir dir(fileprefix);
+ if (!dir.exists())
+ dir.mkdir(fileprefix);
+
+ fileprefix += "/MythTwitter/profileimagecache";
+
+ dir = QDir(fileprefix);
+ if (!dir.exists())
+ dir.mkdir(fileprefix);
+
+ QString url = element->user.profileImageUrl;
+ QString sFilename = QString("%1/%2")
+ .arg(fileprefix)
+ .arg(qChecksum(url.toLocal8Bit().constData(),
+ url.toLocal8Bit().size()));
+
+ bool exists = QFile::exists(sFilename);
+ if (!exists)
+ m_httpcomms->getHttpFile(sFilename, url, 20000, 1, 2);
+
+ item->SetImage(sFilename);
+ }
+ }
+}
+
+void MythTwitterTimeline::OnResponseReceived(Returnables::Response *resp)
+{
+ if(resp)
+ {
+ switch(resp->reqID)
+ {
+ case Returnables::PUBLIC_TIMELINE:
+ {
+ Returnables::PublicTimeline *pTimeline =
+ static_cast(resp);
+ DisplayList(pTimeline->list, "Public Timeline");
+ delete pTimeline;
+ break;
+ }
+ case Returnables::USER_TIMELINE:
+ {
+ Returnables::UserTimeline *userTimeline =
+ static_cast(resp);
+ DisplayList(userTimeline->list, "Users Timeline");
+ delete userTimeline;
+ break;
+ }
+ case Returnables::FRIENDS_TIMELINE:
+ {
+ Returnables::FriendsTimeline *fTimeline =
+ static_cast(resp);
+ DisplayList(fTimeline->list, "Friends Timeline");
+ delete fTimeline;
+ break;
+ }
+ case Returnables::SINGLE_STATUS:
+ case Returnables::FEATURED_USERS:
+ case Returnables::TWITTER_UP:
+ case Returnables::FAVORITES:
+ case Returnables::NEW_STATUS:
+ case Returnables::RECENT_MENTIONS:
+ case Returnables::REMOVE_STATUS:
+ case Returnables::FRIENDS:
+ case Returnables::FOLLOWERS:
+ case Returnables::USER_DETAILS:
+ case Returnables::VERIFY_CREDENTIALS:
+ case Returnables::SENT_DIRECT_MESSAGES:
+ case Returnables::RECEIVED_DIRECT_MESSAGES:
+ case Returnables::SEND_DIRECT_MESSAGE:
+ case Returnables::REMOVE_DIRECT_MESSAGE:
+ case Returnables::ADD_FRIENDSHIP:
+ case Returnables::REMOVE_FRIENDSHIP:
+ case Returnables::FRIENDSHIP_EXISTS:
+ case Returnables::DELIVERY_DEVICE:
+ case Returnables::API_REQUESTS:
+ case Returnables::ADD_FAVORITE:
+ case Returnables::REMOVE_FAVORITE:
+ case Returnables::PROFILE_COLORS:
+ case Returnables::PROFILE_IMAGE:
+ case Returnables::PROFILE_BACKGROUND_IMAGE:
+ case Returnables::PROFILE:
+ case Returnables::FRIENDS_IDS:
+ case Returnables::FOLLOWERS_IDS:
+ case Returnables::ENABLE_NOTIFICATIONS:
+ case Returnables::DISABLE_NOTIFICATIONS:
+ case Returnables::BLOCK_USER:
+ case Returnables::UNBLOCK_USER:
+ case Returnables::LOGOUT:
+ {
+ break;
+ }
+ }
+ }
+}
+
Index: mythplugins/mythtwitter/mythtwitter/mythtwitterlib.cpp
===================================================================
--- mythplugins/mythtwitter/mythtwitter/mythtwitterlib.cpp (revision 0)
+++ mythplugins/mythtwitter/mythtwitter/mythtwitterlib.cpp (revision 0)
@@ -0,0 +1,207 @@
+#include "mythtwitterlib.h"
+#include "mythtwittercore.h"
+
+//=====================================================================
+MythTwitter::MythTwitter()
+{}
+//=====================================================================
+MythTwitter::~MythTwitter()
+{}
+//=====================================================================
+void MythTwitter::GetPublicTimeline()
+{
+ Core::GetPublicTimeline();
+}
+//=====================================================================
+void MythTwitter::GetSingleStatus(quint64 id)
+{
+ Core::GetSingleStatus(QString::number(id));
+}
+//=====================================================================
+void MythTwitter::GetFeaturedUsers()
+{
+ Core::GetFeaturedUsers();
+}
+//=====================================================================
+void MythTwitter::Login(QString user, QString password)
+{
+ Core::Login(user, password);
+}
+//=====================================================================
+void MythTwitter::Logout()
+{
+ Core::Logout();
+}
+//=====================================================================
+void MythTwitter::Abort()
+{
+ Core::Abort();
+}
+//=====================================================================
+void MythTwitter::SetLoginInfo(QString user, QString password)
+{
+ Core::SetLoginInfo(user, password);
+}
+//=====================================================================
+void MythTwitter::IsTwitterUp()
+{
+ Core::IsTwitterUp();
+}
+//=====================================================================
+void MythTwitter::GetUsersTimeline(SERVER::Option2 *opt /*=NULL*/)
+{
+ Core::GetUsersTimeline(opt);
+}
+//=====================================================================
+void MythTwitter::GetFavorites(QString user /*=""*/, unsigned int page /*=1*/)
+{
+ Core::GetFavorites(user, page);
+}
+//=====================================================================
+void MythTwitter::GetFriendsTimeline(SERVER::Option1 *opt /*=NULL*/)
+{
+ Core::GetFriendsTimeline(opt);
+}
+//=====================================================================
+void MythTwitter::PostNewStatus(QString status, quint64 in_reply_to_status_id, QString source)
+{
+ Core::PostNewStatus(status, QString::number(in_reply_to_status_id), source);
+}
+//=====================================================================
+void MythTwitter::GetRecentMentions(SERVER::Option3 *opt /*=NULL*/)
+{
+ Core::GetRecentMentions(opt);
+}
+//=====================================================================
+void MythTwitter::RemoveStatus(quint64 id)
+{
+ Core::RemoveStatus(QString::number(id));
+}
+//=====================================================================
+void MythTwitter::GetFriends(SERVER::Option4 *opt /*=NULL*/)
+{
+ Core::GetFriends(opt);
+}
+//=====================================================================
+void MythTwitter::GetFollowers(SERVER::Option4 *opt /*=NULL*/)
+{
+ Core::GetFollowers(opt);
+}
+//=====================================================================
+void MythTwitter::GetUserDetails(QString id, unsigned int user_id, QString screen_name)
+{
+ Core::GetUserDetails(id, QString::number(user_id), screen_name);
+}
+//=====================================================================
+void MythTwitter::GetSentDirectMessages(SERVER::Option5 *opt /*=NULL*/)
+{
+ Core::GetSentDirectMessages(opt);
+}
+//=====================================================================
+void MythTwitter::GetReceivedDirectMessages(SERVER::Option5 *opt /*=NULL*/)
+{
+ Core::GetReceivedDirectMessages(opt);
+}
+//=====================================================================
+void MythTwitter::SendDirectMessage(QString user, QString text)
+{
+ Core::SendDirectMessage(user, text);
+}
+//=====================================================================
+void MythTwitter::RemoveDirectMessage(quint64 id)
+{
+ Core::RemoveDirectMessage(QString::number(id));
+}
+//=====================================================================
+void MythTwitter::AddFriendship(QString user, bool follow /*=true*/)
+{
+ Core::AddFriendship(user, follow);
+}
+//=====================================================================
+void MythTwitter::RemoveFriendship(QString user)
+{
+ Core::RemoveFriendship(user);
+}
+//=====================================================================
+void MythTwitter::FriendshipExist(QString user_a, QString user_b)
+{
+ Core::FriendshipExist(user_a, user_b);
+}
+//=====================================================================
+void MythTwitter::VerifyCredentials()
+{
+ Core::VerifyCredentials();
+}
+//=====================================================================
+void MythTwitter::UpdateDeliveryDevice(SERVER::DEVICES device)
+{
+ Core::UpdateDeliveryDevice(device);
+}
+//=====================================================================
+void MythTwitter::RemainingApiRequests()
+{
+ Core::RemainingApiRequests();
+}
+//=====================================================================
+void MythTwitter::AddFavorite(quint64 id)
+{
+ Core::AddFavorite(QString::number(id));
+}
+//=====================================================================
+void MythTwitter::RemoveFavorite(quint64 id)
+{
+ Core::RemoveFavorite(QString::number(id));
+}
+//=====================================================================
+void MythTwitter::UpdateProfileColors(QString background_color, QString text_color, QString link_color, QString sidebar_fill_color , QString sidebar_border_color)
+{
+ Core::UpdateProfileColors(background_color, text_color,link_color,sidebar_fill_color, sidebar_border_color);
+}
+//=====================================================================
+void MythTwitter::UpdateProfileImage(QString image)
+{
+ Core::UpdateProfileImage(image);
+}
+//=====================================================================
+void MythTwitter::UpdateProfileBackgroundImage(QString image, bool tile)
+{
+ QString isTile = tile ? "true" : "false";
+ Core::UpdateProfileBackgroundImage(image, isTile);
+}
+//=====================================================================
+void MythTwitter::UpdateProfile(QString name, QString email, QString url, QString location, QString description)
+{
+ Core::UpdateProfile(name, email, url, location, description);
+}
+//=====================================================================
+void MythTwitter::EnableNotifications(QString id)
+{
+ Core::EnableNotifications(id);
+}
+//=====================================================================
+void MythTwitter::DisableNotifications(QString id)
+{
+ Core::DisableNotifications(id);
+}
+//=====================================================================
+void MythTwitter::BlockUser(QString id)
+{
+ Core::BlockUser(id);
+}
+//=====================================================================
+void MythTwitter::UnBlockUser(QString id)
+{
+ Core::UnBlockUser(id);
+}
+//=====================================================================
+void MythTwitter::GetFriendsIDs(QString id, QString user_id, QString screen_name)
+{
+ Core::GetFriendsIDs(id, user_id, screen_name);
+}
+//=====================================================================
+
+void MythTwitter::GetFollowersIDs(QString id,QString user_id, QString screen_name)
+{
+ Core::GetFollowersIDs(id, user_id, screen_name);
+}
+//=====================================================================
Index: mythplugins/mythtwitter/AUTHORS
===================================================================
--- mythplugins/mythtwitter/AUTHORS (revision 0)
+++ mythplugins/mythtwitter/AUTHORS (revision 0)
@@ -0,0 +1 @@
+By Robert McNamara
Index: mythplugins/mythtwitter/ChangeLog
===================================================================
--- mythplugins/mythtwitter/ChangeLog (revision 0)
+++ mythplugins/mythtwitter/ChangeLog (revision 0)
@@ -0,0 +1,4 @@
+2009-11-16 Robert McNamara
+
+ * Initial Version, only intended to send tweets for now.
+
Index: mythplugins/mythtwitter/COPYING
===================================================================
--- mythplugins/mythtwitter/COPYING (revision 0)
+++ mythplugins/mythtwitter/COPYING (revision 0)
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ 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 General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
Index: mythplugins/mythtwitter/README
===================================================================
--- mythplugins/mythtwitter/README (revision 0)
+++ mythplugins/mythtwitter/README (revision 0)
@@ -0,0 +1,23 @@
+MythTwitter
+---------------------------------------------------------------------
+
+INSTALLATION:
+---------------------------------------------------------------------
+
+run (a Qt4 version of) qmake on mythtwitter.pro:
+
+qmake-qt4 mythtwitter.pro
+
+Type 'make' in the main directory to begin compiling
+
+Once the make is completed, do a 'make install'.
+
+
+CONFIGURATION/USAGE:
+---------------------------------------------------------------------
+
+To set up MythTwitter, simply enter MythTwitter, press MENU, choose
+"Twitter Login Settings," and enter your login info. You are
+ready to twitter! There is a twitter jumppoint that you can bind so
+that you can twitter from anywhere, or go to Info Center and choose
+"Twitter."