gwibber-service-sohu-0.8.1/0000755000175000017500000000000011573222032015366 5ustar chinesechinesegwibber-service-sohu-0.8.1/po/0000755000175000017500000000000011573222032016004 5ustar chinesechinesegwibber-service-sohu-0.8.1/po/POTFILES.in0000644000175000017500000000010711551565321017566 0ustar chinesechinesegtk/sohu/__init__.py [type: gettext/glade] ui/gwibber-accounts-sohu.ui gwibber-service-sohu-0.8.1/po/gwibber-service-sohu.pot0000644000175000017500000000347711551565405022610 0ustar chinesechinese# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2011-04-13 16:07-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../gtk/sohu/__init__.py:45 ../gtk/sohu/__init__.py:159 #, python-format msgid "%s has been authorized by Sohu" msgstr "" #: ../gtk/sohu/__init__.py:62 msgid "

Please wait...

" msgstr "" #: ../gtk/sohu/__init__.py:101 msgid "Verifying" msgstr "" #: ../gtk/sohu/__init__.py:147 ../gtk/sohu/__init__.py:151 #: ../gtk/sohu/__init__.py:171 msgid "Authorization failed. Please try again." msgstr "" #: ../gtk/sohu/__init__.py:154 msgid "Successful" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:1 msgid "Account Color:" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:2 msgid "Account Settings:" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:3 msgid "Allow sending posts to this account" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:4 msgid "Authorize with sohu" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:5 msgid "Color used to help distinguish accounts" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:6 msgid "Include this account when downloading messages" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:7 msgid "Sohu authorized" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:8 msgid "_Authorize" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:9 msgid "_Receive Messages" msgstr "" #: ../ui/gwibber-accounts-sohu.ui.h:10 msgid "_Send Messages" msgstr "" gwibber-service-sohu-0.8.1/__init__.py0000644000175000017500000002506411556514305017516 0ustar chinesechinesefrom gwibber.microblog import network, util from htmlentitydefs import name2codepoint import re import gnomekeyring from oauth import oauth from gwibber.microblog.util import log, resources from gettext import lgettext as _ import sohu.utils log.logger.name = "Sohu" PROTOCOL_INFO = { "name": "Sohu", "version": "1.0", "config": [ "private:secret_token", "access_token", "username", "color", "receive_enabled", "send_enabled", ], "authtype": "oauth1a", "color": "#729FCF", "features": [ "send", "receive", "search", "tag", "reply", "responses", "private", "public", "delete", "retweet", "like", "send_thread", "send_private", "user_messages", "sinceid", "lists", "list", ], "default_streams": [ "receive", "images", "responses", "private", "lists", ], } URL_PREFIX = "http://t.sohu.com" API_PREFIX = "http://api.t.sohu.com" def unescape(s): return re.sub('&(%s);' % '|'.join(name2codepoint), lambda m: unichr(name2codepoint[m.group(1)]), s) class Client: def __init__(self, acct): self.service = util.getbus("Service") if acct.has_key("secret_token") and acct.has_key("password"): acct.pop("password") self.account = acct if not acct.has_key("access_token") and not acct.has_key("secret_token"): return [{"error": {"type": "auth", "account": self.account, "message": _("Failed to find credentials")}}] self.sigmethod = oauth.OAuthSignatureMethod_HMAC_SHA1() self.consumer = oauth.OAuthConsumer(*sohu.utils.get_sohu_keys()) self.token = oauth.OAuthToken(acct["access_token"], acct["secret_token"]) def _common(self, data): m = {}; try: m["mid"] = str(data["id"]) m["service"] = "sohu" m["account"] = self.account["id"] m["time"] = util.parsetime(data["created_at"]) m["text"] = unescape(data["text"]) m["to_me"] = ("@%s" % self.account["username"]) in data["text"] m["html"] = util.linkify(data["text"], ((util.PARSE_HASH, '#\\1' % URL_PREFIX), (util.PARSE_NICK, '@\\1' % URL_PREFIX)), escape=False) m["content"] = util.linkify(data["text"], ((util.PARSE_HASH, '#\\1' % m["account"]), (util.PARSE_NICK, '@\\1' % m["account"])), escape=False) if data.has_key("retweeted_status"): m["retweeted_status"] = data["retweeted_status"] else: m["retweeted_status"] = None images = [] if data.get("original_pic", 0): images.append({"src": data["small_pic"], "url": data["original_pic"]}) if data.get("retweeted_status", 0): if data["retweeted_status"].get("original_pic"): images.append({"src": data["retweeted_status"]["small_pic"], "url": data["retweeted_status"]["original_pic"]}) if images: m["images"] = images m["type"] = "photo" except: log.logger.error("%s failure - %s", PROTOCOL_INFO["name"], data) return {} return m def _user(self, user): return { "name": user["name"], "nick": user["screen_name"], "id": user["id"], "location": user["location"], "followers": user.get("followers", None), "image": user["profile_image_url"], "url": "/".join((URL_PREFIX, user["screen_name"])), "is_me": user["screen_name"] == self.account["username"], } def _message(self, data): if type(data) == type(None): return [] m = self._common(data) m["source"] = data.get("source", False) if data.has_key("in_reply_to_status_id"): if data["in_reply_to_status_id"]: m["reply"] = {} m["reply"]["id"] = data["in_reply_to_status_id"] m["reply"]["nick"] = data["in_reply_to_screen_name"] if m["reply"]["id"] and m["reply"]["nick"]: m["reply"]["url"] = "/".join((URL_PREFIX, m["reply"]["nick"], "statuses", str(m["reply"]["id"]))) else: m["reply"]["url"] = None m["sender"] = self._user(data["user"] if "user" in data else data["sender"]) m["url"] = "/".join((m["sender"]["url"], "statuses", str(m["mid"]))) return m def _private(self, data): m = self._message(data) m["private"] = True m["recipient"] = {} m["recipient"]["name"] = data["recipient"]["name"] m["recipient"]["nick"] = data["recipient"]["screen_name"] m["recipient"]["id"] = data["recipient"]["id"] m["recipient"]["image"] = data["recipient"]["profile_image_url"] m["recipient"]["location"] = data["recipient"]["location"] m["recipient"]["url"] = "/".join((URL_PREFIX, m["recipient"]["nick"])) m["recipient"]["is_me"] = m["recipient"]["nick"] == self.account["username"] m["to_me"] = m["recipient"]["is_me"] return m def _result(self, data): m = self._common(data) if data["to_user_id"]: m["reply"] = {} m["reply"]["id"] = data["to_user_id"] m["reply"]["nick"] = data["to_user"] m["sender"] = {} m["sender"]["nick"] = data["from_user"] m["sender"]["id"] = data["from_user_id"] m["sender"]["image"] = data["profile_image_url"] m["sender"]["url"] = "/".join((URL_PREFIX, m["sender"]["nick"])) m["sender"]["is_me"] = m["sender"]["nick"] == self.account["username"] m["url"] = "/".join((m["sender"]["url"], "statuses", str(m["mid"]))) return m def _list(self, data): return { "mid": data["id"], "service": "sohu", "account": self.account["id"], "time": 0, "text": data["description"], "html": data["description"], "content": data["description"], "url": "/".join((URL_PREFIX, data["uri"])), "sender": self._user(data["user"]), "name": data["name"], "nick": data["slug"], "key": data["slug"], "full": data["full_name"], "uri": data["uri"], "mode": data["mode"], "members": data["member_count"], "followers": data["subscriber_count"], "kind": "list", } def _get(self, path, parse="message", post=False, single=False, **args): url = "/".join((API_PREFIX, path)) request = oauth.OAuthRequest.from_consumer_and_token(self.consumer, self.token, http_method="POST" if post else "GET", http_url=url, parameters=util.compact(args)) request.sign_request(self.sigmethod, self.consumer, self.token) if post: data = network.Download(request.http_url, None, post, body=request.to_postdata()).get_json() #data = network.Download(request.to_url(), util.compact(args), post).get_json() else: data = network.Download(request.to_url(), None, post).get_json() resources.dump(self.account["service"], self.account["id"], data) if isinstance(data, dict) and data.get("errors", 0): if "authenticate" in data["errors"][0]["message"]: logstr = """%s: %s - %s""" % (PROTOCOL_INFO["name"], _("Authentication failed"), error["message"]) log.logger.error("%s", logstr) return [{"error": {"type": "auth", "account": self.account, "message": data["errors"][0]["message"]}}] else: for error in data["errors"]: logstr = """%s: %s - %s""" % (PROTOCOL_INFO["name"], _("Unknown failure"), error["message"]) return [{"error": {"type": "unknown", "account": self.account, "message": error["message"]}}] elif isinstance(data, dict) and data.get("error", 0): if "Incorrect signature" in data["error"]: logstr = """%s: %s - %s""" % (PROTOCOL_INFO["name"], _("Request failed"), data["error"]) log.logger.error("%s", logstr) return [{"error": {"type": "auth", "account": self.account, "message": data["error"]}}] elif isinstance(data, str): logstr = """%s: %s - %s""" % (PROTOCOL_INFO["name"], _("Request failed"), data) log.logger.error("%s", logstr) return [{"error": {"type": "request", "account": self.account, "message": data}}] if parse == "list": return [self._list(l) for l in data["lists"]] if single: return [getattr(self, "_%s" % parse)(data)] if parse: return [getattr(self, "_%s" % parse)(m) for m in data] else: return [] def _search(self, **args): data = network.Download("http://api.t.sohu.com/search.json", util.compact(args)) data = data.get_json()["results"] return [self._result(m) for m in data] def __call__(self, opname, **args): return getattr(self, opname)(**args) def receive(self, count=util.COUNT, since=None): return self._get("statuses/home_timeline.json", count=count, since_id=since) def user_messages(self, id=None, count=util.COUNT, since=None): return self._get("statuses/user_timeline.json", id=id, count=count, since_id=since) def responses(self, count=util.COUNT, since=None): return self._get("statuses/mentions.json", count=count, since_id=since) def private(self, count=util.COUNT, since=None): private = self._get("direct_messages.json", "private", count=count, since_id=since) or [] private_sent = self._get("direct_messages/sent.json", "private", count=count, since_id=since) or [] return private + private_sent def public(self): return self._get("statuses/public_timeline.json") def lists(self, **args): following = self._get("%s/lists/subscriptions.json" % self.account["username"], "list") or [] lists = self._get("%s/lists.json" % self.account["username"], "list") or [] return following + lists def list(self, user, id, count=util.COUNT, since=None): return self._get("%s/lists/%s/statuses.json" % (user, id), per_page=count, since_id=since) def search(self, query, count=util.COUNT, since=None): return self._search(q=query, rpp=count, since_id=since) def tag(self, query, count=util.COUNT, since=None): return self._search(q="#%s" % query, count=count, since_id=since) def delete(self, message): return self._get("statuses/destroy/%s.json" % message["mid"], None, post=True, do=1) def like(self, message): return self._get("favorites/create/%s.json" % message["mid"], None, post=True, do=1) def send(self, message): return self._get("statuses/update.json", post=True, single=True, status=message) def send_private(self, message, private): return self._get("direct_messages/new.json", "private", post=True, single=True, text=message, screen_name=private["sender"]["nick"]) def send_thread(self, message, target): return self._get("statuses/update.json", post=True, single=True, status=message, in_reply_to_status_id=target["mid"]) gwibber-service-sohu-0.8.1/INSTALL0000644000175000017500000000000011551565046016420 0ustar chinesechinesegwibber-service-sohu-0.8.1/COPYING0000644000175000017500000004310311551565046016435 0ustar chinesechinese GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. 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 convey 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 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision 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, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This 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. gwibber-service-sohu-0.8.1/ui/0000755000175000017500000000000011573222032016003 5ustar chinesechinesegwibber-service-sohu-0.8.1/ui/gwibber-accounts-sohu.ui0000644000175000017500000001635711551565555022610 0ustar chinesechinese True 6 True True _Authorize True True True True False 0 True Authorize with sohu 1 0 True True Sohu authorized 0 1 0 True False 1 True 6 True 0 Account Settings: 0 True 2 3 12 6 _Send Messages True True False Allow sending posts to this account True True True 3 1 2 GTK_FILL _Receive Messages True True False Include this account when downloading messages True True True 3 GTK_FILL 1 True True True Color used to help distinguish accounts 0 Account Color: 0 True True True Color used to help distinguish accounts #000000000000 False 1 2 2 gwibber-service-sohu-0.8.1/ui/icons/0000755000175000017500000000000011573222032017116 5ustar chinesechinesegwibber-service-sohu-0.8.1/ui/icons/scalable/0000755000175000017500000000000011573222032020664 5ustar chinesechinesegwibber-service-sohu-0.8.1/ui/icons/scalable/sohu.png0000644000175000017500000001330011551601115022344 0ustar chinesechinesePNG  IHDR00W MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3bKGD pHYs  tIME( IDATh͚[eQZkKj{=V.&8ĹH$6mH(B'OEb $!<" a!.&H<%"6QgU꯿jQo|/oA 03pa;0Єx}餯?}੃Kt|=޿3ouo"+ WXy|B>>4AwC3gDa 00aalf7ZaT^@Bc#'#lWM^A4 O°W&&0l Ԣa$;(cVA-s 膑'yr|XR lѾTS5 ᘪe uH0-Au9`%$ŲP.fc{ ZoB/<ԁ"k?D*?ݎfs +-!! 庿5` fb^iy!"rF@r,!_"ls!1A3 F(2GZ[cF6X\!eZ˘ i>/܃"Z&JK5c$ a  E4n8bCa  oFrS PW98 -~;UpPrHgfh"lNWKR2J*33L3*ϲ\{qbU@X7%zpr/'Q Mס6`qg/:4OXۑ zW`TS)0/GGZ t e YXr:d5f/+y;err<u?:|/T2 <ѝSbÛ'/ Y&h.2 ea[.;;&7@3P۱-JDlLjr iC-#Es f>>xG!Wt/{!4"(B*;k<]Ҟ # vl줺H۞  ܏~>[E  @B:F[$W J I뮓d ρEŀY˄-ȓESHQ *ZU-BҊ9 <|WtC ǂaa-Lsq•pL]tmQ,tq2_!B.ʼn #Y# X!arBJDoOp.+HeJ#|p[X Cʋ|\r.c0eh"8Nb2,Fq%L]qe=yLl=b:;h5ouȅ9tźr|ݭ\({D'8*7Zj@A,D pO ;3 uFS>"sڏ0Y-B́`F#a^:}swS" -Hʎ). A,[q a[a$<] +h$2N?gΨtJWjB [MX`}\ԂG]wz`;rhcA+ktUȂN%䄥nVk)#p?XQ>`}< Y9ʅ6zgU¦vނ2C&\I%WjsW,lۃnWu1zz{եYioCa #֜i;:;=h?zA xBGm%yS.[*A4x~#2ߚ| 5+nj7*,~v\,=w?R^_@^+7vh'{zas ͎y*dvr{;vS/L.6\o۱'WjX褂yV;%9О]ӑwo|8L'J u!")4YQniNo`]N`ql<79߻Uw*FV\;c;6jb/Wca6fs*eH$$!ӧW^;ϝҕ; io]gg+@0jXqD},~Y0Șp*;^K{ u>ɥ3g|ڲ3+oxr3/mdXd<`Nַ`c,<6Zqv^v x9LkC=17ouOf4|E]Nlpz֑lYo3G :8ƚYxhMྟ5X{4ygsqۗ.4ǛCiW0@6ZÆҮI5iY6]Qa^:n1v'NrECxgO̬"KMa ]*Hfֶᦻ1bm4Z9Yp…C=vR-h\XrJX.Tsk'lʛM?*Vjgx;ť;2<) pD;^KR]ǵ+Oegg%r賨 vŸ?{nt:k !j0,FhKv.o_lk_4^Όǥcm"g/_s>q[=ߏcкY{8½p~֨')_`p? 2xL=>M I{IENDB`gwibber-service-sohu-0.8.1/ui/icons/scalable/sohu.svg0000644000175000017500000001344711551601115022373 0ustar chinesechinese image/svg+xml gwibber-service-sohu-0.8.1/ui/icons/16x16/0000755000175000017500000000000011573222032017703 5ustar chinesechinesegwibber-service-sohu-0.8.1/ui/icons/16x16/sohu.png0000600000175000017500000000122511551573237021373 0ustar chinesechinesePNG  IHDRasBIT|dLIDAT8=kTA{Mb4A AXh E vVZ%`E*(LV6FcXܛl80ys;+Q: 3 @E "C=A%SΙny g:jr{h~s0N%W.WJ$~ȋW( @䖖P=bs=4C? 6JfBCq=bb0F/h|Y\i([I8<89`Ff(!q`ˌ( XkN>:tvH UĤoh*68Sp (C$pM@ XB2S`: P6m#mm=({["AĩQ;H5q1` hy i,{oW9Emt S!svH8x_EǑHjlrS(n>Ans_?"\iz[cx6N5}GP"§$^_A0]!y>OlAWk g^8)cccG<וvlj~67vIENDB`gwibber-service-sohu-0.8.1/ui/icons/16x16/sohu.svg0000644000175000017500000000475411551573270021425 0ustar chinesechinese image/svg+xml gwibber-service-sohu-0.8.1/ui/icons/22x22/0000755000175000017500000000000011573222032017675 5ustar chinesechinesegwibber-service-sohu-0.8.1/ui/icons/22x22/sohu.png0000644000175000017500000000751311551601074021372 0ustar chinesechinesePNG  IHDRĴl; MiCCPPhotoshop ICC profilexڝSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/%ҟ3bKGD pHYs  tIME 2IDAT8˅ˋU֭33DT(v@\("*F\ "DŅNqk!.._Q(I|E3dUuEUq!=u;9_~dc>) Fc!\% @O({nV6n  HOߕX{۟ê]B*]Ɵ8c"v&]G d}IT +1E#^X4@ccX^=\ߒ8J%ɅXSo$a -CRIIj%U3cfőuI.օC:,:H(- J^{#G-@FQ0DH&C`D#q{NĭԨDF#qwYekd=ύ 1 {-*\QWIq"%|-2H6Wɓ- G"z 45"t U`ƨ3'NT Ɓ9? 6b3 $XMBH4j@Ba TLnr!e { +q S6Ze?I٢ /bPepZ R;ƵB]jRSU.(ˈM1BHQό2ڂ’oR5x,7ak/=0 X!޾l Ȫv޵3,4sgQUSFC.pKC}؄ i@_o>joOkHeᐵrޟ3U_qת!+ 6`Ч^H;+pλ&}~t]6c9O5'2saV;XkYʒ 5mvoG6':ѳ%6x62$R dlq"e [LLwtp=B<@ ڦ؞6Ukbn s<}fbvՑO=h8|?}\qvf^g9 %rk!?Or /K_b"*"`fnPu,YA]{'3L *7 u}G>~-HS K 2Zpm}O=pus1bow/Xll{goq;տIENDB`gwibber-service-sohu-0.8.1/ui/icons/22x22/sohu.svg0000644000175000017500000000635511551601074021410 0ustar chinesechinese image/svg+xml gwibber-service-sohu-0.8.1/MANIFEST.in0000644000175000017500000000036511571762437017150 0ustar chinesechineseinclude AUTHORS COPYING INSTALL README include MANIFEST.in MANIFEST include po/* include ui/* include ui/icons/16x16/* include ui/icons/22x22/* include ui/icons/scalable/* include __init__.py include utils.py include gtk/*.py include gtk/*/*.py gwibber-service-sohu-0.8.1/gtk/0000755000175000017500000000000011573222032016153 5ustar chinesechinesegwibber-service-sohu-0.8.1/gtk/__init__.py0000644000175000017500000000000011551565046020265 0ustar chinesechinesegwibber-service-sohu-0.8.1/gtk/sohu/0000755000175000017500000000000011573222032017131 5ustar chinesechinesegwibber-service-sohu-0.8.1/gtk/sohu/__init__.py0000644000175000017500000001561511551762707021270 0ustar chinesechineseimport gtk, pango, webkit, gnomekeyring import urllib, urllib2, json, urlparse, uuid from oauth import oauth from gtk import Builder from gwibber.microblog.util import resources import gettext from gettext import gettext as _ if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('gwibber','UTF-8') gettext.textdomain('gwibber-service-sohu') import sohu.utils gtk.gdk.threads_init() sigmeth = oauth.OAuthSignatureMethod_HMAC_SHA1() class AccountWidget(gtk.VBox): """AccountWidget: A widget that provides a user interface for configuring sohu accounts in Gwibber """ def __init__(self, account=None, dialog=None): """Creates the account pane for configuring Sohu accounts""" gtk.VBox.__init__( self, False, 20 ) self.ui = gtk.Builder() self.ui.set_translation_domain ("gwibber") self.ui.add_from_file (resources.get_ui_asset("gwibber-accounts-sohu.ui")) self.ui.connect_signals(self) self.vbox_settings = self.ui.get_object("vbox_settings") self.pack_start(self.vbox_settings, False, False) self.show_all() self.account = account or {} self.dialog = dialog has_secret_key = True if self.account.has_key("id"): try: value = gnomekeyring.find_items_sync(gnomekeyring.ITEM_GENERIC_SECRET, {"id": str("%s/%s" % (self.account["id"], "secret_token"))})[0].secret except gnomekeyring.NoMatchError: has_secret_key = False try: if self.account.has_key("access_token") and self.account.has_key("secret_token") and self.account.has_key("username") and has_secret_key and not self.dialog.condition: self.ui.get_object("hbox_sohu_auth").hide() self.ui.get_object("sohu_auth_done_label").set_label(_("%s has been authorized by Sohu") % self.account["username"]) self.ui.get_object("hbox_sohu_auth_done").show() else: self.ui.get_object("hbox_sohu_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object('vbox_create').hide() except: self.ui.get_object("hbox_sohu_auth_done").hide() if self.dialog.ui: self.dialog.ui.get_object("vbox_create").hide() def on_sohu_auth_clicked(self, widget, data=None): self.winsize = self.window.get_size() web = webkit.WebView() web.get_settings().set_property("enable-plugins", False) web.load_html_string(_("

