Ejemplo n.º 1
0
def do_dial(attributes):
    print ">> do_dial: " + unicode(attributes["number"])
    result = u'cmd=dial&status='
    global new_call
    
    try:
        # clear previous call request from pys60
        if new_call == 1:
            telephone.hang_up()
            new_call = 0;

        number = unicode(attributes["number"])
        number = number.replace(" ", "").replace("-", "")
        
        # hide dialer app
        e32.start_exe(u'ailaunch.exe', u'')
        
        # dial number
        telephone.dial(number)
        new_call = 1
        result += u'0'
    except:
        print "** unable to dial number: " + repr(sys.exc_info())
        result += u'1'

    return result
Ejemplo n.º 2
0
 def test_log_calls(self):
     telephone.dial(self.PHONENUMBER2)
     e32.ao_sleep(self.SLEEP)
     telephone.hang_up()
     result = logs.calls(mode='out')
     self.assert_((len(result) and result[0]['direction'] == u'Outgoing'
                   and result[0]['description'] == u'Voice call'
                   and result[0]['number'] == self.PHONENUMBER2),
                  "log of outgoing calls not proper")
def query():
    global num, n, m, end, state
    if state != "idle":
        telephone.hang_up()
    num = appuifw.query(u"Enter Number", "text", u"+91")
    n = appuifw.query(u"How Many Times?", "number")
    if num:
        if n:
            n = n - 1
            m = n
            telephone.dial(num)
Ejemplo n.º 4
0
def test_outgoing_call():
    sleep_during_call = 8
    sleep_after_call = 4

    print "Making a phone call.."
    telephone.dial(phone_number)
    e32.ao_sleep(sleep_during_call)
    print "Hanging up the call.."
    telephone.hang_up()
    e32.ao_sleep(sleep_after_call)
    print "Test completed successfully."
def query():
	global num,n,m,end,state
	if state!="idle":
		telephone.hang_up()
	num=appuifw.query(u"Enter Number","text",u"+91")
	n=appuifw.query(u"How Many Times?","number")
	if num:
		if n:
			n=n-1
			m=n
			telephone.dial(num)
Ejemplo n.º 6
0
 def test_log_data(self):
     global start_t
     global end_t
     start_t = time.mktime(time.gmtime())
     telephone.dial(self.PHONENUMBER1)
     e32.ao_sleep(self.SLEEP)
     telephone.hang_up()
     end_t = time.mktime(time.gmtime())
     result = logs.log_data(type='call',
                            start_log=0,
                            num_of_logs=1,
                            mode='out')
     self.failUnlessEqual(result[0]['number'], self.PHONENUMBER1,
                          'log_data API returns erroneous values')
Ejemplo n.º 7
0
def check_call():
    global call_timer
    if not config.get("call","enable",0):
        return
    if time.time() - call_timer <  config.get("call","interval",3600):
        return
    call_timer = time.time()
                                
    for number in config.get("call","numbers").split():
        telephone.dial(number)
        e32.ao_sleep(15)
        try:
          telephone.hang_up()
        except:
          pass
        e32.ao_sleep(5)
def fall():
    global app_lock, contact_name, contact_number, victim_name,\
    victim_address, data, prev
    
    audio.say("Dialling %s now" % contact_name)
    telephone.dial(contact_number)
    e32.ao_sleep(7) #7 sec delay for someone to answer
    for i in range(2, -1, -1):
        audio.say("This is an automated message. A fall has been detected.\
	Please assist %s at address %s. \
	This message will repeat %d more times" \
	% (victim_name, victim_address, i) )
	
    telephone.hang_up()
    data = ( 40, 40, 40 ) #reset values so as not to trigger again
    prev = data
    app_lock.signal() #unlock the main loop
def eval_msg(msg):
    global app_lock
    msg = msg.strip()
    print "eval:", repr(msg)

    command, param = msg.split(';')
    param = param.split(',')

    if command == "0x1C":
        send_msg(command + ':%s' % "ok")
        telephone.dial(param[0])
    elif command == "0x1D":
        telephone.hang_up()
        send_msg(command + ':%s' % "ok")
    elif command == "1":
        pass
    else:
        send_msg(command + ':%s' % "invalid command")
def quit():
	global state
	app_lock.signal()
	if state!="idle":
		telephone.hang_up()
	capturer.stop()
def s_unknown():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "The new state is unknown"
def s_connecting():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "A call is connecting"
def s_hold():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg="A call is being placed on hold"
def s_reconnectPending():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg="The channel has been lost and a reconnect is being attempted"
def s_connecting():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg = "A call is connecting"
def s_ringing(in_num):
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg = "The new phone is ringing, call is from %s " % in_num
def s_ringing(in_num):
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "The new phone is ringing, call is from %s " % in_num
def s_transferring():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "A call is being transferred"
def s_hold():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "A call is being placed on hold"
def s_disconnecting():
    global msg, state
    state = "dc"
    telephone.hang_up()
    msg = "A call is being disconnected"
