Merge lp:~seriy-pr/gwibber/vkontakte-ru-plugin into lp:gwibber
- vkontakte-ru-plugin
- Merge into trunk
Status: | Rejected | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Rejected by: | Ken VanDine | ||||||||||||||||||||
Proposed branch: | lp:~seriy-pr/gwibber/vkontakte-ru-plugin | ||||||||||||||||||||
Merge into: | lp:gwibber | ||||||||||||||||||||
Diff against target: |
1212 lines (+1149/-2) 7 files modified
.bzrignore (+0/-2) gwibber/microblog/plugins/vkontakte/__init__.py (+593/-0) gwibber/microblog/plugins/vkontakte/gtk/vkontakte/__init__.py (+185/-0) gwibber/microblog/plugins/vkontakte/ui/gwibber-accounts-vkontakte.ui (+227/-0) gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.svg (+55/-0) gwibber/microblog/plugins/vkontakte/vk_api_wrapper.py (+87/-0) gwibber/microblog/util/const.py.in (+2/-0) |
||||||||||||||||||||
To merge this branch: | bzr merge lp:~seriy-pr/gwibber/vkontakte-ru-plugin | ||||||||||||||||||||
Related bugs: |
|
||||||||||||||||||||
Related blueprints: |
A button to "retweet" a microblog post.
(Undefined)
Vkontakte.ru support
(Undefined)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ken VanDine | Needs Fixing | ||
Review via email: mp+61045@code.launchpad.net |
This proposal supersedes a proposal from 2011-01-27.
Commit message
Description of the change
Added plugin for vkontakte.ru ( http://
This branch contains a fix of whishlist bug #572753
Also there is a related blueprint https:/
Some peoples report that plugin works for them: https:/
- 969. By Sergey Prokhorov
-
Simplify lazy loading mechanizm
- 970. By Sergey Prokhorov
-
Linkify comments and links description
- 971. By Sergey Prokhorov
-
Add mentions support
- 972. By Sergey Prokhorov
-
Fix notifications
- 973. By Sergey Prokhorov
-
Fix right-aligned text on "\ufeff" char appears on message
- 974. By Sergey Prokhorov
-
Add support for vkontakte hashtags.
- 975. By Sergey Prokhorov
-
Merged with trunk
- 976. By Sergey Prokhorov
-
Merged with head
Sergey Prokhorov (seriy-pr) wrote : | # |
> I think this would be best as a standalone plugin, packaged separately from
> gwibber. We want to move most of the plugins out of the gwibber source and
> into separate projects. You can look at https:/
> service-sina as an example. I think we will be keeping twitter, facebook and
> g+ (when it exists) in gwibber mainline and move the rest to new source
> packages. If you have questions, please join us in #gwibber on Freenode.
>
> Thanks for the awesome work!
Ok, I think this is good idea. Also, we already has ppa for vkontakte plugin https:/
- 977. By Sergey Prokhorov
-
merged with trunk
- 978. By Sergey Prokhorov
-
Make code less ugly + replace <br> with <br/>
- 979. By Sergey Prokhorov
-
merged with trunk
- 980. By Sergey Prokhorov
-
move icons to plugin directory
- 981. By Sergey Prokhorov
-
setup.py don't used in gwibber now
- 982. By Sergey Prokhorov
-
merged with trunk
- 983. By Sergey Prokhorov
-
Fix logging issue
- 984. By Sergey Prokhorov
-
Fix indentation
- 985. By Sergey Prokhorov
-
Fix logger issue
- 986. By Sergey Prokhorov
-
More logging fixes
- 987. By Sergey Prokhorov
-
fix code conventions
- 988. By Sergey Prokhorov
-
Fix issue of renaming the vk api wrapper
- 989. By Sergey Prokhorov
-
Fix indentation on gui module
- 990. By Sergey Prokhorov
-
Compatible with 3.3.92 on ubuntu 12.04
Unmerged revisions
- 990. By Sergey Prokhorov
-
Compatible with 3.3.92 on ubuntu 12.04
- 989. By Sergey Prokhorov
-
Fix indentation on gui module
- 988. By Sergey Prokhorov
-
Fix issue of renaming the vk api wrapper
- 987. By Sergey Prokhorov
-
fix code conventions
- 986. By Sergey Prokhorov
-
More logging fixes
- 985. By Sergey Prokhorov
-
Fix logger issue
- 984. By Sergey Prokhorov
-
Fix indentation
- 983. By Sergey Prokhorov
-
Fix logging issue
- 982. By Sergey Prokhorov
-
merged with trunk
- 981. By Sergey Prokhorov
-
setup.py don't used in gwibber now
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2012-01-12 17:31:35 +0000 | |||
3 | +++ .bzrignore 2012-03-17 22:54:18 +0000 | |||
4 | @@ -1,5 +1,3 @@ | |||
5 | 1 | unknown: | ||
6 | 2 | .bzrignore | ||
7 | 3 | gwibber/semantic.cache | 1 | gwibber/semantic.cache |
8 | 4 | semantic.cache | 2 | semantic.cache |
9 | 5 | *.gmo | 3 | *.gmo |
10 | 6 | 4 | ||
11 | === added directory 'gwibber/microblog/plugins/vkontakte' | |||
12 | === added file 'gwibber/microblog/plugins/vkontakte/__init__.py' | |||
13 | --- gwibber/microblog/plugins/vkontakte/__init__.py 1970-01-01 00:00:00 +0000 | |||
14 | +++ gwibber/microblog/plugins/vkontakte/__init__.py 2012-03-17 22:54:18 +0000 | |||
15 | @@ -0,0 +1,593 @@ | |||
16 | 1 | # -*- coding: utf-8 -*- | ||
17 | 2 | ''' | ||
18 | 3 | Created on 05.12.2010 | ||
19 | 4 | |||
20 | 5 | @author: Sergey Prokhorov <root@seriyps.ru> | ||
21 | 6 | ''' | ||
22 | 7 | import json | ||
23 | 8 | import inspect | ||
24 | 9 | from gwibber.microblog.util.const import * | ||
25 | 10 | from gwibber.microblog import util | ||
26 | 11 | import time | ||
27 | 12 | import urllib | ||
28 | 13 | import re | ||
29 | 14 | import logging | ||
30 | 15 | |||
31 | 16 | |||
32 | 17 | from vk_api_wrapper import VkApi, VkException | ||
33 | 18 | # Try to import * from custom, install custom.py to include packaging | ||
34 | 19 | # customizations like distro API keys, etc | ||
35 | 20 | try: | ||
36 | 21 | from gwibber.microblog.util.custom import * | ||
37 | 22 | except: | ||
38 | 23 | pass | ||
39 | 24 | |||
40 | 25 | logger = logging.getLogger("Vkontakte") | ||
41 | 26 | logger.debug("Initializing.") | ||
42 | 27 | |||
43 | 28 | #XXX: remove me! see gwibber.microblog.util.const.VK_APP_ID | ||
44 | 29 | VK_APP_ID = "2036925" | ||
45 | 30 | |||
46 | 31 | PROTOCOL_INFO = { | ||
47 | 32 | "name": "Vkontakte", | ||
48 | 33 | "version": "0.3", | ||
49 | 34 | |||
50 | 35 | "config": [ | ||
51 | 36 | "color", | ||
52 | 37 | "receive_enabled", | ||
53 | 38 | "receive_groups", | ||
54 | 39 | "send_enabled", | ||
55 | 40 | "username", | ||
56 | 41 | "uid", | ||
57 | 42 | "private:access_token" | ||
58 | 43 | ], | ||
59 | 44 | |||
60 | 45 | "authtype": "vkontakte", | ||
61 | 46 | "color": "#45688E", # #6D8FB3 | ||
62 | 47 | |||
63 | 48 | "features": [ | ||
64 | 49 | "send", | ||
65 | 50 | "reply", | ||
66 | 51 | "receive", | ||
67 | 52 | #"thread", | ||
68 | 53 | "delete", | ||
69 | 54 | #"send_thread", | ||
70 | 55 | "like", | ||
71 | 56 | "sincetime" | ||
72 | 57 | ], | ||
73 | 58 | |||
74 | 59 | "default_streams": [ | ||
75 | 60 | "receive", | ||
76 | 61 | "images", | ||
77 | 62 | "links", | ||
78 | 63 | "videos", | ||
79 | 64 | ] | ||
80 | 65 | } | ||
81 | 66 | |||
82 | 67 | URL_PREFIX = 'http://vkontakte.ru/' | ||
83 | 68 | |||
84 | 69 | |||
85 | 70 | class attachment_processor(object): | ||
86 | 71 | """Generate attachment fields | ||
87 | 72 | http://vkontakte.ru/developers.php?o=-1&p=%D0%9E%D0%BF%D0%B8%D1%81%D0%B0%D0%BD%D0%B8%D0%B5+%D0%BF%D0%BE%D0%BB%D1%8F+attachment | ||
88 | 73 | """ | ||
89 | 74 | |||
90 | 75 | def __init__(self, client): | ||
91 | 76 | self.client = client | ||
92 | 77 | |||
93 | 78 | def _process_photo(self, attachment): | ||
94 | 79 | return ("photo", | ||
95 | 80 | photoAttachment( | ||
96 | 81 | url="{0}photo{1}_{2}".format(URL_PREFIX, | ||
97 | 82 | attachment["owner_id"], | ||
98 | 83 | attachment["pid"]), | ||
99 | 84 | picture=attachment["src"])) | ||
100 | 85 | |||
101 | 86 | _process_posted_photo = _process_photo | ||
102 | 87 | |||
103 | 88 | def _process_graffiti(self, attachment): | ||
104 | 89 | return ("photo", | ||
105 | 90 | photoAttachment( | ||
106 | 91 | url="{0}graffiti{1}?from_id={2}".format(URL_PREFIX, | ||
107 | 92 | attachment["gid"], | ||
108 | 93 | attachment["owner_id"]), | ||
109 | 94 | picture=attachment["src"])) | ||
110 | 95 | |||
111 | 96 | def _process_video(self, attachment): | ||
112 | 97 | lnk = "{0}video{1}_{2}".format(URL_PREFIX, attachment["owner_id"], | ||
113 | 98 | attachment["vid"]) | ||
114 | 99 | video_data = self.client.api.video.get(videos="{0}_{1}".format( | ||
115 | 100 | attachment["owner_id"], | ||
116 | 101 | attachment["vid"]))["response"] | ||
117 | 102 | return ("video", | ||
118 | 103 | videoAttachment( | ||
119 | 104 | url=lnk, | ||
120 | 105 | name=attachment["title"], | ||
121 | 106 | source=lnk, | ||
122 | 107 | picture=video_data[1]["image"])) | ||
123 | 108 | |||
124 | 109 | def _process_link(self, attachment): | ||
125 | 110 | l = linkAttachment( | ||
126 | 111 | name=attachment["title"], | ||
127 | 112 | url=attachment["url"], | ||
128 | 113 | description=util.linkify(attachment["description"], escape=False)) | ||
129 | 114 | if "image_src" in attachment: | ||
130 | 115 | l.picture = attachment["image_src"] | ||
131 | 116 | return "link", l | ||
132 | 117 | |||
133 | 118 | def process(self, attachment, message): | ||
134 | 119 | """find is processor has matched handler, and if yes, | ||
135 | 120 | generate attachment with this handler and merge it with | ||
136 | 121 | original message""" | ||
137 | 122 | type_ = attachment["type"] | ||
138 | 123 | processor_name = "_process_{0}".format(type_) | ||
139 | 124 | if hasattr(self, processor_name): | ||
140 | 125 | key, val = getattr(self, processor_name)(attachment[type_]) | ||
141 | 126 | setattr(message, key, val) | ||
142 | 127 | message.type = key | ||
143 | 128 | return message | ||
144 | 129 | |||
145 | 130 | |||
146 | 131 | ########### | ||
147 | 132 | # MAGICK!!! | ||
148 | 133 | ########### | ||
149 | 134 | '''vkontakte API don't return comments for wall posts, | ||
150 | 135 | but return comments count, so, we need download comments | ||
151 | 136 | for each posts with comments count > 0 by separate API query. | ||
152 | 137 | But, surprise! API don't return commenters profile data, only | ||
153 | 138 | commenter ID. That means, that we need download commenter profile | ||
154 | 139 | for each commenter. Only one good thing is that we can | ||
155 | 140 | download many profiles by single query. So, when process | ||
156 | 141 | wall posts, we insert "lazyUserLoader" fake objects in places, where | ||
157 | 142 | commenter profile must be. And ALL profiles loads only when | ||
158 | 143 | some slave object need profile data. | ||
159 | 144 | ''' | ||
160 | 145 | |||
161 | 146 | |||
162 | 147 | class lazy_profiles_loader(object): | ||
163 | 148 | '''Dispatcher, that store slaves and start | ||
164 | 149 | worker when one of slaves need data''' | ||
165 | 150 | |||
166 | 151 | def __init__(self, client): | ||
167 | 152 | ''' | ||
168 | 153 | @param client: Client's instance''' | ||
169 | 154 | self.client = client | ||
170 | 155 | self.masks = {} | ||
171 | 156 | self.results = {} | ||
172 | 157 | |||
173 | 158 | def new_mask(self, id): | ||
174 | 159 | mask = lazyUserLoader(id, self) | ||
175 | 160 | self.masks[id] = mask | ||
176 | 161 | return mask | ||
177 | 162 | |||
178 | 163 | def run(self): | ||
179 | 164 | '''magick (see comments upper) lazy worker (transform map of | ||
180 | 165 | profile id's to map of profiles)''' | ||
181 | 166 | ids = [str(k) for k in self.masks.keys()] | ||
182 | 167 | uids = ",".join(ids) | ||
183 | 168 | try: | ||
184 | 169 | profiles = self.client.api.getProfiles( | ||
185 | 170 | uids=uids, fields="uid,photo,first_name,last_name") | ||
186 | 171 | except VkException, e: | ||
187 | 172 | self.client._format_error(e) #log message to console | ||
188 | 173 | return {} | ||
189 | 174 | for profile in profiles['response']: | ||
190 | 175 | self.results[profile["uid"]] = self.client._user(profile) | ||
191 | 176 | |||
192 | 177 | def get(self, id): | ||
193 | 178 | if not self.results: | ||
194 | 179 | self.run() | ||
195 | 180 | return self.results.get(id, None) | ||
196 | 181 | |||
197 | 182 | |||
198 | 183 | ########### | ||
199 | 184 | # END MAGICK!!! | ||
200 | 185 | ########### | ||
201 | 186 | |||
202 | 187 | ########### | ||
203 | 188 | # declarative description of Gwibber message JSON structure | ||
204 | 189 | # XXX: this can/must be reused in other Gwibber plugins!!! | ||
205 | 190 | ########### | ||
206 | 191 | |||
207 | 192 | # base class | ||
208 | 193 | class jsonable(object): | ||
209 | 194 | """ | ||
210 | 195 | Allow subclass instances be represented as combination | ||
211 | 196 | of python std types (list, str, dict, int, float) that | ||
212 | 197 | can be used by json.dumps() | ||
213 | 198 | eg | ||
214 | 199 | ======================== | ||
215 | 200 | class C2(jsonable): | ||
216 | 201 | prop0="" | ||
217 | 202 | |||
218 | 203 | class C1(jsonable): | ||
219 | 204 | prop1="" # str | ||
220 | 205 | prop2=0 # int | ||
221 | 206 | prop3=0.0 # float | ||
222 | 207 | prop4={} # as is | ||
223 | 208 | prop5=("choice1", "choice2", "choice3") # one of | ||
224 | 209 | prop6=[C2, ] # list of | ||
225 | 210 | |||
226 | 211 | c1=C1(prop1="p1_val") # pass to constructor | ||
227 | 212 | c1.prop2=100500 # pass as property assignment | ||
228 | 213 | ... | ||
229 | 214 | prop5=[C2(prop0="c2_p0_val1"), C2(prop0="c2_p0_val2")] | ||
230 | 215 | |||
231 | 216 | >>> c1.to_jsonable() # return dict object | ||
232 | 217 | { | ||
233 | 218 | "prop1": "p1_val", | ||
234 | 219 | "prop2": 100500, | ||
235 | 220 | ... | ||
236 | 221 | "prop6":[ | ||
237 | 222 | { | ||
238 | 223 | "prop0": "c2_p0_val1" | ||
239 | 224 | }, | ||
240 | 225 | { | ||
241 | 226 | "prop0": "c2_p0_val2" | ||
242 | 227 | } | ||
243 | 228 | ] | ||
244 | 229 | } | ||
245 | 230 | =========================== | ||
246 | 231 | Idea came from http://code.google.com/p/gdata-python-client/source/browse/src/atom/core.py | ||
247 | 232 | "XmlElement" class | ||
248 | 233 | """ | ||
249 | 234 | _members = None | ||
250 | 235 | |||
251 | 236 | def __init__(self, **kwargs): | ||
252 | 237 | if self.__class__._members is None: | ||
253 | 238 | self.__class__._members = tuple(self.__class__._list_members()) | ||
254 | 239 | for member_name, member_type in self.__class__._members: | ||
255 | 240 | if member_name in kwargs: | ||
256 | 241 | setattr(self, member_name, kwargs[member_name]) | ||
257 | 242 | else: | ||
258 | 243 | if isinstance(member_type, list): | ||
259 | 244 | setattr(self, member_name, []) | ||
260 | 245 | else: | ||
261 | 246 | setattr(self, member_name, None) | ||
262 | 247 | |||
263 | 248 | @classmethod | ||
264 | 249 | def _list_members(cls): | ||
265 | 250 | """Introspect class properties""" | ||
266 | 251 | for pair in inspect.getmembers(cls): | ||
267 | 252 | if not pair[0].startswith('_'): | ||
268 | 253 | member_type = pair[1] | ||
269 | 254 | if (isinstance(member_type, (tuple, list, str, unicode, dict, | ||
270 | 255 | int, float, bool)) | ||
271 | 256 | or (inspect.isclass(member_type) | ||
272 | 257 | and issubclass(member_type, jsonable))): | ||
273 | 258 | yield pair | ||
274 | 259 | |||
275 | 260 | def to_jsonable(self): | ||
276 | 261 | """Recursively transform objects hierarchy to | ||
277 | 262 | hierarchy of python std types""" | ||
278 | 263 | res = {} | ||
279 | 264 | for m_name, m_type in self._members: | ||
280 | 265 | child = getattr(self, m_name) | ||
281 | 266 | if child is None: | ||
282 | 267 | continue | ||
283 | 268 | if isinstance(m_type, (str, unicode)): | ||
284 | 269 | res[m_name] = unicode(child) | ||
285 | 270 | elif isinstance(m_type, int): | ||
286 | 271 | res[m_name] = int(child) | ||
287 | 272 | elif isinstance(m_type, float): | ||
288 | 273 | res[m_name] = float(child) | ||
289 | 274 | elif isinstance(m_type, bool): | ||
290 | 275 | res[m_name] = bool(child) | ||
291 | 276 | elif isinstance(m_type, dict): # copy as is | ||
292 | 277 | res[m_name] = child | ||
293 | 278 | elif isinstance(m_type, list): | ||
294 | 279 | res[m_name] = [] | ||
295 | 280 | for subchild in child: | ||
296 | 281 | res[m_name].append(subchild.to_jsonable()) | ||
297 | 282 | elif isinstance(m_type, tuple): | ||
298 | 283 | if child in m_type: | ||
299 | 284 | res[m_name] = child | ||
300 | 285 | elif inspect.isclass(m_type) and issubclass(m_type, jsonable): | ||
301 | 286 | res[m_name] = child.to_jsonable() # recursively | ||
302 | 287 | return res | ||
303 | 288 | |||
304 | 289 | def __str__(self): | ||
305 | 290 | return str(self.to_jsonable()) | ||
306 | 291 | |||
307 | 292 | |||
308 | 293 | # Gwibber message structure hierarchy: | ||
309 | 294 | |||
310 | 295 | class errMessage(jsonable): | ||
311 | 296 | type = "" | ||
312 | 297 | account = {} | ||
313 | 298 | message = "" | ||
314 | 299 | |||
315 | 300 | |||
316 | 301 | class error(jsonable): | ||
317 | 302 | error = errMessage | ||
318 | 303 | |||
319 | 304 | |||
320 | 305 | class user(jsonable): | ||
321 | 306 | name = "" | ||
322 | 307 | id = "" | ||
323 | 308 | is_me = False | ||
324 | 309 | image = "" | ||
325 | 310 | url = "" | ||
326 | 311 | |||
327 | 312 | |||
328 | 313 | class lazyUserLoader(jsonable): | ||
329 | 314 | """Loads user profile only when to_json() called""" | ||
330 | 315 | def __init__(self, id, master, **kwargs): | ||
331 | 316 | super(lazyUserLoader, self).__init__(**kwargs) | ||
332 | 317 | self._id = id | ||
333 | 318 | self._master = master | ||
334 | 319 | |||
335 | 320 | def to_jsonable(self): | ||
336 | 321 | res = self._master.get(self._id) | ||
337 | 322 | return res.to_jsonable() if isinstance(res, jsonable) else {} | ||
338 | 323 | |||
339 | 324 | |||
340 | 325 | class like(jsonable): | ||
341 | 326 | count = 0 | ||
342 | 327 | |||
343 | 328 | |||
344 | 329 | class photoAttachment(jsonable): | ||
345 | 330 | url = "" | ||
346 | 331 | picture = "" | ||
347 | 332 | |||
348 | 333 | |||
349 | 334 | class videoAttachment(jsonable): | ||
350 | 335 | url = "" | ||
351 | 336 | name = "" | ||
352 | 337 | source = "" | ||
353 | 338 | picture = "" | ||
354 | 339 | |||
355 | 340 | |||
356 | 341 | class linkAttachment(jsonable): | ||
357 | 342 | name = "" | ||
358 | 343 | url = "" | ||
359 | 344 | description = "" | ||
360 | 345 | picture = "" | ||
361 | 346 | |||
362 | 347 | |||
363 | 348 | class comment(jsonable): | ||
364 | 349 | text = "" | ||
365 | 350 | time = "" | ||
366 | 351 | sender = lazyUserLoader | ||
367 | 352 | |||
368 | 353 | |||
369 | 354 | class message(jsonable): | ||
370 | 355 | mid = "" | ||
371 | 356 | service = "" | ||
372 | 357 | account = "" | ||
373 | 358 | time = 0 | ||
374 | 359 | sender = user | ||
375 | 360 | to_me = False | ||
376 | 361 | url = "" | ||
377 | 362 | text = "" | ||
378 | 363 | html = "" | ||
379 | 364 | content = "" | ||
380 | 365 | likes = like | ||
381 | 366 | photo = photoAttachment | ||
382 | 367 | video = videoAttachment | ||
383 | 368 | link = linkAttachment | ||
384 | 369 | type = ("photo", "video", "link") | ||
385 | 370 | comments = [comment, ] | ||
386 | 371 | |||
387 | 372 | |||
388 | 373 | ########### | ||
389 | 374 | # END declarative description of Gwibber message JSON structure | ||
390 | 375 | ########### | ||
391 | 376 | |||
392 | 377 | class Client(object): | ||
393 | 378 | |||
394 | 379 | mention_re = re.compile(r"\[id(\d+)\|(.+)\]", re.U) | ||
395 | 380 | hash_re = re.compile("#([A-Za-z0-9_]+)") | ||
396 | 381 | |||
397 | 382 | def mentify(self, text): | ||
398 | 383 | return self.mention_re.sub(r'<a href="%sid\1">\2</a>' % URL_PREFIX, | ||
399 | 384 | text) | ||
400 | 385 | |||
401 | 386 | def hashify(self, text): | ||
402 | 387 | return self.hash_re.sub( | ||
403 | 388 | r'#<a class="hash" href="{0}feed?q=%23\1§ion=search">\1</a>'.format( | ||
404 | 389 | URL_PREFIX), text) | ||
405 | 390 | |||
406 | 391 | def __init__(self, acct): | ||
407 | 392 | self.account = acct | ||
408 | 393 | self.access_token = acct.get("access_token") | ||
409 | 394 | self.api = VkApi(access_token=self.access_token) | ||
410 | 395 | self.attachment_processor = attachment_processor(self) | ||
411 | 396 | |||
412 | 397 | def __call__(self, opname, **args): | ||
413 | 398 | try: | ||
414 | 399 | ret = [item for item in getattr(self, opname)(**args) | ||
415 | 400 | if isinstance(item, jsonable)] # read all yield's | ||
416 | 401 | #for i in ret: | ||
417 | 402 | # print str(i) | ||
418 | 403 | return [item.to_jsonable() for item in ret] | ||
419 | 404 | except VkException, e: | ||
420 | 405 | return [self._format_error(e).to_jsonable()] | ||
421 | 406 | |||
422 | 407 | def _format_error(self, e, type=None, message=None): | ||
423 | 408 | logger.error('Vkontakte error #%d: "%s" in url %s', | ||
424 | 409 | e.code, e.msg, e.url) | ||
425 | 410 | if e.code in (3, 5, 7): | ||
426 | 411 | _type = "auth" | ||
427 | 412 | #elif e.code in (2, 4, 100): | ||
428 | 413 | # _type = "internal" | ||
429 | 414 | else: | ||
430 | 415 | _type = "unknown" | ||
431 | 416 | return error(error=errMessage(type=type or _type, | ||
432 | 417 | account=self.account, | ||
433 | 418 | message=message or e.msg)) | ||
434 | 419 | |||
435 | 420 | def _user(self, acc_data): | ||
436 | 421 | """Extract single user data from API response""" | ||
437 | 422 | if "gid" in acc_data: | ||
438 | 423 | return user(name=acc_data["name"], | ||
439 | 424 | id=str(acc_data["gid"] * -1), | ||
440 | 425 | is_me=False, | ||
441 | 426 | image=acc_data["photo"], | ||
442 | 427 | url="{0}sclub{1}".format(URL_PREFIX, acc_data["gid"])) | ||
443 | 428 | else: | ||
444 | 429 | return user(name=u"{0} {1}".format(acc_data["first_name"], | ||
445 | 430 | acc_data["last_name"]), | ||
446 | 431 | id=str(acc_data["uid"]), | ||
447 | 432 | is_me=acc_data["uid"] == int(self.account["uid"]), | ||
448 | 433 | image=acc_data["photo"], | ||
449 | 434 | url="{0}id{1}".format(URL_PREFIX, acc_data["uid"])) | ||
450 | 435 | |||
451 | 436 | def _message(self, item, account, comment_author_factory): | ||
452 | 437 | """Extract single message data from API response""" | ||
453 | 438 | m = message() | ||
454 | 439 | m.mid = str(item["post_id"]) | ||
455 | 440 | m.service = "vkontakte" | ||
456 | 441 | m.account = self.account["id"] | ||
457 | 442 | # XXX: WTF?!? why we don't move timezone correction to presentation | ||
458 | 443 | # logic??? We must store to DB absolute UTC timestamp!!! | ||
459 | 444 | m.time = item["date"] + time.timezone | ||
460 | 445 | m.sender = self._user(account) | ||
461 | 446 | m.url = "{0}wall{1}_{2}".format(URL_PREFIX, m.sender.id, item["post_id"]) | ||
462 | 447 | # remove strange align-right chars + opening br tags | ||
463 | 448 | m.text = item["text"].replace(u"\ufeff", "").replace("<br>", "<br/>") | ||
464 | 449 | m.html = self.hashify( | ||
465 | 450 | self.mentify( | ||
466 | 451 | util.linkify(m.text, escape=False))) | ||
467 | 452 | m.content = m.html | ||
468 | 453 | |||
469 | 454 | # find all mentions in message text where id is mine... | ||
470 | 455 | m.to_me = len([id for id, _name in self.mention_re.findall(m.text) | ||
471 | 456 | if id == self.account["uid"]]) > 0 | ||
472 | 457 | |||
473 | 458 | if item.get("likes", 0): | ||
474 | 459 | m.likes = like(count=item["likes"]["count"]) | ||
475 | 460 | |||
476 | 461 | if "attachment" in item: | ||
477 | 462 | if item["attachment"]["type"] == "audio": | ||
478 | 463 | return # FIXME: Gwibber don't support audio | ||
479 | 464 | m = self.attachment_processor.process(item["attachment"], m) | ||
480 | 465 | |||
481 | 466 | if item["comments"]["count"] > 0: | ||
482 | 467 | try: | ||
483 | 468 | comments = self.api.wall.getComments(owner_id=m.sender.id, | ||
484 | 469 | post_id=item["post_id"], | ||
485 | 470 | sort="asc", | ||
486 | 471 | count=50) | ||
487 | 472 | except VkException, e: | ||
488 | 473 | return self._format_error(e) # XXX: may be return "m" ? | ||
489 | 474 | if "response" in comments: | ||
490 | 475 | for comm in comments["response"]: | ||
491 | 476 | if not isinstance(comm, dict): | ||
492 | 477 | # drop first(?) element, because it is | ||
493 | 478 | # integer count of comments | ||
494 | 479 | continue | ||
495 | 480 | mask = comment_author_factory.new_mask(comm["uid"]) | ||
496 | 481 | m.comments.append( | ||
497 | 482 | comment( | ||
498 | 483 | text=self.hashify( | ||
499 | 484 | self.mentify( | ||
500 | 485 | util.linkify(comm["text"]))), | ||
501 | 486 | time=comm["date"], | ||
502 | 487 | sender=mask | ||
503 | 488 | ) | ||
504 | 489 | ) | ||
505 | 490 | return m | ||
506 | 491 | |||
507 | 492 | def receive(self, since=None): | ||
508 | 493 | '''Retrieve messages from friend's and own walls.''' | ||
509 | 494 | if not since: | ||
510 | 495 | since = int(time.time() - 60 * 60 * 24) # 24 hours | ||
511 | 496 | response = self.api.newsfeed.get(filters="post", | ||
512 | 497 | start_time=since)["response"] | ||
513 | 498 | |||
514 | 499 | comment_author_factory = lazy_profiles_loader(self) | ||
515 | 500 | |||
516 | 501 | profiles_by_id = {} # index user and group profiles by user id | ||
517 | 502 | for _acc in response["profiles"]: | ||
518 | 503 | profiles_by_id[_acc["uid"]] = _acc | ||
519 | 504 | if self.account["receive_groups"]: | ||
520 | 505 | for _acc in response["groups"]: | ||
521 | 506 | profiles_by_id[_acc["gid"] * -1] = _acc | ||
522 | 507 | |||
523 | 508 | for item in response["items"]: | ||
524 | 509 | #source_id > 0 for peoples and < 0 for groups | ||
525 | 510 | if item["source_id"] < 0 and not self.account["receive_groups"]: | ||
526 | 511 | continue # skip groups if "receive_groups" option disabled | ||
527 | 512 | account = profiles_by_id[item["source_id"]] | ||
528 | 513 | message = self._message(item, account, comment_author_factory) | ||
529 | 514 | yield message | ||
530 | 515 | |||
531 | 516 | for msg in self._own_wall_posts(10, comment_author_factory): | ||
532 | 517 | yield msg | ||
533 | 518 | |||
534 | 519 | def _own_wall_posts(self, count, comment_author_factory): | ||
535 | 520 | '''Download all posts user post in own wall''' | ||
536 | 521 | try: | ||
537 | 522 | response = self.api.wall.get( | ||
538 | 523 | filter="owner", count=count)["response"] | ||
539 | 524 | except VkException, e: | ||
540 | 525 | yield self._format_error(e) | ||
541 | 526 | return | ||
542 | 527 | me = None | ||
543 | 528 | for post in response: | ||
544 | 529 | if not isinstance(post, dict): | ||
545 | 530 | # skip first element - number of items | ||
546 | 531 | continue | ||
547 | 532 | post["post_id"] = post["id"] | ||
548 | 533 | post["source_id"] = post["from_id"] | ||
549 | 534 | if not me: | ||
550 | 535 | me = self.api.getProfiles( | ||
551 | 536 | uids=post["source_id"], | ||
552 | 537 | fields="uid,photo,first_name,last_name")["response"][0] | ||
553 | 538 | yield self._message(post, me, comment_author_factory) | ||
554 | 539 | |||
555 | 540 | def user_messages(self, id=None, count=util.COUNT, since=None): | ||
556 | 541 | """Messages posted by some user""" | ||
557 | 542 | raise NotImplementedError | ||
558 | 543 | #if count>100:#vk limit | ||
559 | 544 | # count = 100 | ||
560 | 545 | #comment_author_factory = lazy_profiles_loader(self) | ||
561 | 546 | #return self._own_wall_posts(count, comment_author_factory) | ||
562 | 547 | |||
563 | 548 | def send(self, message): | ||
564 | 549 | """Send new post to own wall""" | ||
565 | 550 | self.api.wall.post(message=message) | ||
566 | 551 | return self._own_wall_posts(1, lazy_profiles_loader(self)) | ||
567 | 552 | |||
568 | 553 | def send_thread(self, message, target): | ||
569 | 554 | """Send comment with text @message to post @target | ||
570 | 555 | @param message: message text | ||
571 | 556 | @param target: target post""" | ||
572 | 557 | self.api.wall.addComment(owner_id=target["sender"]["id"], | ||
573 | 558 | post_id=target["mid"], | ||
574 | 559 | text=message) | ||
575 | 560 | # Update post data | ||
576 | 561 | # XXX: this doesn't update Gwibber UI and this is a Gwibber bug... | ||
577 | 562 | return self._post_by_id(target["sender"]["id"], target["mid"]) | ||
578 | 563 | |||
579 | 564 | def _post_by_id(self, owner_id, post_id): | ||
580 | 565 | response = self.api.wall.getById( | ||
581 | 566 | posts="{0}_{1}".format(owner_id, post_id))["response"] | ||
582 | 567 | comment_author_factory = lazy_profiles_loader(self) | ||
583 | 568 | me = None | ||
584 | 569 | for post in response: | ||
585 | 570 | if not isinstance(post, dict): | ||
586 | 571 | # skip first element - number of items | ||
587 | 572 | continue | ||
588 | 573 | post["post_id"] = post["id"] | ||
589 | 574 | post["source_id"] = post["from_id"] | ||
590 | 575 | if not me: | ||
591 | 576 | me = self.api.getProfiles( | ||
592 | 577 | uids=post["source_id"], | ||
593 | 578 | fields="uid,photo,first_name,last_name")["response"][0] | ||
594 | 579 | yield self._message(post, me, comment_author_factory) | ||
595 | 580 | |||
596 | 581 | def like(self, message): | ||
597 | 582 | """Like message | ||
598 | 583 | @param message: target post you like""" | ||
599 | 584 | self.api.wall.addLike(owner_id=message["sender"]["id"], | ||
600 | 585 | post_id=message["mid"]) | ||
601 | 586 | return [] | ||
602 | 587 | |||
603 | 588 | def delete(self, message): | ||
604 | 589 | """Remove message from you wall | ||
605 | 590 | @param message: post you want to delete""" | ||
606 | 591 | self.api.wall.delete(owner_id=message["sender"]["id"], | ||
607 | 592 | post_id=message["mid"]) | ||
608 | 593 | return [] | ||
609 | 0 | 594 | ||
610 | === added directory 'gwibber/microblog/plugins/vkontakte/gtk' | |||
611 | === added file 'gwibber/microblog/plugins/vkontakte/gtk/__init__.py' | |||
612 | === added directory 'gwibber/microblog/plugins/vkontakte/gtk/vkontakte' | |||
613 | === added file 'gwibber/microblog/plugins/vkontakte/gtk/vkontakte/__init__.py' | |||
614 | --- gwibber/microblog/plugins/vkontakte/gtk/vkontakte/__init__.py 1970-01-01 00:00:00 +0000 | |||
615 | +++ gwibber/microblog/plugins/vkontakte/gtk/vkontakte/__init__.py 2012-03-17 22:54:18 +0000 | |||
616 | @@ -0,0 +1,185 @@ | |||
617 | 1 | # -*- coding: utf-8 -*- | ||
618 | 2 | ''' | ||
619 | 3 | @author: Sergey Prokhorov <me@seriyps.ru> | ||
620 | 4 | ''' | ||
621 | 5 | from gi.repository import Gdk, Gtk, WebKit, Pango | ||
622 | 6 | from gi.repository.Gtk import Builder | ||
623 | 7 | from gwibber.microblog.util import resources | ||
624 | 8 | from gwibber.microblog.util.const import * | ||
625 | 9 | from gwibber.microblog.util.keyring import get_from_keyring | ||
626 | 10 | |||
627 | 11 | try: | ||
628 | 12 | from gwibber.microblog.plugins.vkontakte.vk_api_wrapper import VkApi | ||
629 | 13 | except ImportError: | ||
630 | 14 | try: | ||
631 | 15 | from vkontakte.vk_api_wrapper import VkApi | ||
632 | 16 | except ImportError: | ||
633 | 17 | VkApi = None | ||
634 | 18 | |||
635 | 19 | import urllib | ||
636 | 20 | import urlparse | ||
637 | 21 | import logging | ||
638 | 22 | |||
639 | 23 | import gettext | ||
640 | 24 | from gettext import gettext as _ | ||
641 | 25 | if hasattr(gettext, 'bind_textdomain_codeset'): | ||
642 | 26 | gettext.bind_textdomain_codeset('gwibber', 'UTF-8') | ||
643 | 27 | gettext.textdomain('gwibber') | ||
644 | 28 | |||
645 | 29 | logger = logging.getLogger('Vkontakte') | ||
646 | 30 | logger.info('Initializing...') | ||
647 | 31 | |||
648 | 32 | # XXX: remove me! see gwibber.microblog.util.const.VK_APP_ID | ||
649 | 33 | VK_APP_ID = "2036925" | ||
650 | 34 | |||
651 | 35 | |||
652 | 36 | class AccountWidget(Gtk.VBox): | ||
653 | 37 | """AccountWidget: A widget that provides a user interface for configuring | ||
654 | 38 | Vkontakte accounts in Gwibber""" | ||
655 | 39 | |||
656 | 40 | def __init__(self, account=None, dialog=None): | ||
657 | 41 | """Creates the account pane for configuring Vkontakte accounts""" | ||
658 | 42 | Gtk.VBox.__init__(self, False, 20) | ||
659 | 43 | self._state_init() | ||
660 | 44 | if account: | ||
661 | 45 | self.account = account | ||
662 | 46 | else: | ||
663 | 47 | self.account = {} | ||
664 | 48 | self.dialog = dialog | ||
665 | 49 | self.window = dialog.dialog | ||
666 | 50 | has_access_token = True | ||
667 | 51 | if "id" in self.account: # check is current account already authorized | ||
668 | 52 | has_access_token = get_from_keyring(self.account['id'], | ||
669 | 53 | 'access_token') is not None | ||
670 | 54 | try: # if account authorized, don't show "authorize" button | ||
671 | 55 | if (self.account["access_token"] | ||
672 | 56 | and self.account["username"] | ||
673 | 57 | and has_access_token | ||
674 | 58 | and not self.dialog.condition): | ||
675 | 59 | self._state_authorized() | ||
676 | 60 | else: # else don't show "authorized" label | ||
677 | 61 | self._state_not_authorized() | ||
678 | 62 | except: | ||
679 | 63 | self._state_not_authorized() | ||
680 | 64 | |||
681 | 65 | |||
682 | 66 | def on_vk_auth_clicked(self, widget, data=None): | ||
683 | 67 | """Start embed browser and show authorization dialog""" | ||
684 | 68 | web = WebKit.WebView() | ||
685 | 69 | web.get_settings().set_property("enable-plugins", False) | ||
686 | 70 | web.load_html_string(_("<p>Please wait...</p>"), "file:///") | ||
687 | 71 | |||
688 | 72 | qstring = urllib.urlencode({ #call to vkontakte API authorization | ||
689 | 73 | "client_id": VK_APP_ID, | ||
690 | 74 | "redirect_uri": "http://vkontakte.ru/api/login_success.html", #FIXME: http://api.vkontakte.ru/blank.html don't fire "title-changed" | ||
691 | 75 | "response_type": "token", | ||
692 | 76 | "display": "popup", | ||
693 | 77 | "scope": ",".join(("video", "offline", "wall")) | ||
694 | 78 | }) | ||
695 | 79 | url = "http://api.vkontakte.ru/oauth/authorize?" + qstring | ||
696 | 80 | web.set_size_request(550, 440) | ||
697 | 81 | logger.info("Load url %s", url) | ||
698 | 82 | web.load_uri(url) | ||
699 | 83 | #http://api.vkontakte.ru/oauth/authorize?client_id=2036925&response_type=token&scope=video,offline,wal&redirect_uri=http://api.vkontakte.ru/blank.html | ||
700 | 84 | web.connect("title-changed", self.on_vk_auth_title_change) | ||
701 | 85 | self._state_show_browser(web) | ||
702 | 86 | |||
703 | 87 | def on_vk_auth_title_change(self, web=None, title=None, data=None): | ||
704 | 88 | """When user confirm or revoke authorization in embed browser""" | ||
705 | 89 | saved = False | ||
706 | 90 | url = web.get_main_frame().get_uri() | ||
707 | 91 | logger.info("title changed...") | ||
708 | 92 | if "access_token=" in url: | ||
709 | 93 | """When user successfully authorize our application, extract | ||
710 | 94 | access_token secret... | ||
711 | 95 | http://api.vkontakte.ru/blank.html#access_token=55a69...c55&expires_in=0&user_id=535...7""" | ||
712 | 96 | query_string = url.split("#", 1)[1] | ||
713 | 97 | data = urlparse.parse_qs(query_string) | ||
714 | 98 | self.account["access_token"] = str(data["access_token"][0]) | ||
715 | 99 | self.account["uid"] = data["user_id"][0] | ||
716 | 100 | if VkApi: # try retrieve user name and last name from API | ||
717 | 101 | profile = (VkApi(access_token=self.account["access_token"]) | ||
718 | 102 | .getProfiles(uids=self.account["uid"], | ||
719 | 103 | fields="first_name,last_name")) | ||
720 | 104 | self.account["username"] = u"%(first_name)s %(last_name)s" % (profile['response'][0]) | ||
721 | 105 | else: | ||
722 | 106 | self.account["username"] = "id%s" % self.account["uid"] | ||
723 | 107 | saved = self.dialog.on_edit_account_save() # store user account data | ||
724 | 108 | self._state_authorized() | ||
725 | 109 | self._state_login_success(saved) | ||
726 | 110 | self._state_hide_browser(web) | ||
727 | 111 | if "error=" in url: | ||
728 | 112 | query_string = url.split("?", 1)[1] | ||
729 | 113 | desc = urlparse.parse_qs(query_string)["error_description"][0] | ||
730 | 114 | self._state_not_authorized() | ||
731 | 115 | self._state_login_failed(_("Authentication error: %s") % desc) | ||
732 | 116 | self._state_hide_browser(web) | ||
733 | 117 | |||
734 | 118 | ### UI-manipulation methods ### | ||
735 | 119 | |||
736 | 120 | def _state_init(self): | ||
737 | 121 | """create UI from UI file""" | ||
738 | 122 | self._browser_scroll = None | ||
739 | 123 | self.ui = Gtk.Builder() | ||
740 | 124 | self.ui.set_translation_domain("gwibber") | ||
741 | 125 | self.ui.add_from_file( | ||
742 | 126 | resources.get_ui_asset("gwibber-accounts-vkontakte.ui")) | ||
743 | 127 | self.ui.connect_signals(self) # attach events (on_vk_auth_clicked) | ||
744 | 128 | self.vbox_settings = self.ui.get_object("vbox_settings") | ||
745 | 129 | self.pack_start(self.vbox_settings, False, False, 0) | ||
746 | 130 | self.show_all() | ||
747 | 131 | |||
748 | 132 | def _state_show_browser(self, web): | ||
749 | 133 | """Show webkit widget, hide settings etc..""" | ||
750 | 134 | (self.win_w, self.win_h) = self.window.get_size() | ||
751 | 135 | if not self._browser_scroll: | ||
752 | 136 | self._browser_scroll = Gtk.ScrolledWindow() | ||
753 | 137 | self.pack_start(self._browser_scroll, True, True, 0) | ||
754 | 138 | self._browser_scroll.child = None | ||
755 | 139 | self._browser_scroll.add(web) | ||
756 | 140 | self._browser_scroll.set_size_request(550, 440) | ||
757 | 141 | self.show_all() | ||
758 | 142 | self.dialog.infobar.hide() | ||
759 | 143 | self.ui.get_object("vbox1").hide() | ||
760 | 144 | self.ui.get_object("vbox_advanced").hide() | ||
761 | 145 | |||
762 | 146 | def _state_hide_browser(self, web): | ||
763 | 147 | """Hide webkit, show advanced settings, etc..""" | ||
764 | 148 | web.hide() | ||
765 | 149 | self.window.resize(self.win_w, self.win_h) | ||
766 | 150 | self.ui.get_object("vbox1").show() | ||
767 | 151 | self.ui.get_object("vbox_advanced").show() | ||
768 | 152 | |||
769 | 153 | def _state_login_success(self, saved): | ||
770 | 154 | """Show 'update' or 'create' buttons if not saved automatically""" | ||
771 | 155 | if self.dialog.ui and "id" in self.account and not saved: | ||
772 | 156 | self.dialog.ui.get_object("vbox_save").show() | ||
773 | 157 | elif self.dialog.ui and not saved: | ||
774 | 158 | self.dialog.ui.get_object("vbox_create").show() | ||
775 | 159 | |||
776 | 160 | def _state_login_failed(self, reason=None): | ||
777 | 161 | """When user fail or revoke authorization, show popup message""" | ||
778 | 162 | Gtk.gdk.threads_enter() | ||
779 | 163 | if not reason: | ||
780 | 164 | reason = _("Vkontakte authorization failed. Please try again.") | ||
781 | 165 | else: | ||
782 | 166 | reason = _(reason) | ||
783 | 167 | d = Gtk.MessageDialog(None, Gtk.DIALOG_MODAL, Gtk.MESSAGE_ERROR, | ||
784 | 168 | Gtk.BUTTONS_OK, reason) | ||
785 | 169 | if d.run(): | ||
786 | 170 | d.destroy() | ||
787 | 171 | Gtk.gdk.threads_leave() | ||
788 | 172 | |||
789 | 173 | def _state_not_authorized(self): | ||
790 | 174 | """Show 'Authorize with vkontakte' button""" | ||
791 | 175 | self.ui.get_object("hbox_vk_auth_done").hide() | ||
792 | 176 | self.ui.get_object("hbox_vk_auth").show() | ||
793 | 177 | if self.dialog.ui: | ||
794 | 178 | self.dialog.ui.get_object('vbox_create').hide() | ||
795 | 179 | |||
796 | 180 | def _state_authorized(self): | ||
797 | 181 | """Hide 'Authorize with vkontakte' button, show 'Authorized'""" | ||
798 | 182 | self.ui.get_object("hbox_vk_auth").hide() | ||
799 | 183 | self.ui.get_object("vk_auth_done_label").set_label( | ||
800 | 184 | _("%s has been authorized by Vkontakte") % self.account["username"].encode('utf-8')) | ||
801 | 185 | self.ui.get_object("hbox_vk_auth_done").show() | ||
802 | 0 | 186 | ||
803 | === added directory 'gwibber/microblog/plugins/vkontakte/ui' | |||
804 | === added file 'gwibber/microblog/plugins/vkontakte/ui/gwibber-accounts-vkontakte.ui' | |||
805 | --- gwibber/microblog/plugins/vkontakte/ui/gwibber-accounts-vkontakte.ui 1970-01-01 00:00:00 +0000 | |||
806 | +++ gwibber/microblog/plugins/vkontakte/ui/gwibber-accounts-vkontakte.ui 2012-03-17 22:54:18 +0000 | |||
807 | @@ -0,0 +1,227 @@ | |||
808 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
809 | 2 | <interface> | ||
810 | 3 | <requires lib="gtk+" version="2.24"/> | ||
811 | 4 | <object class="GtkVBox" id="vbox_settings"> | ||
812 | 5 | <property name="visible">True</property> | ||
813 | 6 | <property name="can_focus">False</property> | ||
814 | 7 | <property name="spacing">6</property> | ||
815 | 8 | <child> | ||
816 | 9 | <object class="GtkVBox" id="vbox1"> | ||
817 | 10 | <property name="visible">True</property> | ||
818 | 11 | <property name="can_focus">False</property> | ||
819 | 12 | <child> | ||
820 | 13 | <object class="GtkHBox" id="hbox_vk_auth"> | ||
821 | 14 | <property name="visible">True</property> | ||
822 | 15 | <property name="can_focus">False</property> | ||
823 | 16 | <child> | ||
824 | 17 | <object class="GtkButton" id="vk_auth_button"> | ||
825 | 18 | <property name="label" translatable="yes">_Authorize</property> | ||
826 | 19 | <property name="visible">True</property> | ||
827 | 20 | <property name="can_focus">True</property> | ||
828 | 21 | <property name="receives_default">True</property> | ||
829 | 22 | <property name="use_action_appearance">False</property> | ||
830 | 23 | <property name="use_underline">True</property> | ||
831 | 24 | <signal name="clicked" handler="on_vk_auth_clicked" swapped="no"/> | ||
832 | 25 | </object> | ||
833 | 26 | <packing> | ||
834 | 27 | <property name="expand">True</property> | ||
835 | 28 | <property name="fill">False</property> | ||
836 | 29 | <property name="position">0</property> | ||
837 | 30 | </packing> | ||
838 | 31 | </child> | ||
839 | 32 | <child> | ||
840 | 33 | <object class="GtkLabel" id="vk_auth_label"> | ||
841 | 34 | <property name="visible">True</property> | ||
842 | 35 | <property name="can_focus">False</property> | ||
843 | 36 | <property name="label" translatable="yes">Authorize with vkontakte</property> | ||
844 | 37 | </object> | ||
845 | 38 | <packing> | ||
846 | 39 | <property name="expand">True</property> | ||
847 | 40 | <property name="fill">True</property> | ||
848 | 41 | <property name="position">1</property> | ||
849 | 42 | </packing> | ||
850 | 43 | </child> | ||
851 | 44 | </object> | ||
852 | 45 | <packing> | ||
853 | 46 | <property name="expand">True</property> | ||
854 | 47 | <property name="fill">True</property> | ||
855 | 48 | <property name="position">0</property> | ||
856 | 49 | </packing> | ||
857 | 50 | </child> | ||
858 | 51 | <child> | ||
859 | 52 | <object class="GtkHBox" id="hbox_vk_auth_done"> | ||
860 | 53 | <property name="visible">True</property> | ||
861 | 54 | <property name="can_focus">False</property> | ||
862 | 55 | <child> | ||
863 | 56 | <object class="GtkLabel" id="vk_auth_done_label"> | ||
864 | 57 | <property name="visible">True</property> | ||
865 | 58 | <property name="can_focus">False</property> | ||
866 | 59 | <property name="label" translatable="yes">Vkontakte authorized</property> | ||
867 | 60 | </object> | ||
868 | 61 | <packing> | ||
869 | 62 | <property name="expand">True</property> | ||
870 | 63 | <property name="fill">True</property> | ||
871 | 64 | <property name="position">0</property> | ||
872 | 65 | </packing> | ||
873 | 66 | </child> | ||
874 | 67 | </object> | ||
875 | 68 | <packing> | ||
876 | 69 | <property name="expand">True</property> | ||
877 | 70 | <property name="fill">True</property> | ||
878 | 71 | <property name="position">1</property> | ||
879 | 72 | </packing> | ||
880 | 73 | </child> | ||
881 | 74 | </object> | ||
882 | 75 | <packing> | ||
883 | 76 | <property name="expand">True</property> | ||
884 | 77 | <property name="fill">True</property> | ||
885 | 78 | <property name="position">0</property> | ||
886 | 79 | </packing> | ||
887 | 80 | </child> | ||
888 | 81 | <child> | ||
889 | 82 | <object class="GtkHSeparator" id="hseparator1"> | ||
890 | 83 | <property name="visible">True</property> | ||
891 | 84 | <property name="can_focus">False</property> | ||
892 | 85 | </object> | ||
893 | 86 | <packing> | ||
894 | 87 | <property name="expand">False</property> | ||
895 | 88 | <property name="fill">True</property> | ||
896 | 89 | <property name="position">1</property> | ||
897 | 90 | </packing> | ||
898 | 91 | </child> | ||
899 | 92 | <child> | ||
900 | 93 | <object class="GtkVBox" id="vbox_advanced"> | ||
901 | 94 | <property name="visible">True</property> | ||
902 | 95 | <property name="can_focus">False</property> | ||
903 | 96 | <property name="spacing">6</property> | ||
904 | 97 | <child> | ||
905 | 98 | <object class="GtkLabel" id="label3"> | ||
906 | 99 | <property name="visible">True</property> | ||
907 | 100 | <property name="can_focus">False</property> | ||
908 | 101 | <property name="xalign">0</property> | ||
909 | 102 | <property name="label" translatable="yes">Account Settings:</property> | ||
910 | 103 | <attributes> | ||
911 | 104 | <attribute name="weight" value="bold"/> | ||
912 | 105 | </attributes> | ||
913 | 106 | </object> | ||
914 | 107 | <packing> | ||
915 | 108 | <property name="expand">True</property> | ||
916 | 109 | <property name="fill">True</property> | ||
917 | 110 | <property name="position">0</property> | ||
918 | 111 | </packing> | ||
919 | 112 | </child> | ||
920 | 113 | <child> | ||
921 | 114 | <object class="GtkVBox" id="vbox2"> | ||
922 | 115 | <property name="visible">True</property> | ||
923 | 116 | <property name="can_focus">False</property> | ||
924 | 117 | <child> | ||
925 | 118 | <object class="GtkCheckButton" id="receive_enabled"> | ||
926 | 119 | <property name="label" translatable="yes">_Receive Messages</property> | ||
927 | 120 | <property name="visible">True</property> | ||
928 | 121 | <property name="can_focus">True</property> | ||
929 | 122 | <property name="receives_default">False</property> | ||
930 | 123 | <property name="tooltip_text" translatable="yes">Include this account when downloading messages</property> | ||
931 | 124 | <property name="use_action_appearance">False</property> | ||
932 | 125 | <property name="use_underline">True</property> | ||
933 | 126 | <property name="active">True</property> | ||
934 | 127 | <property name="draw_indicator">True</property> | ||
935 | 128 | </object> | ||
936 | 129 | <packing> | ||
937 | 130 | <property name="expand">True</property> | ||
938 | 131 | <property name="fill">True</property> | ||
939 | 132 | <property name="position">0</property> | ||
940 | 133 | </packing> | ||
941 | 134 | </child> | ||
942 | 135 | <child> | ||
943 | 136 | <object class="GtkCheckButton" id="send_enabled"> | ||
944 | 137 | <property name="label" translatable="yes">_Send Messages</property> | ||
945 | 138 | <property name="visible">True</property> | ||
946 | 139 | <property name="can_focus">True</property> | ||
947 | 140 | <property name="receives_default">False</property> | ||
948 | 141 | <property name="tooltip_text" translatable="yes">Allow sending posts to this account</property> | ||
949 | 142 | <property name="use_action_appearance">False</property> | ||
950 | 143 | <property name="use_underline">True</property> | ||
951 | 144 | <property name="active">True</property> | ||
952 | 145 | <property name="draw_indicator">True</property> | ||
953 | 146 | </object> | ||
954 | 147 | <packing> | ||
955 | 148 | <property name="expand">True</property> | ||
956 | 149 | <property name="fill">True</property> | ||
957 | 150 | <property name="position">1</property> | ||
958 | 151 | </packing> | ||
959 | 152 | </child> | ||
960 | 153 | <child> | ||
961 | 154 | <object class="GtkCheckButton" id="receive_groups"> | ||
962 | 155 | <property name="label" translatable="yes" comments="Receive messages from the groups, in addition to messages from users?">_Receive groups</property> | ||
963 | 156 | <property name="visible">True</property> | ||
964 | 157 | <property name="can_focus">True</property> | ||
965 | 158 | <property name="receives_default">False</property> | ||
966 | 159 | <property name="tooltip_text" translatable="yes">Receive news from groups</property> | ||
967 | 160 | <property name="use_action_appearance">False</property> | ||
968 | 161 | <property name="use_underline">True</property> | ||
969 | 162 | <property name="active">True</property> | ||
970 | 163 | <property name="draw_indicator">True</property> | ||
971 | 164 | </object> | ||
972 | 165 | <packing> | ||
973 | 166 | <property name="expand">True</property> | ||
974 | 167 | <property name="fill">True</property> | ||
975 | 168 | <property name="position">2</property> | ||
976 | 169 | </packing> | ||
977 | 170 | </child> | ||
978 | 171 | </object> | ||
979 | 172 | <packing> | ||
980 | 173 | <property name="expand">True</property> | ||
981 | 174 | <property name="fill">True</property> | ||
982 | 175 | <property name="position">1</property> | ||
983 | 176 | </packing> | ||
984 | 177 | </child> | ||
985 | 178 | <child> | ||
986 | 179 | <object class="GtkHBox" id="hbox1"> | ||
987 | 180 | <property name="visible">True</property> | ||
988 | 181 | <property name="can_focus">False</property> | ||
989 | 182 | <property name="homogeneous">True</property> | ||
990 | 183 | <child> | ||
991 | 184 | <object class="GtkLabel" id="label4"> | ||
992 | 185 | <property name="visible">True</property> | ||
993 | 186 | <property name="can_focus">False</property> | ||
994 | 187 | <property name="tooltip_text" translatable="yes">Color used to help distinguish accounts</property> | ||
995 | 188 | <property name="xalign">0</property> | ||
996 | 189 | <property name="label" translatable="yes">Account Color:</property> | ||
997 | 190 | </object> | ||
998 | 191 | <packing> | ||
999 | 192 | <property name="expand">True</property> | ||
1000 | 193 | <property name="fill">True</property> | ||
1001 | 194 | <property name="position">0</property> | ||
1002 | 195 | </packing> | ||
1003 | 196 | </child> | ||
1004 | 197 | <child> | ||
1005 | 198 | <object class="GtkColorButton" id="color"> | ||
1006 | 199 | <property name="visible">True</property> | ||
1007 | 200 | <property name="can_focus">True</property> | ||
1008 | 201 | <property name="receives_default">True</property> | ||
1009 | 202 | <property name="tooltip_text" translatable="yes">Color used to help distinguish accounts</property> | ||
1010 | 203 | <property name="use_action_appearance">False</property> | ||
1011 | 204 | <property name="color">#000000000000</property> | ||
1012 | 205 | </object> | ||
1013 | 206 | <packing> | ||
1014 | 207 | <property name="expand">False</property> | ||
1015 | 208 | <property name="fill">True</property> | ||
1016 | 209 | <property name="position">1</property> | ||
1017 | 210 | </packing> | ||
1018 | 211 | </child> | ||
1019 | 212 | </object> | ||
1020 | 213 | <packing> | ||
1021 | 214 | <property name="expand">True</property> | ||
1022 | 215 | <property name="fill">True</property> | ||
1023 | 216 | <property name="position">2</property> | ||
1024 | 217 | </packing> | ||
1025 | 218 | </child> | ||
1026 | 219 | </object> | ||
1027 | 220 | <packing> | ||
1028 | 221 | <property name="expand">True</property> | ||
1029 | 222 | <property name="fill">True</property> | ||
1030 | 223 | <property name="position">2</property> | ||
1031 | 224 | </packing> | ||
1032 | 225 | </child> | ||
1033 | 226 | </object> | ||
1034 | 227 | </interface> | ||
1035 | 0 | 228 | ||
1036 | === added directory 'gwibber/microblog/plugins/vkontakte/ui/icons' | |||
1037 | === added directory 'gwibber/microblog/plugins/vkontakte/ui/icons/16x16' | |||
1038 | === added file 'gwibber/microblog/plugins/vkontakte/ui/icons/16x16/vkontakte.png' | |||
1039 | 1 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/16x16/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/16x16/vkontakte.png 2012-03-17 22:54:18 +0000 differ | 229 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/16x16/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/16x16/vkontakte.png 2012-03-17 22:54:18 +0000 differ |
1040 | === added directory 'gwibber/microblog/plugins/vkontakte/ui/icons/22x22' | |||
1041 | === added file 'gwibber/microblog/plugins/vkontakte/ui/icons/22x22/vkontakte.png' | |||
1042 | 2 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/22x22/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/22x22/vkontakte.png 2012-03-17 22:54:18 +0000 differ | 230 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/22x22/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/22x22/vkontakte.png 2012-03-17 22:54:18 +0000 differ |
1043 | === added directory 'gwibber/microblog/plugins/vkontakte/ui/icons/32x32' | |||
1044 | === added file 'gwibber/microblog/plugins/vkontakte/ui/icons/32x32/vkontakte.png' | |||
1045 | 3 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/32x32/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/32x32/vkontakte.png 2012-03-17 22:54:18 +0000 differ | 231 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/32x32/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/32x32/vkontakte.png 2012-03-17 22:54:18 +0000 differ |
1046 | === added directory 'gwibber/microblog/plugins/vkontakte/ui/icons/scalable' | |||
1047 | === added file 'gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.png' | |||
1048 | 4 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.png 2012-03-17 22:54:18 +0000 differ | 232 | Binary files gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.png 1970-01-01 00:00:00 +0000 and gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.png 2012-03-17 22:54:18 +0000 differ |
1049 | === added file 'gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.svg' | |||
1050 | --- gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.svg 1970-01-01 00:00:00 +0000 | |||
1051 | +++ gwibber/microblog/plugins/vkontakte/ui/icons/scalable/vkontakte.svg 2012-03-17 22:54:18 +0000 | |||
1052 | @@ -0,0 +1,55 @@ | |||
1053 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
1054 | 2 | <!-- Created with Inkscape (http://www.inkscape.org/) --> | ||
1055 | 3 | <!-- SVG Created by Sergey A Prochorov <root@seriyps.ru> (http://seriyps.ru/) --> | ||
1056 | 4 | <svg | ||
1057 | 5 | xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
1058 | 6 | xmlns:cc="http://creativecommons.org/ns#" | ||
1059 | 7 | xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
1060 | 8 | xmlns:svg="http://www.w3.org/2000/svg" | ||
1061 | 9 | xmlns="http://www.w3.org/2000/svg" | ||
1062 | 10 | version="1.1" | ||
1063 | 11 | width="285" | ||
1064 | 12 | height="285" | ||
1065 | 13 | id="svg3036"> | ||
1066 | 14 | <defs | ||
1067 | 15 | id="defs8"> | ||
1068 | 16 | <filter | ||
1069 | 17 | color-interpolation-filters="sRGB" | ||
1070 | 18 | id="filter3773"> | ||
1071 | 19 | <feGaussianBlur | ||
1072 | 20 | id="feGaussianBlur3775" | ||
1073 | 21 | stdDeviation="3.931875" /> | ||
1074 | 22 | </filter> | ||
1075 | 23 | </defs> | ||
1076 | 24 | <metadata | ||
1077 | 25 | id="metadata3042"> | ||
1078 | 26 | <rdf:RDF> | ||
1079 | 27 | <cc:Work | ||
1080 | 28 | rdf:about=""> | ||
1081 | 29 | <dc:format>image/svg+xml</dc:format> | ||
1082 | 30 | <dc:type | ||
1083 | 31 | rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | ||
1084 | 32 | <dc:title></dc:title> | ||
1085 | 33 | </cc:Work> | ||
1086 | 34 | </rdf:RDF> | ||
1087 | 35 | </metadata> | ||
1088 | 36 | <g | ||
1089 | 37 | transform="translate(-45.0635,-38.936486)" | ||
1090 | 38 | id="g3796"> | ||
1091 | 39 | <rect | ||
1092 | 40 | width="168" | ||
1093 | 41 | height="197" | ||
1094 | 42 | x="108" | ||
1095 | 43 | y="87" | ||
1096 | 44 | id="rect4024" | ||
1097 | 45 | style="fill:#4c77a0;fill-opacity:1;stroke:none" /> | ||
1098 | 46 | <path | ||
1099 | 47 | d="M 102,52.5 C 78.75,55 57.625,71.25 54.5,98 l 0,170.5 c 2.875,25.25 20,43.625 46.5,46 l 168.5,0 c 22.75,-0.625 43.625,-18.125 47.25,-46.5 l 0,-169.375 C 314.25,73.875 292.375,54.5 270,52.5 l -168,0 z m 34,55.75 64.25,0 c 66,0.5 51.15504,62.271 24,68.5 44.5,3.75 50.25,82.5 -23.75,83.25 L 136.25,260 136,108.25 z m 36,27 0,31.75 18,0 c 22.1875,0 23.0625,-31.75 0,-31.75 l -18,0 z m 0,58 0,37.5 24.25,0 c 26.75,0 28,-37.5 0,-37.5 l -24.25,0 z" | ||
1100 | 48 | id="path3978" | ||
1101 | 49 | style="opacity:0.62999998;fill:#000000;fill-opacity:1;stroke:none;filter:url(#filter3773)" /> | ||
1102 | 50 | <path | ||
1103 | 51 | d="M 99,50 C 75.75,52.5 54.625,68.75 51.5,95.5 l 0,170.5 c 2.875,25.25 20,43.625 46.5,46 l 168.5,0 c 22.75,-0.625 43.625,-18.125 47.25,-46.5 l 0,-169.375 C 311.25,71.375 289.375,52 267,50 L 99,50 z m 34,55.75 64.25,0 c 66,0.5 51.15504,62.271 24,68.5 44.5,3.75 50.25,82.5 -23.75,83.25 l -64.25,0 L 133,105.75 z m 36,27 0,31.75 18,0 c 22.1875,0 23.0625,-31.75 0,-31.75 l -18,0 z m 0,58 0,37.5 24.25,0 c 26.75,0 28,-37.5 0,-37.5 l -24.25,0 z" | ||
1104 | 52 | id="path3046" | ||
1105 | 53 | style="fill:#ffffff;fill-opacity:1;stroke:none" /> | ||
1106 | 54 | </g> | ||
1107 | 55 | </svg> | ||
1108 | 0 | 56 | ||
1109 | === added file 'gwibber/microblog/plugins/vkontakte/vk_api_wrapper.py' | |||
1110 | --- gwibber/microblog/plugins/vkontakte/vk_api_wrapper.py 1970-01-01 00:00:00 +0000 | |||
1111 | +++ gwibber/microblog/plugins/vkontakte/vk_api_wrapper.py 2012-03-17 22:54:18 +0000 | |||
1112 | @@ -0,0 +1,87 @@ | |||
1113 | 1 | # -*- coding: utf-8 -*- | ||
1114 | 2 | ''' | ||
1115 | 3 | Created on 07.12.2010 | ||
1116 | 4 | |||
1117 | 5 | @author: Sergey Prokhorov <root@seriyps.ru> | ||
1118 | 6 | ''' | ||
1119 | 7 | from gwibber.microblog import network | ||
1120 | 8 | import urllib | ||
1121 | 9 | import time | ||
1122 | 10 | import logging | ||
1123 | 11 | |||
1124 | 12 | logger = logging.getLogger("Vkontakte.vk_api_wrapper") | ||
1125 | 13 | |||
1126 | 14 | |||
1127 | 15 | class VkException(Exception): | ||
1128 | 16 | |||
1129 | 17 | def __init__(self, code, msg, url, response): | ||
1130 | 18 | self.code = code | ||
1131 | 19 | self.msg = msg | ||
1132 | 20 | self.response = response | ||
1133 | 21 | self.url = url | ||
1134 | 22 | Exception.__init__(self, code, msg, url, response) | ||
1135 | 23 | |||
1136 | 24 | |||
1137 | 25 | class VkApi(object): | ||
1138 | 26 | """Vkontakte.ru (vk.com) API wrapper for Gwibber | ||
1139 | 27 | == Usage == | ||
1140 | 28 | Initialization: | ||
1141 | 29 | api=vk_api(access_token) | ||
1142 | 30 | "access_token" can be retrieved from call to http://api.vkontakte.ru/oauth/authorize | ||
1143 | 31 | (see http://vkontakte.ru/developers.php?o=-1&p=%C0%E2%F2%EE%F0%E8%E7%E0%F6%E8%FF%20%EA%EB%E8%E5%ED%F2%F1%EA%E8%F5%20%EF%F0%E8%EB%EE%E6%E5%ED%E8%E9) | ||
1144 | 32 | Make calls to simple methods (has no dots in name, like "getProfiles", "isAppUser"): | ||
1145 | 33 | res=api.method(arg_name1=arg1, arg_name2=arg2) | ||
1146 | 34 | eg res=api.getProfiles(uids="535397,1", fields="uid,first_name,last_name") | ||
1147 | 35 | Make calls to namespaced methods (has dots in name, like "wall.post", "newsfeed.get"): | ||
1148 | 36 | res=api.namespace.method(arg_name1=arg1, arg_name2=arg2) | ||
1149 | 37 | eg res=api.wall.post(message="New wall post from API") | ||
1150 | 38 | Alternative call syntax (better performance): | ||
1151 | 39 | res=api._load('namespace.method', arg_name1=arg1, arg_name2=arg2) | ||
1152 | 40 | eg res=api._get('wall.post', message="New wall post from API") | ||
1153 | 41 | """ | ||
1154 | 42 | |||
1155 | 43 | api_url = 'https://api.vkontakte.ru/method/%s' | ||
1156 | 44 | |||
1157 | 45 | def __init__(self, access_token): | ||
1158 | 46 | super(VkApi, self).__init__() | ||
1159 | 47 | self._access_token = access_token | ||
1160 | 48 | self._prefix = [] | ||
1161 | 49 | |||
1162 | 50 | def _load(self, method, **params): | ||
1163 | 51 | """Make call by method name and arguments""" | ||
1164 | 52 | params["access_token"] = self._access_token | ||
1165 | 53 | url = self.api_url % method | ||
1166 | 54 | for _i in xrange(3): | ||
1167 | 55 | # this cycle used for API error #6 "Too many requests" | ||
1168 | 56 | logger.debug("Perform API request to method %s. URL: %s?%s", | ||
1169 | 57 | method, url, urllib.urlencode(params)) | ||
1170 | 58 | res = network.Download(url, params, False).get_json() | ||
1171 | 59 | if "error" not in res: | ||
1172 | 60 | #log.logger.debug("%s"%res) | ||
1173 | 61 | return res | ||
1174 | 62 | |||
1175 | 63 | if res["error"]["error_code"] != 6: | ||
1176 | 64 | break | ||
1177 | 65 | logging.warning('Error #6 "%s". Wait 0.5s and retry...', | ||
1178 | 66 | res["error"]["error_msg"]) | ||
1179 | 67 | '''if we get error #6 "Too many requests per second" (vk allow | ||
1180 | 68 | max 3rps http://vkontakte.ru/developers.php?o=-1&p=%D0%92%D0%B7%D0%B0%D0%B8%D0%BC%D0%BE%D0%B4%D0%B5%D0%B9%D1%81%D1%82%D0%B2%D0%B8%D0%B5+%D0%BF%D1%80%D0%B8%D0%BB%D0%BE%D0%B6%D0%B5%D0%BD%D0%B8%D1%8F+%D1%81+API ) | ||
1181 | 69 | try to sleep with small delay and retry request not more then 3x times''' | ||
1182 | 70 | time.sleep(0.5)#TODO: play with sleep value | ||
1183 | 71 | raise VkException(res["error"]["error_code"], | ||
1184 | 72 | res["error"]["error_msg"], | ||
1185 | 73 | "%s?%s" % (url, urllib.urlencode(params)), | ||
1186 | 74 | res) | ||
1187 | 75 | |||
1188 | 76 | """Support for api.namespace.method(**kwargs) calls below""" | ||
1189 | 77 | def __getattr__(self, name): | ||
1190 | 78 | self._prefix.append(name) | ||
1191 | 79 | return self | ||
1192 | 80 | |||
1193 | 81 | def __call__(self, **kwargs): | ||
1194 | 82 | if self._prefix: | ||
1195 | 83 | method = ".".join(self._prefix) | ||
1196 | 84 | self._prefix = [] | ||
1197 | 85 | else: | ||
1198 | 86 | method = kwargs.pop("method") | ||
1199 | 87 | return self._load(method, **kwargs) | ||
1200 | 0 | 88 | ||
1201 | === modified file 'gwibber/microblog/util/const.py.in' | |||
1202 | --- gwibber/microblog/util/const.py.in 2012-02-23 18:02:08 +0000 | |||
1203 | +++ gwibber/microblog/util/const.py.in 2012-03-17 22:54:18 +0000 | |||
1204 | @@ -15,6 +15,8 @@ | |||
1205 | 15 | TWITTER_OAUTH_KEY = "qMBra1U4bpNYvDz947M5Q" | 15 | TWITTER_OAUTH_KEY = "qMBra1U4bpNYvDz947M5Q" |
1206 | 16 | TWITTER_OAUTH_SECRET = "Lzdkhg0WvGYFzD9tnsuwC0zYmpJ4z7HrZl3yOxU1g" | 16 | TWITTER_OAUTH_SECRET = "Lzdkhg0WvGYFzD9tnsuwC0zYmpJ4z7HrZl3yOxU1g" |
1207 | 17 | 17 | ||
1208 | 18 | VK_APP_ID="2036925" | ||
1209 | 19 | |||
1210 | 18 | # Gwibber | 20 | # Gwibber |
1211 | 19 | MAX_MESSAGE_LENGTH = 140 | 21 | MAX_MESSAGE_LENGTH = 140 |
1212 | 20 | MAX_MESSAGE_COUNT = 20000 | 22 | MAX_MESSAGE_COUNT = 20000 |
I think this would be best as a standalone plugin, packaged separately from gwibber. We want to move most of the plugins out of the gwibber source and into separate projects. You can look at https:/ /launchpad. net/gwibber- service- sina as an example. I think we will be keeping twitter, facebook and g+ (when it exists) in gwibber mainline and move the rest to new source packages. If you have questions, please join us in #gwibber on Freenode.
Thanks for the awesome work!