Please wait...

"), "file:///") self.consumer = oauth.OAuthConsumer(*sohu.utils.get_sohu_keys()) request = oauth.OAuthRequest.from_consumer_and_token(self.consumer, http_method="POST", callback="http://gwibber.com/0/auth.html", http_url="http://api.t.sohu.com/oauth/request_token") request.sign_request(sigmeth, self.consumer, token=None) tokendata = urllib2.urlopen(request.http_url, request.to_postdata()).read() self.token = oauth.OAuthToken.from_string(tokendata) #url = "http://api.t.sohu.com/oauth/authorize?oauth_token=" + self.token.key url = "http://api.t.sohu.com/oauth/authorize?oauth_token=%s&oauth_callback=%s&display=popup" % ( self.token.key, "http://gwibber.com/0/auth.html" ) web.load_uri(url) web.set_size_request(550, 400) web.connect("title-changed", self.on_sohu_auth_title_change) self.scroll = gtk.ScrolledWindow() self.scroll.add(web) self.pack_start(self.scroll, True, True, 0) self.show_all() self.ui.get_object("vbox1").hide() self.ui.get_object("vbox_advanced").hide() self.dialog.infobar.set_message_type(gtk.MESSAGE_INFO) def on_sohu_auth_title_change(self, web=None, title=None, data=None): saved = False if title.get_title() == "Success": if hasattr(self.dialog, "infobar_content_area"): for child in self.dialog.infobar_content_area.get_children(): child.destroy() self.dialog.infobar_content_area = self.dialog.infobar.get_content_area() self.dialog.infobar_content_area.show() self.dialog.infobar.show() message_label = gtk.Label(_("Verifying")) message_label.set_use_markup(True) message_label.set_ellipsize(pango.ELLIPSIZE_END) self.dialog.infobar_content_area.add(message_label) self.dialog.infobar.show_all() self.scroll.hide() url = web.get_main_frame().get_uri() data = urlparse.parse_qs(url.split("?", 1)[1]) self.ui.get_object("vbox1").show() self.ui.get_object("vbox_advanced").show() token = data["oauth_token"][0] verifier = data["oauth_verifier"][0] request = oauth.OAuthRequest.from_consumer_and_token( self.consumer, self.token, http_method="POST", http_url="http://api.t.sohu.com/oauth/access_token", parameters={"oauth_verifier": str(verifier)}) request.sign_request(sigmeth, self.consumer, self.token) tokendata = urllib2.urlopen(request.http_url, request.to_postdata()).read() data = urlparse.parse_qs(tokendata) atok = oauth.OAuthToken.from_string(tokendata) self.account["access_token"] = data["oauth_token"][0] self.account["secret_token"] = data["oauth_token_secret"][0] apireq = oauth.OAuthRequest.from_consumer_and_token( self.consumer, atok, http_method="GET", http_url="http://api.t.sohu.com/account/verify_credentials.json", parameters=None) apireq.sign_request(sigmeth, self.consumer, atok) account_data = json.loads(urllib2.urlopen(apireq.to_url()).read()) self.account["username"] = account_data["screen_name"] self.account["user_id"] = account_data["id"] if isinstance(account_data, dict): if account_data.has_key("id"): saved = self.dialog.on_edit_account_save() else: print "Failed" self.dialog.infobar.set_message_type(gtk.MESSAGE_ERROR) message_label.set_text(_("Authorization failed. Please try again.")) else: print "Failed" self.dialog.infobar.set_message_type(gtk.MESSAGE_ERROR) message_label.set_text(_("Authorization failed. Please try again.")) if saved: message_label.set_text(_("Successful")) self.dialog.infobar.set_message_type(gtk.MESSAGE_INFO) #self.dialog.infobar.hide() self.ui.get_object("hbox_sohu_auth").hide() self.ui.get_object("sohu_auth_done_label").set_label(_("%s has been authorized by Sohu") % str(self.account["username"])) self.ui.get_object("hbox_sohu_auth_done").show() if self.dialog.ui and self.account.has_key("id") and not saved: self.dialog.ui.get_object("vbox_save").show() elif self.dialog.ui and not saved: self.dialog.ui.get_object("vbox_create").show() self.window.resize(*self.winsize) if title.get_title() == "Failure": web.hide() self.dialog.infobar.set_message_type(gtk.MESSAGE_ERROR) message_label.set_text(_("Authorization failed. Please try again.")) self.dialog.infobar.show_all() self.ui.get_object("vbox1").show() self.ui.get_object("vbox_advanced").show() self.window.resize(*self.winsize) gwibber-service-sohu-0.8.1/setup.py0000644000175000017500000000222711573221706017112 0ustar chinesechinese#!/usr/bin/env python # from distutils.core import setup from DistUtilsExtra.command import * from glob import glob setup(name="gwibber-service-sohu", version="0.8.1", author="An Yang", author_email="an.euroford@gmail.com", url="http://launchpad.net/gwibber-service-sohu/", license="GNU General Public License (GPL)", data_files=[ ('share/gwibber/plugins/sohu', ["__init__.py", "utils.py"]), ('share/gwibber/plugins/sohu/gtk', glob("gtk/*.*")), ('share/gwibber/plugins/sohu/gtk/sohu', glob("gtk/sohu/*.*")), ('share/gwibber/plugins/sohu/ui', glob("ui/*.*")), ('share/gwibber/plugins/sohu/ui/icons/16x16', glob("ui/icons/16x16/*.*")), ('share/gwibber/plugins/sohu/ui/icons/22x22', glob("ui/icons/22x22/*.*")), ('share/gwibber/plugins/sohu/ui/icons/scalable', glob("ui/icons/scalable/*.*")), ('share/gwibber/plugins/sohu/data', glob("data/*.*")), ], cmdclass = { "build" : build_extra.build_extra, "build_i18n" : build_i18n.build_i18n, "build_help" : build_help.build_help, "build_icons" : build_icons.build_icons } ) gwibber-service-sohu-0.8.1/PKG-INFO0000644000175000017500000000041411573222032016462 0ustar chinesechineseMetadata-Version: 1.0 Name: gwibber-service-sohu Version: 0.8.1 Summary: UNKNOWN Home-page: http://launchpad.net/gwibber-service-sohu/ Author: An Yang Author-email: an.euroford@gmail.com License: GNU General Public License (GPL) Description: UNKNOWN Platform: UNKNOWN gwibber-service-sohu-0.8.1/AUTHORS0000644000175000017500000000004011551565046016443 0ustar chinesechineseAn Yang gwibber-service-sohu-0.8.1/README0000644000175000017500000000003011551565132016246 0ustar chinesechineseSohu plugin for Gwibber gwibber-service-sohu-0.8.1/setup.cfg0000644000175000017500000000014611551565174017225 0ustar chinesechinese[install] prefix = /usr [build] i18n = True icons = True [build_i18n] domain = gwibber-service-sohu gwibber-service-sohu-0.8.1/utils.py0000644000175000017500000000076411551565466017130 0ustar chinesechinesefrom os.path import join, exists, realpath import xdg def get_sohu_keys(): for dir in xdg.BaseDirectory.xdg_data_dirs: if exists (join(dir, "gwibber", "plugins", "sohu", "data", "sohu")): prv_file = join(dir, "gwibber", "plugins", "sohu", "data", "sohu") f = open(prv_file, "r") try: data = eval(f.read()) except: pass SOHU_OAUTH_KEY = data["SOHU_OAUTH_KEY"] SOHU_OAUTH_SECRET = data["SOHU_OAUTH_SECRET"] return SOHU_OAUTH_KEY, SOHU_OAUTH_SECRET