Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support for sipxmldevices package, recoded some parts

  • Loading branch information...
commit f25bc2284bc2cfc97d3b2edd38d398175375dfe6 1 parent 400de4a
@ogonbat authored
View
2  phonehub/decorators.py
@@ -14,6 +14,6 @@ def inner(request,*args,**kwargs):
if "Aastra" in partial_agent[0]:
pass
else:
- return HttpResponseRedirect(settings.LOGIN_URL)
+ return HttpResponseRedirect('settings.LOGIN_URL')
return view(request,*args,**kwargs)
return inner
View
10 phonehub/http/__init__.py
@@ -0,0 +1,10 @@
+from django.http import HttpResponse
+
+class AastraXmlResponse(HttpResponse):
+ def __init__(self, content='',encoding='UTF-8',charset="ISO-8859-1"):
+ #convert the object into a text script
+ encoding_header = '<?xml version="1.0" encoding="%s"?>' % (encoding)
+ content = encoding_header + content
+ super(AastraXmlResponse,self).__init__(content)
+ self['Content-Length'] = len(content)
+ self['Content-Type'] = "%s; charset=%s" % ("text/xml",charset)
View
0  phonehub/middleware/__init__.py
No changes.
View
29 phonehub/middleware/sipdevices.py
@@ -0,0 +1,29 @@
+'''
+Created on 07/03/2012
+
+@author: ogonbat
+'''
+import re
+class SipDevicesMiddleware(object):
+ regu_aastra = re.compile(r"Aastra6730i|Aastra6731i|Aastra6735i|Aastra6737i|Aastra6751i|Aastra51i|Aastra6753i|Aastra53i|Aastra6755i|Aastra55i|Aastra6757i|Aastra57i|Aastra6739i|Aastra6757iCT|Aastra57iCT|Aastra6757ict|Aastra57ict")
+ def process_request(self,request):
+ request.device = {}
+ if request.META.has_key('HTTP_USER_AGENT'):
+ user_agent = request.META['HTTP_USER_AGENT']
+ b = self.regu_aastra.search(user_agent)
+ if b:
+ basic_info = user_agent.split(' ')
+ request.device['model'] = basic_info[0]
+ #get mac addr and firmware version
+ basic_mac_info = basic_info[1].split(':')
+ request.device['mac'] = basic_mac_info[1]
+
+ basic_firmware_info = basic_info[2].split(':')
+ request.device['firmware'] = basic_firmware_info[1]
+ if request.META.has_key('HTTP_X_AASTRA_EXPMOD1'):
+ request.device['mod1'] = request.META['HTTP_X_AASTRA_EXPMOD1']
+ if request.META.has_key('HTTP_X_AASTRA_EXPMOD2'):
+ request.device['mod2'] = request.META['HTTP_X_AASTRA_EXPMOD2']
+ if request.META.has_key('HTTP_X_AASTRA_EXPMOD3'):
+ request.device['mod3'] = request.META['HTTP_X_AASTRA_EXPMOD3']
+ return
View
3  phonehub/tests.py
@@ -4,8 +4,7 @@
@author: ogonbat
'''
import unittest
-from phonehub.aastra.api import AastraIPPhoneTextMenu, MenuItem
-from phonehub.aastra.items import SoftKeyItem
+from sipxmldevices.aastra.api import AastraIPPhoneTextMenu, MenuItem, SoftKeyItem
class PhoneHubTestCase(unittest.TestCase):
def setUp(self):
self.textmenu = AastraIPPhoneTextMenu()
View
3  setup.py
@@ -3,12 +3,13 @@
setup(
name = "phonehub",
packages = ["phonehub"],
- version = "1.0.0",
+ version = "1.0.1",
description = "django-phonehub is a django app for simple and fast Aastra phones xml creation",
author = "Andrea Mucci",
author_email = "cingusoft@gmail.com",
url = "https://github.com/ogonbat/django-phonehub",
keywords = ["aastra", "sip", "xml", "django"],
+ requires = ['sipxmldevices'],
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
Please sign in to comment.
Something went wrong with that request. Please try again.