diff --git a/base_phone_popup/popup.py b/base_phone_popup/popup.py index d679eeb..38dffb6 100644 --- a/base_phone_popup/popup.py +++ b/base_phone_popup/popup.py @@ -86,11 +86,13 @@ class phone_common(orm.AbstractModel): def incall_notify_by_extension( self, cr, uid, number, extension_list, context=None): - assert isinstance(extension_list, list), 'extension_list must be a list' + assert isinstance(extension_list, list), \ + 'extension_list must be a list' res = self.get_record_from_phone_number( cr, uid, number, context=context) user_ids = self.pool['res.users'].search( - cr, uid, [('internal_number', 'in', extension_list)], context=context) + cr, uid, [('internal_number', 'in', extension_list)], + context=context) logger.debug( 'Notify incoming call from number %s to users %s' % (number, user_ids)) diff --git a/freeswitch_click2dial/__init__.py b/freeswitch_click2dial/__init__.py index 7d9205a..a950316 100644 --- a/freeswitch_click2dial/__init__.py +++ b/freeswitch_click2dial/__init__.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# FreeSWITCH Click2Dial module for OpenERP -# Copyright (C) 2010-2013 Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# (c) 2010-2013 Alexis de Lattre +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from . import freeswitch_click2dial from . import controller diff --git a/freeswitch_click2dial/__openerp__.py b/freeswitch_click2dial/__openerp__.py index f118a07..31a1674 100644 --- a/freeswitch_click2dial/__openerp__.py +++ b/freeswitch_click2dial/__openerp__.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# FreeSWITCH Click2dial module for OpenERP -# Copyright (C) 2010-2014 Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# (c) 2010-2014 Alexis de Lattre +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { diff --git a/freeswitch_click2dial/controller.py b/freeswitch_click2dial/controller.py index 9eff379..c9b39b9 100644 --- a/freeswitch_click2dial/controller.py +++ b/freeswitch_click2dial/controller.py @@ -1,23 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# FreeSWITCH click2dial module for OpenERP -# Copyright (C) 2014 Alexis de Lattre (alexis@via.ecp.fr) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# (c) 2014 Alexis de Lattre +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html import openerp @@ -27,5 +10,5 @@ class FreeSWITCHClick2dialController(openerp.addons.web.http.Controller): @openerp.addons.web.http.jsonrequest def get_record_from_my_channel(self, req): - res = req.session.model('freeswitch.server').get_record_from_my_channel() - return res + FreeswitchServer = req.session.model('freeswitch.server') + return FreeswitchServer.get_record_from_my_channel() diff --git a/freeswitch_click2dial/freeswitch_click2dial.py b/freeswitch_click2dial/freeswitch_click2dial.py index a3b2deb..46afbca 100644 --- a/freeswitch_click2dial/freeswitch_click2dial.py +++ b/freeswitch_click2dial/freeswitch_click2dial.py @@ -1,24 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# FreeSWITCH Click2dial module for OpenERP -# Copyright (C) 2014-2016 Trever L. Adams -# Copyright (C) 2010-2013 Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# (c) 2010-2013 Alexis de Lattre +# (c) 2014-2016 Trever L. Adams +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from openerp.osv import fields, orm from openerp.tools.translate import _ @@ -35,7 +18,8 @@ _logger = logging.getLogger(__name__) class freeswitch_server(orm.Model): - '''FreeSWITCH server object, stores the parameters of the FreeSWITCH Servers''' + '''FreeSWITCH server object, stores the parameters of the FreeSWITCH + Servers''' _name = "freeswitch.server" _description = "FreeSWITCH Servers" _columns = { @@ -232,9 +216,9 @@ class freeswitch_server(orm.Model): except Exception, e: pass raise orm.except_orm( - _("Connection Test Successfull!"), - _("OpenERP can successfully login to the FreeSWITCH Event " - "Socket.")) + _("Connection Test Successful!"), + _("OpenERP can successfully login to the FreeSWITCH Event " + "Socket.")) def _get_calling_number(self, cr, uid, context=None): user, fs_server, fs_manager = self._connect_to_freeswitch( @@ -253,7 +237,7 @@ class freeswitch_server(orm.Model): f = json.load(StringIO.StringIO(ret.getBody())) if int(f['row_count']) > 0: for x in range(0, int(f['row_count'])): - if (is_fq_res and f['rows'][x]['presence_id'] != + if (is_fq_res > 0 and f['rows'][x]['presence_id'] != user.resource): continue if (f['rows'][x]['cid_num'] == user.internal_number or @@ -275,7 +259,7 @@ class freeswitch_server(orm.Model): fs_manager.disconnect() _logger.debug("Calling party number: '%s'" % calling_party_number) - if isinstance(calling_party_number, int): + if calling_party_number and calling_party_number.isdigit(): return calling_party_number else: return False @@ -466,7 +450,6 @@ class PhoneCommon(orm.AbstractModel): channel + ' ' + fs_number + ' ' + fs_server.context + ' ' + \ '\'' + self.get_name_from_phone_number(cr, uid, fs_number) + \ '\' ' + fs_number - # raise orm.except_orm(_('Error :'), dial_string) fs_manager.api('originate', dial_string.encode('utf-8')) except Exception, e: _logger.error( diff --git a/freeswitch_click2dial/scripts/get_caller_name.py b/freeswitch_click2dial/scripts/get_caller_name.py index 7aff855..2f79293 100644 --- a/freeswitch_click2dial/scripts/get_caller_name.py +++ b/freeswitch_click2dial/scripts/get_caller_name.py @@ -1,5 +1,9 @@ #!/usr/bin/python # -*- encoding: utf-8 -*- +# (c) 2010-2014 Alexis de Lattre +# (c) 2014-2016 Trever L. Adams +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html +# flake8: noqa: E501 """ Name lookup in OpenERP for incoming and outgoing calls with an FreeSWITCH system @@ -34,8 +38,6 @@ comma (,) delimited, not :_: delimited. It is up to you to format the extensions list appropriately. The persons who are at extensions in the notify list will receive a poppup if so configured and if they are logged in. - The notify list actually shouldn't be in the cidlookup.conf, but should be - used when doing notify (in an on answer hook for example). From the dialplan, do something like this . @@ -54,25 +56,9 @@ """ __author__ = "Trever Adams " -__date__ = "May 2016" +__date__ = "August 2016" __version__ = "0.5" -# Copyright (C) 2014-2015 Trever L. Adams -# Copyright (C) 2010-2014 Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - import sys sys.path.append('.') import xmlrpclib @@ -228,7 +214,7 @@ def main(name, phone_number, options): # All SIP phones should support UTF-8... # but in case you have analog phones over TDM - # or buggy phones, you should use the command line option --ascii + # or buggy phones, you should set options["ascii"] to True below if options["ascii"]: res = convert_to_ascii(res) @@ -249,7 +235,7 @@ def application(environ, start_response): options["country"] = "US" options["lang"] = "en" options["ssl"] = False - options["ascii"] = True + options["ascii"] = False options["max_size"] = 40 parameters = parse_qs(environ.get('QUERY_STRING', '')) if 'number' in parameters: @@ -275,8 +261,10 @@ def application(environ, start_response): except: output = name + output = output.encode('utf-8') + status = '200 OK' - response_headers = [('Content-type', 'text/plain'), + response_headers = [('Content-type', 'text/plain; charset=utf-8'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]