summaryrefslogtreecommitdiff
path: root/protocols/Twitter/twitter.h
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-06-06 08:58:27 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-06-06 08:58:27 +0000
commitb61ba851da0157ace3bdfc1ebbf87156b0b76413 (patch)
treed6c567db57af1eb09c254a8bee13c305282334f8 /protocols/Twitter/twitter.h
parenta4c70f6bedb25e5cffb08dfc5cbc2597d1642d6b (diff)
protocols plugins moved to protocols
git-svn-id: http://svn.miranda-ng.org/main/trunk@327 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Twitter/twitter.h')
-rw-r--r--protocols/Twitter/twitter.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/protocols/Twitter/twitter.h b/protocols/Twitter/twitter.h
new file mode 100644
index 0000000000..06f8aca954
--- /dev/null
+++ b/protocols/Twitter/twitter.h
@@ -0,0 +1,96 @@
+/*
+Copyright © 2009 Jim Porter
+
+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 2 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 <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+
+#include <map>
+#include <vector>
+#include <string>
+
+#include "http.h"
+#include <tchar.h>
+
+#if !defined(tstring)
+ #ifdef _UNICODE
+ #define tstring wstring
+ #else
+ #define tstring string
+ #endif
+#endif
+
+typedef unsigned long long twitter_id;
+
+struct twitter_status
+{
+ std::tstring text;
+ twitter_id id;
+ time_t time;
+};
+
+struct twitter_user
+{
+ std::string username;
+ std::tstring real_name;
+ std::string profile_image_url;
+ twitter_status status;
+};
+
+time_t parse_time(const std::string &);
+
+class bad_response : public std::exception
+{
+public:
+ virtual const char * what() const
+ {
+ return "bad http response";
+ }
+};
+
+class twitter
+{
+public:
+ typedef std::vector<twitter_user> status_list;
+ typedef std::map<std::tstring,status_list> status_map;
+
+ twitter();
+
+ bool set_credentials(const std::string &username,const std::string &password, bool test = true);
+ void set_base_url(const std::string &base_url);
+
+ const std::string & get_username() const;
+ const std::string & get_base_url() const;
+
+ bool get_info(const std::tstring &name,twitter_user *);
+ bool get_info_by_email(const std::tstring &email,twitter_user *);
+ std::vector<twitter_user> get_friends();
+
+ twitter_user add_friend(const std::tstring &name);
+ void remove_friend(const std::tstring &name);
+
+ void set_status(const std::tstring &text);
+ std::vector<twitter_user> get_statuses(int count=20,twitter_id id=0);
+
+ void send_direct(const std::tstring &name,const std::tstring &text);
+ std::vector<twitter_user> get_direct(twitter_id id=0);
+
+protected:
+ virtual http::response slurp(const std::string &,http::method, const std::string & = "") = 0;
+
+ std::string username_;
+ std::string password_;
+ std::string base_url_;
+}; \ No newline at end of file