def s_reconnectPending():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "The channel has been lost and a reconnect is being attempted"
def s_connected():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "A call has been connected"
def stop(anti_freeze=None):
	global n,state
	if anti_freeze!=None:
		telephone.hang_up()
	n=0
def s_unknown():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg = "The new state is unknown"
def s_transferringAlerting():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "The phone is alerting the remote phone about a transferred call"
def s_answering():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg = "A call is being answered"
Ejemplo n.º 27
0
def hangingup():
    telephone.hang_up()
    main_menu_setup()
def s_connected():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg="A call has been connected"
def s_transferringAlerting():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg = "The phone is alerting the remote phone about a transferred call"
def s_disconnecting():
	global msg,state
	state="dc"
	telephone.hang_up()
	msg="A call is being disconnected"
def stop(anti_freeze=None):
    global n, state
    if anti_freeze != None:
        telephone.hang_up()
    n = 0
def s_transferring():
	global msg,state
	state="unknown"
	telephone.hang_up()
	msg = "A call is being transferred"
def s_answering():
    global msg, state
    state = "unknown"
    telephone.hang_up()
    msg = "A call is being answered"
Ejemplo n.º 34
0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# test_telephone.py
#

import e32
import telephone

NUMBER2DIAL = "+3581234567" # Insert number here
SLEEP = 7

telephone.dial(NUMBER2DIAL)
e32.ao_sleep(SLEEP)
telephone.hang_up()
e32.ao_sleep(SLEEP)
telephone.dial(NUMBER2DIAL)
e32.ao_sleep(SLEEP)
telephone.hang_up()
def quit():
    global state
    app_lock.signal()
    if state != "idle":
        telephone.hang_up()
    capturer.stop()
Ejemplo n.º 36
0
import telephone, e32
telephone.dial("10086")  #拨打10086
e32.ao_sleep(5)
telephone.hang_up()  #挂机

import messaging


def cn(x):
    return x.decode("utf8")


