# Path: resources/lib/PhoneBooks/PhoneBookFacade.py
# class PhoneBookFacade(PhoneBookBase):
#     def __init__(self, imagepath):
#         PhoneBookBase.__init__(self, imagepath)
#         self._phoneBooks = []
#         for phone_book in _find_phone_book_classes():
#             self._phoneBooks.append(phone_book(imagepath))
# 
#     def set_settings(self, settings):
#         for phone_book in self._phoneBooks:
#             phone_book.set_settings(settings)
# 
#     def get_setting_keys(self):
#         merged_settings = {}
#         for phone_book in self._phoneBooks:
#             merged_settings.update(phone_book.get_setting_keys())
#         return merged_settings
# 
#     def imagecount(self):
#         count = 0
#         for phone_book in self._phoneBooks:
#             count += phone_book.imagecount()
#         return count
# 
#     def compareNumbers(self, a, b, ccode='0049'):
# 
#         a = str(re.sub('[^0-9\+\*]|((?<!\A)\+)', '', a))
#         b = str(re.sub('[^0-9\+\*]|((?<!\A)\+)', '', b))
# 
#         if a.startswith(ccode): a = '0' + a[len(ccode):]
#         if a.startswith('+'): a = '0' + a[3:]
# 
#         if b.startswith(ccode): b = '0' + b[len(ccode):]
#         if b.startswith('+'): b = '0' + b[3:]
# 
#         # a = a[-len(b):]
#         # b = b[-len(a):]
# 
#         return (a == b)
# 
#     def getPhonebook(self):
#         phone_books = {}
#         for phone_book in self._phoneBooks:
#             phone_books.update(phone_book.getPhonebook())
#         return phone_books


import socket
import os
import sys
import xbmc
import xbmcaddon
import xbmcgui
import re
import resources.lib.tools as tools
from resources.lib.PhoneBooks.PhoneBookFacade import PhoneBookFacade
                    self['sip'] = token[6]

                elif self.command == 'RING':
                    self['date'] = token[0]
                    self['number_caller'] = token[3]
                    self['number_called'] = token[4]
                    self['sip'] = token[5]

                elif self.command == 'CONNECT':
                    self['date'] = token[0]
                    self['extension'] = token[3]
                    self['number'] = token[4]

                elif self.command == 'DISCONNECT':
                    self['date'] = token[0]
                    self['duration'] = token[3]

        def __getattr__(self, item):
            if item in self:
                return self[item]
            else:
                return False

    # END OF CLASS CallMonitorLine #

    # Get the Phonebook

    def getPhonebook(self):

        if self.__phoneBookFacade is None:

# Path: resources/lib/PhoneBooks/PhoneBookFacade.py
# class PhoneBookFacade(PhoneBookBase):
#     def __init__(self, imagepath):
#         PhoneBookBase.__init__(self, imagepath)
#         self._phoneBooks = []
#         for phone_book in _find_phone_book_classes():
#             self._phoneBooks.append(phone_book(imagepath))
# 
#     def set_settings(self, settings):
#         for phone_book in self._phoneBooks:
#             phone_book.set_settings(settings)
# 
#     def get_setting_keys(self):
#         merged_settings = {}
#         for phone_book in self._phoneBooks:
#             merged_settings.update(phone_book.get_setting_keys())
#         return merged_settings
# 
#     def imagecount(self):
#         count = 0
#         for phone_book in self._phoneBooks:
#             count += phone_book.imagecount()
#         return count
# 
#     def compareNumbers(self, a, b, ccode='0049'):
# 
#         a = str(re.sub('[^0-9\+\*]|((?<!\A)\+)', '', a))
#         b = str(re.sub('[^0-9\+\*]|((?<!\A)\+)', '', b))
# 
#         if a.startswith(ccode): a = '0' + a[len(ccode):]
#         if a.startswith('+'): a = '0' + a[3:]
# 
#         if b.startswith(ccode): b = '0' + b[len(ccode):]
#         if b.startswith('+'): b = '0' + b[3:]
# 
#         # a = a[-len(b):]
#         # b = b[-len(a):]
# 
#         return (a == b)
# 
#     def getPhonebook(self):
#         phone_books = {}
#         for phone_book in self._phoneBooks:
#             phone_books.update(phone_book.getPhonebook())
#         return phone_books


# Path: default.py
import socket
import os
import sys
import xbmc
import xbmcaddon
import xbmcgui
import re
import resources.lib.tools as tools
from resources.lib.PhoneBooks.PhoneBookFacade import PhoneBookFacade

                    self['sip'] = token[6]

                elif self.command == 'RING':
                    self['date'] = token[0]
                    self['number_caller'] = token[3]
                    self['number_called'] = token[4]
                    self['sip'] = token[5]

                elif self.command == 'CONNECT':
                    self['date'] = token[0]
                    self['extension'] = token[3]
                    self['number'] = token[4]

                elif self.command == 'DISCONNECT':
                    self['date'] = token[0]
                    self['duration'] = token[3]

        def __getattr__(self, item):
            if item in self:
                return self[item]
            else:
                return False

    # END OF CLASS CallMonitorLine #

    # Get the Phonebook

    def getPhonebook(self):

        if self.__phoneBookFacade is None:

            self.__phoneBookFacade = PhoneBookFacade(imagepath=IMAGECACHE)