def __init__(self, global_config, aor, contact, user=None, passw=None, exp=180, rok_cb=None, rfail_cb=None, cb_arg=None, target=None): self.global_config = global_config self.user = user self.passw = passw self.rok_cb = rok_cb self.rfail_cb = rfail_cb self.cb_arg = cb_arg ruri = aor.getCopy() ruri.username = None aor.port = None tfaddr = SipAddress(url=aor) fr0m = SipFrom(address=tfaddr.getCopy()) fr0m.genTag() to = SipTo(address=tfaddr) contact = SipContact(address=SipAddress(url=contact)) contact.address.params['expires'] = '180' self.rmsg = SipRequest(method='REGISTER', ruri=ruri, fr0m=fr0m, contact=contact, to=to, target=target)
class SipAddressHF(SipGenericHF): address = None relaxedparser = False def __init__(self, body = None, address = None): SipGenericHF.__init__(self, body) if body != None: csvs = [] pidx = 0 while 1: idx = body.find(',', pidx) if idx == -1: break; onum = body[:idx].count('<') cnum = body[:idx].count('>') qnum = body[:idx].count('"') if (onum == 0 and cnum == 0 and qnum == 0) or (onum > 0 and \ onum == cnum and (qnum % 2 == 0)): csvs.append(body[:idx]) body = body[idx + 1:] pidx = 0 else: pidx = idx + 1 if (len(csvs) > 0): csvs.append(body) raise ESipHeaderCSV(None, csvs) else: self.parsed = True self.address = address def parse(self): self.address = SipAddress(self.body, relaxedparser = self.relaxedparser) self.parsed = True def __str__(self): return self.localStr() def localStr(self, local_addr = None, local_port = None): if not self.parsed: return self.body return self.address.localStr(local_addr, local_port) def getCopy(self): if not self.parsed: oret = self.__class__(self.body) else: oret = self.__class__(address = self.address.getCopy()) oret.relaxedparser = self.relaxedparser return oret def setBody(self, body): self.address = body def getUri(self): return self.address def getUrl(self): return self.address.url
class SipAddressHF(SipGenericHF): address = None relaxedparser = False def __init__(self, body=None, address=None): SipGenericHF.__init__(self, body) if body != None: csvs = [] pidx = 0 while 1: idx = body.find(',', pidx) if idx == -1: break onum = body[:idx].count('<') cnum = body[:idx].count('>') qnum = body[:idx].count('"') if (onum == 0 and cnum == 0 and qnum == 0) or (onum > 0 and \ onum == cnum and (qnum % 2 == 0)): csvs.append(body[:idx]) body = body[idx + 1:] pidx = 0 else: pidx = idx + 1 if (len(csvs) > 0): csvs.append(body) raise ESipHeaderCSV(None, csvs) else: self.parsed = True self.address = address def parse(self): self.address = SipAddress(self.body, relaxedparser=self.relaxedparser) self.parsed = True def __str__(self): return self.localStr() def localStr(self, local_addr=None, local_port=None): if not self.parsed: return self.body return self.address.localStr(local_addr, local_port) def getCopy(self): if not self.parsed: oret = self.__class__(self.body) else: oret = self.__class__(address=self.address.getCopy()) oret.relaxedparser = self.relaxedparser return oret def setBody(self, body): self.address = body def getUri(self): return self.address def getUrl(self): return self.address.url
def __init__(self, global_config, aor, contact, user = None, passw = None, exp = 180, rok_cb = None, rfail_cb = None, cb_arg = None, target = None): self.global_config = global_config self.user = user self.passw = passw self.rok_cb = rok_cb self.rfail_cb = rfail_cb self.cb_arg = cb_arg ruri = aor.getCopy() ruri.username = None aor.port = None tfaddr = SipAddress(url = aor) fr0m = SipFrom(address = tfaddr.getCopy()) fr0m.genTag() to = SipTo(address = tfaddr) contact = SipContact(address = SipAddress(url = contact)) contact.address.params['expires'] = '180' self.rmsg = SipRequest(method = 'REGISTER', ruri = ruri, fr0m = fr0m, contact = contact, to = to, target = target)