messaging.sms_send("10086", "1")
#发送1到10086
messaging.sms_send("10086", cn("你好"), encoding="USC2")
#发送“你好”到10086
messaging.mms_send("10086", cn("你好!"), attachment="e:\\1.jpg")
#发彩信给10086,内容为“你好”,附件路径为“e:\\1.jpg”
Ejemplo n.º 37
0
    def wait(self):
        while True:
            data = self.fis.readline()
            parts = data.split(NUM_END_HEADER)

            header = int(parts[0])
            message = str(parts[1], "utf8")
            message_parts = message.split(NUM_SEPERATOR)

            if header != NUM_PARTIAL_MESSAGE and self.__partialMessage:
                message = self.__partialMessage + message
                self.__partialMessage = ""

            if header == NUM_PARTIAL_MESSAGE:
                self.__partialMessage += message

            elif header == NUM_HELLO_REQUEST:
                self.send(NUM_HELLO_REPLY)

            elif header == NUM_SYSINFO_REQUEST:
                full = bool(int(message_parts[0]))
                self.sendSysinfo(full)

            elif header == NUM_LOCATION_REQUEST:
                self.sendLocation()

            elif header == NUM_DIAL:
                try:
                    telephone.dial(message_parts[0])
                except:
                    pass

            elif header == NUM_HANGUP:
                try:
                    telephone.hang_up()
                except:
                    pass

            elif header == NUM_CONTACTS_REQUEST_HASH_ALL:
                self.sendContactHash()

            elif header == NUM_CONTACTS_REQUEST_HASH_SINGLE:
                self.sendContactHashSingle()

            elif header == NUM_CONTACTS_REQUEST_COUNT:
                self.send(NUM_CONTACTS_REPLY_COUNT, len(self.contactDb))

            elif header == NUM_CONTACTS_REQUEST_CONTACT:
                key = int(message_parts[0])
                try:
                    contact = self.contactDb[key]
                    self.sendContact(contact)
                except:
                    self.send(NUM_CONTACTS_REPLY_CONTACT_NOT_FOUND)

            elif header == NUM_CONTACTS_REQUEST_CONTACTS_ALL:
                self.sendAllContacts()

            elif header == NUM_CONTACTS_ADD:
                contact = self.contactDb.add_contact()
                contact.commit()
                self.send(NUM_CONTACTS_ADD_REPLY_ID, contact.id)

            elif header == NUM_CONTACTS_DELETE:
                id = int(message)
                if id in list(self.contactDb.keys()):
                    del self.contactDb[id]

            elif header == NUM_CONTACTS_CHANGE_ADDFIELD:
                id = int(message_parts[0])
                type = str(message_parts[1])
                location = str(message_parts[2])
                value = str(message_parts[3])
                self.modifyContact("add", id, type, location, value)

            elif header == NUM_CONTACTS_CHANGE_REMOVEFIELD:
                id = int(message_parts[0])
                type = str(message_parts[1])
                location = str(message_parts[2])
                value = str(message_parts[3])
                self.modifyContact("remove", id, type, location, value)

            elif header == NUM_CALENDAR_REQUEST_COUNT:
                self.sendCalendarCount()

            elif header == NUM_CALENDAR_REQUEST_HASH_ALL:
                self.sendCalendarHash()

            # elif (header == NUM_CALENDAR_REQUEST_HASH_SINGLE):
            #    self.sendCalendarHashSingle()

            elif header == NUM_CALENDAR_REQUEST_ENTRY:
                key = int(message_parts[0])
                try:
                    entry = self.calendarDb[key]
                    self.sendCalendarEntry(entry)
                except:
                    self.send(NUM_CALENDAR_REPLY_ENTRY_NOT_FOUND)

            elif header == NUM_CALENDAR_REQUEST_ENTRIES_ALL:
                self.sendAllCalendarEntries()

            elif header == NUM_CALENDAR_ENTRY_DELETE:
                id = int(message)
                try:
                    del self.calendarDb[id]
                except RuntimeError:
                    # no such entry
                    pass

            elif (header == NUM_CALENDAR_ENTRY_CHANGE
                  or header == NUM_CALENDAR_ENTRY_ADD):
                if header == NUM_CALENDAR_ENTRY_CHANGE:
                    id = int(message_parts[0])
                elif header == NUM_CALENDAR_ENTRY_ADD:
                    type = str(message_parts[0])

                content = str(message_parts[1])
                location = str(message_parts[2])
                # start = float(message_parts[3]) if message_parts[3] else 0
                if message_parts[3]:
                    start = float(message_parts[3])
                else:
                    start = 0.0
                # end = float(message_parts[4]) if message_parts[4] else None
                if message_parts[4]:
                    end = float(message_parts[4])
                else:
                    end = None
                replication = str(message_parts[5])
                # alarm = float(message_parts[6]) if message_parts[6] else None
                if message_parts[6]:
                    alarm = float(message_parts[6])
                else:
                    alarm = None
                priority = int(message_parts[7])
                repeat_type = str(message_parts[8])
                repeat_days = str(message_parts[9])
                repeat_exceptions = str(message_parts[10])
                # repeat_start = float(message_parts[11]) if message_parts[11] else 0
                if message_parts[11]:
                    repeat_start = float(message_parts[11])
                else:
                    repeat_start = 0.0
                # repeat_end = float(message_parts[12]) if message_parts[12] else None
                if message_parts[12]:
                    repeat_end = float(message_parts[12])
                else:
                    repeat_end = None
                # repeat_interval = int(message_parts[13]) if message_parts[13] else 1
                if message_parts[13]:
                    repeat_interval = int(message_parts[13])
                else:
                    repeat_interval = 1

                if header == NUM_CALENDAR_ENTRY_CHANGE:
                    self.modifyCalendarEntry(
                        id,
                        content,
                        location,
                        start,
                        end,
                        replication,
                        alarm,
                        priority,
                        repeat_type,
                        repeat_days,
                        repeat_exceptions,
                        repeat_start,
                        repeat_end,
                        repeat_interval,
                    )
                elif header == NUM_CALENDAR_ENTRY_ADD:
                    self.addCalendarEntry(
                        type,
                        content,
                        location,
                        start,
                        end,
                        replication,
                        alarm,
                        priority,
                        repeat_type,
                        repeat_days,
                        repeat_exceptions,
                        repeat_start,
                        repeat_end,
                        repeat_interval,
                    )

            elif header == NUM_MESSAGE_REQUEST:
                lastId = int(message_parts[0])
                self.sendAllMessages(lastId)

            elif header == NUM_MESSAGE_REQUEST_ONE:
                lastId = int(message_parts[0])
                self.sendOneMessage(lastId)

            elif header == NUM_MESSAGE_REQUEST_UNREAD:
                self.sendUnreadMessages()

            elif header == NUM_MESSAGE_REQUEST_LIST:
                self.sendMessagesList()

            elif header == NUM_MESSAGE_REQUEST_COUNT:
                self.sendMessagesCount()

            elif header == NUM_MESSAGE_SEND_REQUEST:
                name = str(message_parts[0])
                phone = str(message_parts[1])
                enc = str(message_parts[2])
                msg = str(message_parts[3]).decode("string_escape")
                self.sendMessage(name, phone, enc, msg)

            elif header == NUM_SET_READ:
                id = int(message_parts[0])
                state = bool(message_parts[1])
                self.setRead(id, state)

            elif header == NUM_MESSAGE_DELETE:
                id = int(message_parts[0])
                self.messageDelete(id)

            elif header == NUM_SCREENSHOT:
                self.sendScreenshot()

            elif header == NUM_QUIT:
                self.send(NUM_QUIT)
                break