-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcontacts.repy
137 lines (85 loc) · 2.76 KB
/
contacts.repy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
"""
<Program>
contacts.repy
Variables are mostly from:
http://www.mithril.com.au/android/doc/ContactsFacade.html
<Date Started>
December 19th, 2013
<Author>
Yanyan Zhuang
<Purpose>
Trying to use the SL4A JSON bridge to read contacts info
"""
dy_import_module_symbols("sensorutil")
def contacts_get(sl4a_socket, attributes = None):
"""
<Purpose>
Returns a list of all contacts.
<Arguments>
sl4a_socket - the socket that has been established for
RPC communication
<Return>
{"error":null,"id":0,"result":[{"_id":"1","primary_email":"6"},
{"_id":"2","primary_email":"13"},
{"_id":"3","primary_email":"20","name":"******"},
{"_id":"4","primary_email":"26","name":"******"},...}
"""
if attributes == None:
result = json_rpc(sl4a_socket, "contactsGet")
else:
result = json_rpc(sl4a_socket, "contactsGet", attributes)
return result
def contacts_get_by_id(sl4a_socket, id_number):
"""
<Purpose>
Returns contacts by ID.
<Arguments>
sl4a_socket - the socket that has been established for
RPC communication
id_number - Interger id
<Return>
{"error":null,"id":0,"result":{"_id":"30",
"primary_email":"213","name":"******"}}
"""
result = json_rpc(sl4a_socket, "contactsGetById", id_number)
return result
def contacts_get_attributes(sl4a_socket):
"""
<Purpose>
Returns a list of all possible attributes for contacts.
<Arguments>
sl4a_socket - the socket that has been established for
RPC communication
<Return>
{"error":null,"id":0,"result":["times_contacted","custom_ringtone",
"primary_organization","phonetic_name","status","label","number",
"type","mode","last_time_contacted","display_name","im_handle","_id",
"number_key","starred","primary_email","name","primary_phone",
"im_account","notes","im_protocol","send_to_voicemail"]}
"""
result = json_rpc(sl4a_socket, "contactsGetAttributes")
return result
def contacts_get_count(sl4a_socket):
"""
<Purpose>
Returns the number of contacts.
<Arguments>
sl4a_socket - the socket that has been established for
RPC communication
<Return>
{"error":null,"id":0,"result":344}
"""
result = json_rpc(sl4a_socket, "contactsGetCount")
return result
def contacts_get_ids(sl4a_socket):
"""
<Purpose>
Returns a List of all contact IDs.
<Arguments>
sl4a_socket - the socket that has been established for
RPC communication
<Return>
{"error":null,"id":0,"result":[1,2,3,4,5,.....,344]}
"""
result = json_rpc(sl4a_socket, "contactsGetIds")
return result