annotate src/plugins/deprecated_misc_cs.py @ 964:e09f624d3aa9

jp: fixed missing import
author Goffi <goffi@goffi.org>
date Tue, 01 Apr 2014 21:15:35 +0200
parents 1fe00f0c9a91
children 75f3b3b430ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
4 # SAT plugin for managing xep-0045
811
1fe00f0c9a91 dates update
Goffi <goffi@goffi.org>
parents: 771
diff changeset
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Jérôme Poisson (goffi@goffi.org)
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
10 # (at your option) any later version.
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
15 # GNU Affero General Public License for more details.
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 594
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 662
diff changeset
20 from sat.core.i18n import _
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from logging import debug, info, warning, error
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.xish import domish
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from twisted.internet import protocol, defer, threads, reactor
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from twisted.words.protocols.jabber import client, jid, xmlstream
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from twisted.words.protocols.jabber import error as jab_error
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from twisted.words.protocols.jabber.xmlstream import IQ
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from twisted.web.client import getPage
440
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
28 from sat.memory.persistent import PersistentBinaryDict
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 import os.path
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30 import pdb
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from zope.interface import implements
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
33
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
34 from wokkel import disco, iwokkel, data_form
223
86d249b6d9b7 Files reorganisation
Goffi <goffi@goffi.org>
parents: 219
diff changeset
35 from sat.tools.xml_tools import XMLUI
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
36 import urllib
108
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
37 import webbrowser
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
39 from BeautifulSoup import BeautifulSoup
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
40 import re
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
42 PLUGIN_INFO = {
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
43 "name": "CouchSurfing plugin",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
44 "import_name": "CS",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
45 "type": "Misc",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
46 "protocols": [],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
47 "dependencies": [],
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
48 "main": "CS_Plugin",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
49 "handler": "no",
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
50 "description": _(u"""This plugin allow to manage your CouchSurfing account throught your SàT frontend""")
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51 }
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52
218
5c68a65548c3 Plugin CS: fixed forgotten debug stuff, CS plugin is now working again
Goffi <goffi@goffi.org>
parents: 109
diff changeset
53 AGENT = 'Salut à Toi XMPP/CS Plugin'
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
54
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
55
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
56 class CS_Plugin(object):
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58 params = """
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59 <params>
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
60 <individual>
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61 <category name="CouchSurfing">
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62 <param name="Login" type="string" />
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
63 <param name="Password" type="password" />
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64 </category>
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 </individual>
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
66 </params>
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
67 """
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
68
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
69 def __init__(self, host):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
70 info(_("Plugin CS initialization"))
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
71 self.host = host
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
72 #parameters
662
4f747d7fde8c core: importParams renamed to updateParams: it now updates the parameter instead of appending children if it find an existing one.
Goffi <goffi@goffi.org>
parents: 609
diff changeset
73 host.memory.updateParams(CS_Plugin.params)
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
74 #menu
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
75 host.importMenu(_("Plugin"), "CouchSurfing", self.menuSelected, help_string=_("Launch CoushSurfing management interface"))
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
76 self.data = {} # TODO: delete cookies/data after a while
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
77 self.host.registerGeneralCB("plugin_CS_sendMessage", self.sendMessage)
108
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
78 self.host.registerGeneralCB("plugin_CS_showUnreadMessages", self.showUnreadMessages)
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
79
440
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
80 def profileConnected(self, profile):
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
81 self.data[profile] = PersistentBinaryDict("plugin_CS", profile)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
82
440
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
83 def dataLoaded(ignore):
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
84 if not self.data[profile]:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
85 self.data[profile] = {'cookies': {}}
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
86
440
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
87 self.data[profile].load().addCallback(dataLoaded)
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
88
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
89 def profileDisconnected(self, profile):
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
90 del self.data[profile]
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
91
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
92 def erroCB(self, e, id):
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
93 """Called when something is going wrong when contacting CS website"""
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
94 #pdb.set_trace()
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
95 message_data = {"reason": "connection error", "message": _(u"Impossible to contact CS website, please check your login/password, connection or try again later")}
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
96 self.host.bridge.actionResult("ERROR", id, message_data)
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
97
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
98 def menuSelected(self, id, profile):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
99 """Called when the couchsurfing menu item is selected"""
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
100 login = self.host.memory.getParamA("Login", "CouchSurfing", profile_key=profile)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
101 password = self.host.memory.getParamA("Password", "CouchSurfing", profile_key=profile)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
102 if not login or not password:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
103 message_data = {"reason": "uncomplete", "message": _(u"You have to fill your CouchSurfing login & password in parameters before using this interface")}
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
104 self.host.bridge.actionResult("ERROR", id, message_data)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
105 return
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
107 post_data = urllib.urlencode({'auth_login[un]': login, 'auth_login[pw]': password, 'auth_login[action]': 'Login...'})
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
108
440
48277946348b plugin CS: use of PersistentBinaryData to store profile's information, and clean up on profile disconnection.
Goffi <goffi@goffi.org>
parents: 437
diff changeset
109 self.data[profile]['cookies'] = {}
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
110
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
111 d = getPage('http://www.couchsurfing.org/login.html', method='POST', postdata=post_data, headers={'Content-Type': 'application/x-www-form-urlencoded'}, agent=AGENT, cookies=self.data[profile]['cookies'])
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
112 d.addCallback(self.__connectionCB, id, profile)
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
113 d.addErrback(self.erroCB, id)
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
114
218
5c68a65548c3 Plugin CS: fixed forgotten debug stuff, CS plugin is now working again
Goffi <goffi@goffi.org>
parents: 109
diff changeset
115 #self.host.bridge.actionResult("SUPPRESS", id, {})
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
116
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
117 #pages parsing callbacks
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
118
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
119 def savePage(self, name, html):
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
120 f = open('/tmp/CS_' + name + '.html', 'w')
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
121 f.write(html)
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
122 f.close()
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
123 print "page [%s] sauvee" % name
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
124 #pdb.set_trace()
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
125
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
126 def __connectionCB(self, html, id, profile):
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
127 print 'Response received'
218
5c68a65548c3 Plugin CS: fixed forgotten debug stuff, CS plugin is now working again
Goffi <goffi@goffi.org>
parents: 109
diff changeset
128 #self.savePage('principale',html)
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
129 soup = BeautifulSoup(html)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
130 self.data[profile]['user_nick'] = soup.find('a', 'item_link', href='/home.html').contents[0]
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
131 self.data[profile]['user_name'] = soup.html.head.title.string.split(' - ')[1]
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
132 #unread messages
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
133 try:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
134 self.data[profile]['unread_messages'] = int(soup.find(lambda tag: tag.name == 'div' and ('class', 'item_bubble') in tag.attrs and tag.find('a', href="/messages.html?message_status=inbox")).find(text=True))
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
135 except:
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
136 self.data[profile]['unread_messages'] = 0
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
137 #unread couchrequest messages
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
138 try:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
139 self.data[profile]['unread_CR_messages'] = int(soup.find(lambda tag: tag.name == 'div' and ('class', 'item_bubble') in tag.attrs and tag.find('a', href="/couchmanager")).find(text=True))
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
140 except:
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
141 self.data[profile]['unread_CR_messages'] = 0
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
142
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
143 #if we have already the list of friend, no need to make new requests
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
144 if 'friends' not in self.data[profile]:
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
145 self.data[profile]['friends'] = {}
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
146 d = getPage('http://www.couchsurfing.org/connections.html?type=myfriends&show=10000', agent=AGENT, cookies=self.data[profile]['cookies'])
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
147 d.addCallback(self.__friendsPageCB, id=id, profile=profile)
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
148 d.addErrback(self.erroCB, id)
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
149 else:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
150 self.host.bridge.actionResult("XMLUI", id, {"type": "window", "xml": self.__buildUI(self.data[profile])})
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
151
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
152 def __buildUI(self, data):
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
153 """Build the XML UI of the plugin
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
154 @param data: data store for the profile"""
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
155 user_nick = data['user_nick']
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
156 user_name = data['user_name']
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
157 unread_mess = data['unread_messages']
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
158 unread_CR_mess = data['unread_CR_messages']
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
159 friends_list = data['friends'].keys()
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
160 friends_list.sort()
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
161 interface = XMLUI('window', 'tabs', title='CouchSurfing management')
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
162 interface.addCategory(_("Messages"), "vertical")
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
163 interface.addText(_("G'day %(name)s, you have %(nb_message)i unread message%(plural_mess)s and %(unread_CR_mess)s unread couch request message%(plural_CR)s\nIf you want to send a message, select the recipient(s) in the list below") % {'name': user_name, 'nb_message': unread_mess, 'plural_mess': 's' if unread_mess > 1 else '', 'unread_CR_mess': unread_CR_mess, 'plural_CR': 's' if unread_CR_mess > 1 else ''})
108
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
164 if unread_mess:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
165 interface.addButton('plugin_CS_showUnreadMessages', 'showUnreadMessages', _('Show unread message%(plural)s in external web browser') % {'plural': 's' if unread_mess > 1 else ''})
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
166 interface.addList(friends_list, 'friends', style=['multi'])
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
167 interface.changeLayout('pairs')
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
168 interface.addLabel(_("Subject"))
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
169 interface.addString('subject')
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
170 interface.changeLayout('vertical')
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
171 interface.addLabel(_("Message"))
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
172 interface.addText("(use %name% for contact name and %firstname% for guessed first name)")
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
173 interface.addTextBox('message')
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
174 interface.addButton('plugin_CS_sendMessage', 'sendMessage', _('send'), fields_back=['friends', 'subject', 'message'])
109
18b0cf49a6f1 Plugin CS minor changes (Events & Couch Search tabs temporarly removed, open_new_tab user to open link in browser)
Goffi <goffi@goffi.org>
parents: 108
diff changeset
175 #interface.addCategory(_("Events"), "vertical") #TODO: coming soon, hopefuly :)
18b0cf49a6f1 Plugin CS minor changes (Events & Couch Search tabs temporarly removed, open_new_tab user to open link in browser)
Goffi <goffi@goffi.org>
parents: 108
diff changeset
176 #interface.addCategory(_("Couch search"), "vertical")
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
177 return interface.toXml()
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
178
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
179 def __meetingPageCB(self, html):
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
180 """Called when the meeting page has been received"""
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
181
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
182 def __friendsPageCB(self, html, id, profile):
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
183 """Called when the friends list page has been received"""
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
184 self.savePage('friends', html)
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
185 soup = BeautifulSoup(html.replace('"formtable width="400', '"formtable" width="400"')) # CS html fix #TODO: report the bug to CS dev team
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
186 friends = self.data[profile]['friends']
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
187 for _tr in soup.findAll('tr', {'class': re.compile("^msgRow*")}): # we parse the row with friends infos
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
188 _nobr = _tr.find('nobr') # contain the friend name
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
189 friend_name = unicode(_nobr.string)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
190 friend_link = u'http://www.couchsurfing.org' + _nobr.parent['href']
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
191 regex_href = re.compile(r'/connections\.html\?id=([^&]+)')
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
192 a_tag = _tr.find('a', href=regex_href)
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
193 friend_id = regex_href.search(unicode(a_tag)).groups()[0]
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
194
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
195 debug(_("CS friend found: %(friend_name)s (id: %(friend_id)s, link: %(friend_link)s)") % {'friend_name': friend_name, 'friend_id': friend_id, 'friend_link': friend_link})
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
196 friends[friend_name] = {'link': friend_link, 'id': friend_id}
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
197 a = soup.find('td', 'barmiddle next').a # is there several pages ?
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
198 if a:
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
199 #yes, we parse the next page
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
200 d = getPage('http://www.couchsurfing.org/' + str(a['href']), agent=AGENT, cookies=self.data[profile]['cookies'])
106
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
201 d.addCallback(self.__friendsPageCB, id=id, profile=profile)
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
202 d.addErrback(self.erroCB, id)
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
203 else:
138d82f64b6f plugin CS: friends parsing
Goffi <goffi@goffi.org>
parents: 103
diff changeset
204 #no, we show the result
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
205 self.host.bridge.actionResult("XMLUI", id, {"type": "window", "xml": self.__buildUI(self.data[profile])})
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
206
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
207 def __sendMessage(self, answer, subject, message, data, recipient_list, id, profile):
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
208 """Send actually the message
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
209 @param subject: subject of the message
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
210 @param message: body of the message
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
211 @param data: data of the profile
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
212 @param recipient_list: list of friends names, names are removed once message is sent
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
213 @param id: id of the action
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
214 @param profile: profile who launched the action
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
215 """
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
216 if answer:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
217 if not 'Here is a copy of the email that was sent' in answer:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
218 error(_("INTERNAL ERROR: no confirmation of message sent by CS, maybe the site has been modified ?"))
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
219 #TODO: throw a warning to the frontend, saying that maybe the message has not been sent and to contact dev of this plugin
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
220 #debug(_('HTML answer: %s') % answer)
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
221 if recipient_list:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
222 recipient = recipient_list.pop()
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
223 try:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
224 friend_id = data['friends'][recipient]['id']
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
225 except KeyError:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
226 error('INTERNAL ERROR: unknown friend')
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
227 return # send an error to the frontend
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
228 mess = message.replace('%name%', recipient).replace('%firstname%', recipient.split(' ')[0])
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
229 info(_('Sending message to %s') % recipient)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
230 debug(_("\nsubject: %(subject)s\nmessage: \n---\n%(message)s\n---\n\n") % {'subject': subject, 'message': mess})
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
231 post_data = urllib.urlencode({'email[subject]': subject.encode('utf-8'), 'email[body]': mess.encode('utf-8'), 'email[id]': friend_id, 'email[action]': 'Send Message', 'email[replied_id]': '', 'email[couchsurf]': '', 'email[directions_to_add]': ''})
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
232 d = getPage("http://www.couchsurfing.org/send_message.html", method='POST', postdata=post_data, headers={'Content-Type': 'application/x-www-form-urlencoded'}, agent=AGENT, cookies=data['cookies'])
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
233 d.addCallback(self.__sendMessage, subject, message, data, recipient_list, id, profile)
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
234 d.addErrback(self.erroCB, id)
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
235 else:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
236 interface = XMLUI('window', title=_('Message sent')) # TODO: create particular actionResult for alerts ?
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
237 interface.addText(_('The message has been sent to every recipients'))
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
238 self.host.bridge.actionResult("XMLUI", id, {"type": "window", "xml": interface.toXml()})
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
239
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
240 def sendMessage(self, id, data, profile):
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
241 """Called to send a message to a friend
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
242 @param data: dict with the following keys:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
243 friend: name of the recipient
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
244 subject: subject of the message
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
245 message: body of the message, with the following special keywords:
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
246 - %name%: name of the friend
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
247 - %firstname%: guessed first name of the friend (currently the first part of the name)
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
248 """
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
249 if not data['friends']:
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
250 message_data = {"reason": "bad data", "message": _(u"There is not recipient selected for this message !")}
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
251 self.host.bridge.actionResult("ERROR", id, message_data)
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
252 return
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
253 friends = data['friends'].split('\t')
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
254 subject = data['subject']
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
255 message = data['message']
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
256 info(_("sending message to %(friends)s with subject [%(subject)s]" % {'friends': friends, 'subject': subject}))
107
5ae370c71803 CS: message sending is now working
Goffi <goffi@goffi.org>
parents: 106
diff changeset
257 self.__sendMessage(None, subject, message, self.data[profile], friends, id, profile)
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
258
108
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
259 def __showUnreadMessages2(self, html, id, profile):
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
260 """Called when the inbox page has been received"""
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
261 #FIXME: that's really too fragile, only works if the unread messages are in the first page, and it would be too resources consuming for the website to DL each time all pages. In addition, the show attribute doesn't work as expected.
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
262 soup = BeautifulSoup(html)
594
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
263 for tag in soup.findAll(lambda tag: tag.name == 'strong' and tag.a and tag.a['href'].startswith('messages.html?message_status=inbox')):
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
264 link = "http://www.couchsurfing.org/" + str(tag.a['href'])
e629371a28d3 Fix pep8 support in src/plugins.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
265 webbrowser.open_new_tab(link) # TODO: the web browser need to already have CS cookies (i.e. already be opened & logged on CS, or be permanently loggued), a warning to the user should be sent/or a balloon-tip
108
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
266
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
267 def showUnreadMessages(self, id, data, profile):
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
268 """Called when user want to see all unread messages in the external browser"""
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
269 d = getPage("http://www.couchsurfing.org/messages.html?message_status=inbox&show=10000", agent=AGENT, cookies=self.data[profile]['cookies'])
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
270 d.addCallback(self.__showUnreadMessages2, id, profile)
e24e080e6b16 CS plugin: unread messages can now be openned in external web browser
Goffi <goffi@goffi.org>
parents: 107
diff changeset
271 d.addErrback(self.erroCB, id)