# Path: surveilr/config.py
# def defaults_file():
# def config_files():
# def load_default_config():
# def get_str(section, option):
# def get_int(section, option):
# def get_bool(section, option):
# 
# Path: surveilr/drivers.py
# def register_driver(driver_type, name, driver):
# def unregister_driver(driver_type, name):
# def get_driver(driver_type, name):


from surveilr import config
from surveilr import drivers
from clickatell.api import Clickatell
from clickatell import constants as cc
    License along with this program.  If not, see
    <http://www.gnu.org/licenses/>.

    Clickatell SMS driver
"""



class ClickatellMessaging(object):
    def __init__(self):
        username = config.get_str('sms', 'username')
        password = config.get_str('sms', 'password')
        api_id = config.get_str('sms', 'api_id')
        self.client = Clickatell(username, password, api_id,
                                 sendmsg_defaults={
                                    'callback': cc.YES,
                                    'msg_type': cc.SMS_DEFAULT,
                                    'deliv_ack': cc.YES,
                                    'req_feat': (cc.FEAT_ALPHA +
                                                 cc.FEAT_NUMER +
                                                 cc.FEAT_DELIVACK)
                              })

    def send(self, recipient, info):
        sender = config.get_str('sms', 'sender')
        self.client.sendmsg(recipients=[recipient.messaging_address],
                            sender=sender,
                            text=str(info))



# Path: surveilr/config.py
# def defaults_file():
# def config_files():
# def load_default_config():
# def get_str(section, option):
# def get_int(section, option):
# def get_bool(section, option):
# 
# Path: surveilr/drivers.py
# def register_driver(driver_type, name, driver):
# def unregister_driver(driver_type, name):
# def get_driver(driver_type, name):


# Path: surveilr/messaging/sms/clickatell_driver.py
from surveilr import config
from surveilr import drivers
from clickatell.api import Clickatell
from clickatell import constants as cc

    License along with this program.  If not, see
    <http://www.gnu.org/licenses/>.

    Clickatell SMS driver
"""



class ClickatellMessaging(object):
    def __init__(self):
        username = config.get_str('sms', 'username')
        password = config.get_str('sms', 'password')
        api_id = config.get_str('sms', 'api_id')
        self.client = Clickatell(username, password, api_id,
                                 sendmsg_defaults={
                                    'callback': cc.YES,
                                    'msg_type': cc.SMS_DEFAULT,
                                    'deliv_ack': cc.YES,
                                    'req_feat': (cc.FEAT_ALPHA +
                                                 cc.FEAT_NUMER +
                                                 cc.FEAT_DELIVACK)
                              })

    def send(self, recipient, info):
        sender = config.get_str('sms', 'sender')
        self.client.sendmsg(recipients=[recipient.messaging_address],
                            sender=sender,
                            text=str(info))



drivers.register_driver('sms', 'clickatell', ClickatellMessaging())