annotate sat/plugins/plugin_exp_invitation_file.py @ 2917:adf6e33a3e50

plugin invitation file: wrong plugin had been uploaded: this patch remove the test pluging erroneously uploaded, and add the right one instead
author Goffi <goffi@goffi.org>
date Fri, 26 Apr 2019 11:57:26 +0200
parents
children b256e90612d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2917
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin to detect language (experimental)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 from sat.core.i18n import _
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core.constants import Const as C
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.log import getLogger
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from twisted.words.protocols.jabber import jid
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 log = getLogger(__name__)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 PLUGIN_INFO = {
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 C.PI_NAME: "File Sharing Invitation",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 C.PI_IMPORT_NAME: "FILE_SHARING_INVITATION",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 C.PI_TYPE: "EXP",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 C.PI_PROTOCOLS: [],
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 C.PI_DEPENDENCIES: ["XEP-0329", u"INVITATION"],
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 C.PI_RECOMMENDATIONS: [],
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 C.PI_MAIN: "FileSharingInvitation",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 C.PI_HANDLER: "no",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_DESCRIPTION: _(u"Experimental handling of invitations for file sharing"),
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 }
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
39
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 class FileSharingInvitation(object):
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
42
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 def __init__(self, host):
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 log.info(_(u"File Sharing Invitation plugin initialization"))
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 self.host = host
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 ns_fis = host.getNamespace(u"fis")
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 host.plugins[u"INVITATION"].registerNamespace(ns_fis, self.onInvitation)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 host.bridge.addMethod(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 "FISInvite",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 ".plugin",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 in_sign="sssssss",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 out_sign="",
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 method=self._sendFileSharingInvitation,
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 )
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
55
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 def _sendFileSharingInvitation(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None,
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 name=None, profile_key=C.PROF_KEY_NONE):
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 client = self.host.getClient(profile_key)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 invitee_jid = jid.JID(invitee_jid_s)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 service = jid.JID(service_s)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 return self.host.plugins[u"INVITATION"].sendFileSharingInvitation(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 client, invitee_jid, service, repos_type=None, namespace=None, path=None,
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 name=None)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def onInvitation(self, client, service, repos_type, namespace, path, name):
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 if repos_type == u"files":
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 type_human = _(u"file sharing")
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 elif repos_type == u"photos":
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
70 type_human = _(u"photos album")
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 else:
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 log.warning(u"Unknown repository type: {repos_type}".format(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 repos_type=repos_type))
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 repos_type = u"file"
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 type_human = _(u"file sharing")
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 log.info(_(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 u'{profile} has received an invitation for a files repository ({type_human}) '
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 u'with namespace "{namespace}" at path [{path}]').format(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 profile=client.profile, type_human=type_human, namespace=namespace, path=path)
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 )
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 return self.host.plugins[u'LIST_INTEREST'].registerFileSharing(
adf6e33a3e50 plugin invitation file: wrong plugin had been uploaded:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 client, service, repos_type, namespace, path, name)