here2share

PyS60 Library Reference

May 10th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PyS60 Library Reference
  2.  
  3. Release 1.4.1 final
  4. 04 July 2007
  5. Nokia
  6.  
  7.  
  8. Copyright c 2004-2007 Nokia Corporation.
  9. This is Python for S60 version 1.4.1 final created by Nokia Corporation. Files added by Nokia Corpo-
  10. ration are licensed under Apache License Version 2.0. The original software, including modifications of
  11. Nokia Corporation therein, is licensed under the applicable license(s) for Python 2.2.2, unless specifically
  12. indicated otherwise in the relevant source code file.
  13. See http://www.apache.org/licenses/LICENSE-2.0 and http://www.python.org/2.2.2/license.html
  14.  
  15. Abstract
  16. The Python for S60 Platform (Python for S60) simplifies application development and provides a scripting
  17. solution for the Symbian C++ APIs. This document is for Python for S60 version 1.4.1 final that is
  18. based on Python 2.2.2.
  19.  
  20.  
  21. CONTENTS
  22. 1 Introduction
  23. 1
  24. 1.1
  25. Scope . . . . . 1
  26. 1.2
  27. Audience . . . . . 2
  28. 1.3
  29. Naming Conventions . . . . . 2
  30. 2 API Summary
  31. 3
  32. 2.1
  33. Python Standard Library . . . . . 3
  34. 2.2
  35. Python for S60 Extensions . . . . . 3
  36. 2.3
  37. Third-Party Extensions . . . . . 4
  38. 3 Selected Issues on Python Programming for S60
  39. 5
  40. 3.1
  41. Concurrency Aspects . . . . . 5
  42. 3.2
  43. Running Python for S60 Scripts . . . . . 5
  44. 3.3
  45. Standard I/O Streams . . . . . 6
  46. 3.4
  47. Usage of Unicode . . . . . 6
  48. 3.5
  49. Date and Time . . . . . 6
  50. 3.6
  51. Limitations of Thread Support . . . . . 6
  52. 3.7
  53. Scalable User Interface . . . . . 7
  54. 3.8
  55. Error Handling . . . . . 7
  56. 3.9
  57. Limitations and Areas of Development . . . . . 7
  58. 4 Operating System Services and Information
  59. 9
  60. 4.1
  61. e32 — A Symbian OS related services package . . . . . 9
  62. 4.2
  63. sysinfo — Access to system information . . . . . 11
  64. 5 User Interface and Graphics
  65. 13
  66. 5.1
  67. appuifw — Interface to the S60 GUI framework . . . . . 13
  68. 5.2
  69. graphics — A graphics related services package . . . . . 27
  70. 5.3
  71. camera — Interface for taking photographs and video recording . . . . . 33
  72. 5.4
  73. keycapture — Interface for global capturing of key events. . . . . 36
  74. 5.5
  75. topwindow — Interface for creating windows that are shown on top of other applications. 37
  76. 5.6
  77. gles — Bindings to OpenGL ES . . . . . 38
  78. 5.7
  79. glcanvas — UI Control for Displaying OpenGL ES Graphics . . . . . 45
  80. 5.8
  81. sensor — Module to access the device sensors. . . . . 46
  82. 6 Audio and Communication Services
  83. 49
  84. 6.1
  85. audio — An audio related services package . . . . . 49
  86. 6.2
  87. telephone — Telephone services . . . . . 51
  88. 6.3
  89. messaging — A messaging services package . . . . . 52
  90. 6.4
  91. inbox — Interface to device inbox . . . . . 53
  92. 6.5
  93. location — GSM location information . . . . . 54
  94. 6.6
  95. positioning — Simplified interface to the position information . . . . . 55
  96. 7 Data Management
  97. 59
  98. i
  99. Page 6
  100. 7.1
  101. contacts — A contacts related services package . . . . . 59
  102. 7.2
  103. calendar — Access to calendar related services . . . . . 64
  104. 7.3
  105. calendar for EKA2 — Access to calendar related services . . . . . 69
  106. 7.4
  107. e32db — Interface to the Symbian native DB . . . . . 74
  108. 7.5
  109. e32dbm — DBM implemented using the Symbian native DBMS . . . . . 77
  110. 8 Standard Library Support and Extensions
  111. 79
  112. 8.1
  113. Support for Python Standard Library . . . . . 79
  114. 8.2
  115. Extensions to Standard Library Modules . . . . . 80
  116. 9 Extending and Embedding
  117. 83
  118. 9.1
  119. Python/C API Extensions . . . . . 83
  120. 9.2
  121. Extending Python for S60 . . . . . 84
  122. 10 Terms and Abbreviations
  123. 87
  124. A Reporting Bugs
  125. 91
  126. Module Index
  127. 93
  128. Index
  129. 95
  130. ii
  131.  
  132.  
  133. CHAPTER
  134. ONE
  135. Introduction
  136. The Python for S60 Platform (Python for S60) simplifies application development and provides a scripting
  137. solution for the Symbian C++ APIs. This document is for Python for S60 release 1.4.1 final that is
  138. based on Python 2.2.2.
  139. The documentation for Python for S60 includes three documents:
  140. • Getting Started with Python for S60 Platform [5] contains information on how to install Python
  141. for S60 and how to write your first program.
  142. • This document contains API and other reference material.
  143. • Programming with Python for S60 Platform [6] contains code examples and programming patterns
  144. for S60 devices that can be used as a basis for programs.
  145. The Python for S60 as installed on a S60 device consists of:
  146. • Python runtime package that consists of:
  147. – Python interpreter DLL
  148. – Standard and proprietary Python library modules
  149. – S60 UI application framework adaptation component (a DLL) that connects the scripting
  150. domain components to the S60 UI
  151. • Python script shell package that consists of:
  152. – an application written in Python and visible in the application menu of the device that provides
  153. an execution environment for Python scripts.
  154. – For S60 platform versions prior to 3rd Edition: Python Installer program for installing Python
  155. files on the device, which consists of:
  156. ∗ A recognizer plug-in that recognizes .py, .pyc, .pyd and .pyo files as belonging to Python.
  157. ∗ Symbian application written in Python that handles the installation of recognized Python
  158. files into the script shell environment.
  159. A plugin for the S60 C++ SDK is also available. This plugin makes it possible to run Python scripts in
  160. the S60 emulator environment and to compile Python extension modules (PYDs) for the emulator and
  161. the device.
  162. The Python for S60 developer discussion board [9] on the Forum Nokia Web site is a useful resource for
  163. finding out information on specific topics concerning Python for S60. You are welcome to give feedback
  164. or ask questions about Python for S60 through this discussion board.
  165. 1.1 Scope
  166. This document includes the information required by developers to create applications that use Python
  167. for S60, and some advice on extending the platform.
  168. 1
  169. Page 8
  170. 1.2 Audience
  171. This guide is intended for developers looking to create programs that use the native features and re-
  172. sources of the S60 phones. The reader should be familiar with the Python programming language
  173. (http://www.python.org/) and the basics of using Python for S60 (see Getting Started with Python for S60
  174. Platform [5]).
  175. 1.3 Naming Conventions
  176. Most names of the type ESomething typically indicate a constant defined by the Symbian SDK. More
  177. information about these constants can be found in the Symbian SDK documentation.
  178. 2
  179. Chapter 1. Introduction
  180. Page 9
  181. CHAPTER
  182. TWO
  183. API Summary
  184. All built-in object types of the Python language are supported in the S60 environment. The rest of the
  185. programming interfaces are implemented by various library modules as summarized in this chapter.
  186. 2.1 Python Standard Library
  187. Python for S60 platform distribution does not include all of the Python’s standard and optional library
  188. modules to save storage space in the phone. Nevertheless, many of the excluded modules also work in
  189. the S60 Python environment without any modifications. Some modules are included in the SDK version
  190. but not installed in the phone. For a summary of supported library modules, see Chapter 8.
  191. When Python, available at http://www.python.org/, is installed on a PC, the library modules are by default
  192. located in ‘\Python22\Lib’ on Windows and in ‘/usr/lib/python2.2’ on Linux. The Python library modules’
  193. APIs are documented in [1].
  194. Python for S60 extends some standard modules. These extensions are described in this document, see
  195. Chapter 8.2.
  196. 2.2 Python for S60 Extensions
  197. There are two kinds of native C++ extensions in the Python for S60 Platform: built-in extensions and
  198. dynamically loadable extensions.
  199. 2.2.1 Built-in extensions
  200. There are two built-in extensions in the Python for S60 package:
  201. • The e32 extension module is built into the Python interpreter on Symbian OS, and implements
  202. interfaces to special Symbian OS Platform services that are not accessible via Python standard
  203. library modules.
  204. • The appuifw module for Python for S60 Platform offers UI application framework related Python
  205. interfaces.
  206. 2.2.2 Dynamically loadable extensions
  207. These dynamically loadable extension modules provide proprietary APIs to S60 Platform’s services:
  208. graphics: see Chapter 5.2
  209. e32db: see Chapter 7.4
  210. messaging: see Chapter 6.3
  211. 3
  212. Page 10
  213. inbox: see Chapter 6.4
  214. location: see Chapter 6.5
  215. sysinfo: see Chapter 4.2
  216. camera: see Chapter 5.3
  217. audio: see Chapter 6.1
  218. telephone: see Chapter 6.2
  219. calendar: see Chapter 7.2
  220. contacts: see Chapter 7.1
  221. keycapture: see Chapter 5.4
  222. topwindow: see Chapter 5.5
  223. gles: see Chapter 5.6
  224. glcanvas: see Chapter 5.7
  225. 2.3 Third-Party Extensions
  226. It is also possible to write your own Python extensions. S60 related extensions to Python/C API are
  227. described in Chapter 9.1. For some further guidelines on writing extensions in C/C++, see Chapter 9.2.
  228. In addition, for an example on porting a simple extension to S60, see [6].
  229. 4
  230. Chapter 2. API Summary
  231. Page 11
  232. CHAPTER
  233. THREE
  234. Selected Issues on Python Programming for
  235. S60
  236. The following issues must be considered when using Python on S60.
  237. 3.1 Concurrency Aspects
  238. The thread that initializes the Python interpreter becomes the main Python thread. This is usually the
  239. main thread of a UI application. When an application written in Python launches, the Symbian platform
  240. infrastructure creates the main UI thread that starts the Python environment. If a Python program is
  241. started as a server with e32.start server, then the Python main thread is not a UI thread.
  242. It is possible to launch new threads via the services of thread module. Examples of such situations could
  243. be to overcome eventual problems with the fixed, relatively small stack size of the main UI application
  244. thread; or to perform some background processing while still keeping the UI responsive. These new
  245. threads are not allowed to directly manipulate the UI; in other words, they may not use the appuifw
  246. module.
  247. Because of the limitations of the Python interpreter’s final cleanup, Python applications on the Symbian
  248. OS should be designed in such a way that the main thread is the last thread alive.
  249. A facility called active object is used extensively on the Symbian OS to implement co-operative, non-
  250. preemptive scheduling within operating system threads. This facility is also utilized with native APIs. A
  251. Python programmer is exposed to related concurrency issues particularly in UI programming. Preserving
  252. the responsiveness of the UI with the help of active objects needs to be considered when designing the
  253. application logic. At the same time it is necessary to take into account the resulting concurrent behavior
  254. within the application when active objects are used. While the main execution path of a UI script is
  255. blocked in wait for an active object to complete – either explicitly as a result of using e32.Ao lock, or
  256. indirectly within some other Python API implementation – the UI-related callbacks may still get called.
  257. The standard thread.lock cannot normally be used for synchronization in the UI application main
  258. thread, as it blocks the UI event handling that takes place in the same thread context. The Symbian
  259. active object based synchronization service called e32.Ao lock has been implemented to overcome this
  260. problem. The main thread can wait in this lock, while the UI remains responsive.
  261. Python for S60 tries to minimize the unwanted exposure of a Python programmer to the active objects
  262. of the Symbian OS. The programmer may choose to implement the eventual concurrent behavior of the
  263. application with normal threads. However, certain active object based facilities are offered as an option
  264. in the e32 module.
  265. 3.2 Running Python for S60 Scripts
  266. The current options for installing Python scripts to a S60 device are: a stand-alone installation to the
  267. device’s main application menu, and an installation to a folder hierarchy maintained by the Python script
  268. 5
  269. Page 12
  270. shell. For more details on this topic, see Programming with Python for S60 Platform [6]. In the first
  271. case the script application is launched via application menu, and it executes in its own process context.
  272. The latter case is suitable for development, testing, and trying out new scripts.
  273. The Python script shell delivered with Python for S60 package has itself been written in Python. It is a
  274. collection of scripts that offer an interactive Python console and a possibility to execute scripts located
  275. in the directory of the script shell. Due to this kind of design the scripts are not fully isolated from each
  276. other. This means that any changes a script makes in the script shell namespace are visible to other
  277. scripts as well. This may be helpful during the development of a script suite, as long as care is taken to
  278. avoid unwanted interference between scripts.
  279. For some special issues to consider when writing Python scripts to be run in the current Python script
  280. shell, see Programming with Python for S60 Platform [6]. These include the arrangements for standard
  281. output and the maintenance of the Options menu contents.
  282. Note: Note that unlike some previous releases, the current version of the Python for S60 script shell
  283. takes care of restoring appuifw.app.menu, appuifw.app.title, appuifw.app.exit key handler,
  284. appuifw.app.screen, appuifw.app.body, sys.stderr and ?? after a script has been run, and The
  285. application programmer doesn’t need to save and restore these settings.
  286. 3.3 Standard I/O Streams
  287. The standard Python I/O streams in the sys module are by default connected to underlying C STDLIB’s
  288. stdio streams that in turn are terminated by dummy file descriptors. Usually Python scripts set the
  289. I/O streams suitably by manipulating them at Python level via sys module interface. The e32 extension
  290. module offers a Python interface for attaching to C STDLIB’s output streams, but this service is only
  291. recommended for debugging purposes. The e32. stdo function takes as its argument the name of the
  292. file where C STDLIB’s stdout and stderr are to be redirected. This makes it possible to capture the
  293. low-level error output when the Python interpreter has detected a fatal error and aborts.
  294. 3.4 Usage of Unicode
  295. No changes have been made to the standard library modules with regard to string argument and return
  296. value types. S60 extensions generally accept both plain strings and Unicode strings as arguments, but
  297. they return only Unicode strings. APIs that take string arguments for the purpose of showing them on
  298. the UI expect Unicode strings. Giving something else may result in garbled appearance of the text on
  299. the screen.
  300. 3.5 Date and Time
  301. Unix time, seconds since January 1, 1970, 00:00:00 UTC (Coordinated Universal Time), is generally used
  302. as the time format in the Python for S60 APIs described in this document. The float type is used for
  303. storing time values.
  304. 3.6 Limitations of Thread Support
  305. Python for S60 supports starting native threads via the standard thread module. However, the native
  306. APIs Python for S60 uses have certain limitations that a Python programmer must be aware of.
  307. Objects that wrap native resources can typically be used only in the thread they are created in. This is
  308. because native resources cannot be shared between native threads. Examples:
  309. Note:
  310. 6
  311. Chapter 3. Selected Issues on Python Programming for S60
  312. Page 13
  313. • Symbian OS STDLIB implementation has some limitations that are reflected at OS module support
  314. (see S60 SDK documentation [4]). For example, STDLIB file descriptors cannot be shared between
  315. threads, and for that reason, Python file objects cannot either.
  316. • Sockets as implemented in the S60 version of the socket module.
  317. Warning: Trying to use native objects from the wrong thread can crash the interpreter. If display of
  318. panic codes is enabled, a typical panic code displayed in this case is “KERN-EXEC 3”.
  319. 3.7 Scalable User Interface
  320. Note: S60 2nd Edition FP3 and further releases.
  321. S60 2nd Edition FP3 enables a new feature called scalable user interface. For Python developers this
  322. feature is currently visible in new APIs supporting the scalable UI, icon loading, and new screen resolu-
  323. tions. For more information on scalable user interface, see Section 5.1.8, Icon Type of this document, as
  324. well as Programming with Python for S60 Platform [6].
  325. 3.8 Error Handling
  326. The APIs described in this document may raise any standard Python exceptions. In situations where a
  327. Symbian error code is returned, its symbolic name is given as the value parameter of a SymbianError
  328. exception.
  329. In case where the functions have nothing special to return, they return None on success.
  330. 3.9 Limitations and Areas of Development
  331. Some OS level concepts to which the standard os library module offers an interface do not exist as such
  332. in Symbian OS environment. An example of this is the concept of current working directory.
  333. Reference cycle garbage collection is not in use. Because of this, special care needs to be taken to
  334. dismantle cyclic references when a Python program exits. This prevents error messages related to native
  335. resources that are left open. The problem could be removed by developing support for collection of cyclic
  336. garbage or by performing a special cleanup action on interpreter exit. The gc module has been ported
  337. to the Symbian OS, and it has been verified to work. However, the current distribution has been built
  338. without gc support.
  339. 3.7. Scalable User Interface
  340. 7
  341. Page 14
  342. 8
  343. Page 15
  344. CHAPTER
  345. FOUR
  346. Operating System Services and Information
  347. 4.1 e32 — A Symbian OS related services package
  348. The e32 module offers Symbian OS related utilities that are not related to the UI and are not provided
  349. by the standard Python library modules.
  350. 4.1.1 Module Level Functions
  351. The following free functions - functions that do not belong to any class - are defined in the e32 module:
  352. ao yield()
  353. Yields to the active scheduler to have ready active objects with priority above normal scheduled for
  354. running. This has the effect of flushing the eventual pending UI events. Note that the UI callback
  355. code may be run in the context of the thread that performs an ao yield. For information on
  356. active scheduler, see S60 SDK documentation [4].
  357. ao sleep(interval [, callback ])
  358. Sleeps for the given interval without blocking the active scheduler. When the optional callback is
  359. given, the call to ao sleep returns immediately and the callback gets called after interval. See
  360. also Section 4.1.3, Ao timer Type.
  361. ao callgate(wrapped callable)
  362. Wraps wrapped callable into returned callable object callgate that can be called in any thread. As
  363. a result of a call to callgate, wrapped callable gets called in the context of the thread that originally
  364. created the callgate. Arguments can be given to the call. This is actually a simple wrapping of the
  365. Symbian active object facility.
  366. drive list()
  367. Returns a list of currently visible drives as a list of Unicode strings ’<driveletter>:’
  368. file copy(target name, source name)
  369. Copies the file source name to target name. The names must be complete paths.
  370. in emulator()
  371. Returns 1 if running in an emulator, or 0 if running on a device.
  372. set home time(time)
  373. Set the device’s time to time (see Section 3.5).
  374. pys60 version
  375. A string containing the version number of the Python for S60 and some additional information.
  376. Example:
  377. >>> import e32
  378. >>> e32.pys60_version
  379. 1.2 final’
  380. pys60 version info
  381. 9
  382. Page 16
  383. A tuple containing the five components of the Python for S60 version number: major, minor, micro,
  384. release tag, and serial. All values except release level are integers; the release tag is a string. A value
  385. other than ’final’ for the release tag signifies a development release. The pys60 version info
  386. value corresponding to the Python for S60 version 1.2 is (1, 2, 0, ’final’, 0).
  387. s60 version info
  388. The SDK version with which this Python was compiled (tuple). The following values are possible:
  389. (1, 2) for S60 1st Edition
  390. (2, 0) for S60 2nd Edition
  391. (2, 6) S60 2nd Edition Feature Pack 2
  392. (2, 8) S60 2nd Edition Feature Pack 3
  393. (3, 0) S60 3rd Edition
  394. Examples:
  395. >>> import e32
  396. >>> e32.pys60_version
  397. ’1.2.0 final’
  398. >>> e32.pys60_version_info
  399. (1, 2, 0, ’final’, 0)
  400. >>> e32.s60_version_info
  401. (2, 0)
  402. >>>
  403. is ui thread()
  404. Returns True if the code that calls this function runs in the context of the UI thread; otherwise
  405. returns False.
  406. start exe(filename, command [,wait ])
  407. Launches the native Symbian OS executable filename (Unicode) and passes it the command string.
  408. When wait is set, the function synchronously waits for the exit of the executable and returns a
  409. value that describes the exit type. Possible values are 0 for normal exit and 2 for abnormal exit.
  410. start server(filename)
  411. Starts the Python script in file filename (Unicode) as a server in its own process. Note that appuifw
  412. module is not available to a server script.
  413. reset inactivity()
  414. Resets the timers since the user was last active. As a consequence, the device backlight is normally
  415. turned on when this function is invoked.
  416. inactivity()
  417. Returns the time in seconds since the user of the device was last active.
  418. 4.1.2 Ao lock Type
  419. class Ao lock()
  420. Creates an Ao lock instance. A Symbian active object based synchronization service. This can
  421. be used in the main thread without blocking the handling of UI events. The application should
  422. not exit while a thread is waiting in Ao lock. If Ao lock.wait is called while another wait call
  423. is already in progress, an AssertionError is raised.
  424. Instances of Ao lock type have the following methods:
  425. wait()
  426. If the lock has already been signaled, returns immediately. Otherwise blocks in wait for the lock
  427. to be signaled. Only one waiter is allowed, so you should avoid recursive calls to this service. wait
  428. can only be called in the thread that created the lock object. During the wait, other Symbian-
  429. active objects are being served, so the UI will not freeze. This may result in the UI callback code
  430. 10
  431. Chapter 4. Operating System Services and Information
  432. Page 17
  433. being run in the context of the thread that is waiting in Ao lock. This must be considered when
  434. designing the application logic.
  435. signal()
  436. Signals the lock. The waiter is released.
  437. 4.1.3 Ao timer Type
  438. The rationale for the Ao timer type is that you cannot cancel a pending e32.ao sleep. This is
  439. problematic if e.g. the user exits an application which is sleeping. In this case a panic would occur
  440. since the sleep is not cancelled - this is the reason you should avoid using e32.ao sleep and instead
  441. use the Ao timer with appropriate cancel calls if there is for example a possibility for the user to exit
  442. the application during a sleep.
  443. class Ao timer()
  444. Creates an Ao timer instance. A Symbian active object based sleeping service. This can be used
  445. in the main thread without blocking the handling of UI events. The application should not exit
  446. while a thread has a pending after call in Ao timer. Only one after invocation can be pending
  447. at time for each instance of this type.
  448. Instances of Ao timer type have the following methods:
  449. after(interval [,callback ])
  450. Sleeps for the given interval without blocking the active scheduler. When the optional callback is
  451. given, the call to after returns immediately and the callback gets called after interval.
  452. cancel()
  453. Cancels a pending after call.
  454. 4.2 sysinfo — Access to system information
  455. The sysinfo module offers an API for checking the system information of a S60 mobile device.
  456. Note: The method ring type is not available for S60 1st Edition.
  457. The sysinfo module has the following functions:
  458. active profile()
  459. Returns the current active profile as a string, which can be one of the following: ’general’,
  460. ’silent’, ’meeting’,
  461. ’outdoor’, ’pager’, ’offline’, , ’drive’, oruser <profile
  462. value>’.
  463. battery()
  464. Returns the current battery level. On devices based on S60 2nd Edition Feature Pack 1 (S60 2.1)
  465. or earlier the value ranges from 0 (empty) to 7 (full). On newer devices the value ranges from 0
  466. (empty) to 100 (full). On the emulator the value is always 0.
  467. Note: The returned value may be incorrect while the device is being charged.
  468. display twips()
  469. Returns the width and height of the display in twips. For a definition of a twip, see Chapter 10,
  470. Terms and Abbreviations.
  471. display pixels()
  472. Returns the width and height of the display in pixels.
  473. free drivespace()
  474. Returns the amount of free space left on the drives in bytes, for example {u’C:’ 100}. The keys
  475. in the dictionary are the drive letters followed by a colon (:).
  476. imei()
  477. Returns the IMEI code of the device as a Unicode string or, if running on the emulator, the
  478. hardcoded string u’000000000000000’.
  479. 4.2. sysinfo — Access to system information
  480. 11
  481. Page 18
  482. max ramdrive size()
  483. Returns the maximum size of the RAM drive on the device.
  484. total ram()
  485. Returns the amount of RAM memory on the device.
  486. free ram()
  487. Returns the amount of free RAM memory available on the device.
  488. total rom()
  489. Returns the amount of read-only ROM memory on the device.
  490. ring type()
  491. Not supported in 1st Edition! Returns the current ringing type as a string, which can be one
  492. of the following: ’normal’, ’ascending’, ’ring once’, ’beep’, or ’silent’.
  493. os version()
  494. Returns the operating system version number of the device as a three element tuple (major version,
  495. minor version, build number). The elements are as follows1:
  496. •The major version number, ranging from 0 to 127 inclusive
  497. •The minor version number, ranging from 0 to 99 inclusive
  498. •The build number, ranging from 0 to 32767 inclusive.
  499. signal bars()
  500. Returns the current network signal strength ranging from 0 to 7, with 0 meaning no signal and 7
  501. meaning a strong signal. If using an emulator, value 0 is always returned.
  502. signal dbm()
  503. Returns the current network signal strength in dBm. This is available SDK 2.8 onwards. If using
  504. an emulator value 0 is always returned.
  505. sw version()
  506. Returns the software version as a Unicode string. On the emulator, returns the hardcoded string
  507. u’emulator’. For example, a software version can be returned as u’V 4.09.1 26-02-04 NHL-10
  508. (c) NMP’.
  509. 1Descriptions for these values are based on information found in S60 SDK documentation [4].
  510. 12
  511. Chapter 4. Operating System Services and Information
  512. Page 19
  513. CHAPTER
  514. FIVE
  515. User Interface and Graphics
  516. 5.1 appuifw — Interface to the S60 GUI framework
  517. The appuifw module offers an interface to the S60 UI application framework. Figure 5.1 provides an
  518. overview of the Python for S60 environment for UI application programming.
  519. Note: The services of this interface may only be used in the context of the main thread, that is, the
  520. initial thread of a UI application script.
  521. 5.1.1 Basics of appuifw Module
  522. Figure 5.2 shows the layout of a S60 application UI in the normal screen mode and a summary of how
  523. it relates to the services available at the appuifw API. For alternative layouts, see Figure 5.3.
  524. The main application window may be set up to be occupied by a UI control.
  525. A multi-view application can show the different views as tabs in the navigation pane and react as the
  526. users navigate between tabs.
  527. Dialogs always take precedence over the usual UI controls and appear on top of them.
  528. UI controls are implemented as Python types. These types are available:
  529. • Text
  530. • Listbox
  531. • Canvas
  532. UI controls appear on the screen as soon as an instance of the corresponding Python type is set to the
  533. body field (app.body) of the current application UI.
  534. Form is a versatile dialog implemented as a type.
  535. The Content handler type facilitates interfacing to other UI applications and common high-level UI
  536. components. It is based on the notion that designated handlers can reduce UI application interaction to
  537. operations on MIME-type content.
  538. The following dialogs are implemented as functions:
  539. • note
  540. • query
  541. • multi query
  542. • selection list
  543. • multi selection list
  544. 13
  545. Page 20
  546. Figure 5.1: Python for S60 UI environment overview
  547. Figure 5.2: The different parts of the screen when using the ’normal’ layout
  548. 14
  549. Chapter 5. User Interface and Graphics
  550. Page 21
  551. Figure 5.3: UI layouts. left: ’normal’, middle: ’large’, right: ’full’
  552. • popup menu
  553. A dialog becomes visible as soon as the corresponding Python function has been called. The function
  554. returns with the eventual user input or information on the cancellation of the dialog. Form is an exception;
  555. it is shown when its execute method is called.
  556. 5.1.2 Softkeys
  557. The softkeys are managed by the underlying S60 Platform. When no dialog is visible, the right softkey is
  558. bound to application exit and the left one represents an Options menu. Python for S60 offers an interface
  559. for manipulating the menu and for binding the Exit key to a Python-callable object (see Section 5.1.4).
  560. The native code that implements a dialog also manages the softkeys of the dialog, typically OK and
  561. Cancel. When the user input needs to be validated before accepting it and dismissing the dialog, it is
  562. best to use Form.
  563. 5.1.3 Module Level Functions
  564. The following free functions - functions that do not belong to any class - are defined in the appuifw
  565. module:
  566. available fonts()
  567. Returns a list (Unicode) of all fonts available in the device.
  568. query(label, type[, initial value ])
  569. Performs a query with a single-field dialog. The prompt is set to label, and the type of the dialog
  570. is defined by type. The value of type can be any of the following strings:
  571. •’text’
  572. •’code
  573. •’number’
  574. •’date’
  575. •’time
  576. •’query’
  577. •’float
  578. The type of the optional initial value parameter and the returned input depend on the value of
  579. type:
  580. 5.1. appuifw — Interface to the S60 GUI framework
  581. 15
  582. Page 22
  583. •For text fields, (’text’, ’code) it is Unicode
  584. •For number fields, it is numeric
  585. •For date fields, it is seconds since epoch rounded down to the nearest local midnight
  586. A simple confirmation query and time query take no initial value and return True/None and seconds
  587. since local midnight, correspondingly. All queries return None if the users cancel the dialog.
  588. Forfloat’ query the initial value setting has no effect.
  589. multi query(label 1, label 2)
  590. A two-field text (Unicode) input dialog. Returns the inputted values as a 2-tuple. Returns None if
  591. the users cancel the dialog.
  592. note(text[, type[, global ]])
  593. Displays a note dialog of the chosen type with text (Unicode). The default value for type is ’info’,
  594. which is automatically used if type is not set. type can be one of the following strings: ’error’,
  595. ’info’, or ’conf’.
  596. If global (integer) is any other value than zero a global note is displayed. A global note is displayed
  597. even if the Python application calling this function is in background. The same set of types is
  598. supported as in standard note.
  599. popup menu(list[, label ])
  600. A pop-up menu style dialog. list representing the menu contents can be a list of Unicode strings
  601. or a list of Unicode string pairs (tuples). The resulting dialog list is then a single-style or a double-
  602. style list. A single-style list is shown in full; whereas a double-style list shows the items one at a
  603. time. Returns None if the user cancels the operation.
  604. selection list(choices[, search field=0 ])
  605. Executes a dialog that allows the users to select a list item and returns the index of the chosen item,
  606. or None if the selection is cancelled by the users. choices is a list of Unicode strings. search field
  607. is 0 (disabled) by default and is optional. Setting it to 1 enables a search field (find pane) that
  608. facilitates searching for items in long lists. If enabled, the search field appears after you press a
  609. letter key.
  610. multi selection list(choices[, style=’checkbox’, search field=0 ])
  611. Executes a dialog that allows the users to select multiple list items. Returns a tuple of indexes (a
  612. pair of Unicode strings) of the chosen items, or empty tuple if the selection is cancelled by the users.
  613. choices is a list of Unicode strings. style is an optional string; the default value being ’checkbox’.
  614. If ’checkbox’ is given, the list will be a checkbox list, where empty checkboxes indicate what items
  615. can be marked. The other possible value that can be set for style is ’checkmark’. If ’checkmark’
  616. is given, the list will be a markable list, which lists items but does not indicate specifically that
  617. items can be selected. To select items on a markable list, use the Navigation key to browse the
  618. list and the Edit key to select an item. For example views on checkbox and markable lists, see
  619. Figure 5.4. search field is 0 (disabled) by default and is optional. Setting it to 1 enables a search
  620. field (find pane) that facilitates searching for items in long lists. If enabled, the search field is
  621. always visible with checkbox lists; with markable lists it appears by pressing a letter key.
  622. Example:
  623. tuple = appuifw.multi_selection_list(L, style=’checkmark’, search_field=1)
  624. 5.1.4 Application Type
  625. A single implicit instance of this type always exists when appuifw module is present and can be referred
  626. to with the name app. New instances cannot be created by a Python program.
  627. class Application
  628. Instances of Application type have the following attributes:
  629. 16
  630. Chapter 5. User Interface and Graphics
  631. Page 23
  632. Figure 5.4: Examples of a checkbox list (left) and a markable list (right)
  633. body
  634. The UI control that is visible in the application’s main window. Currently either Text, a
  635. Listbox object, Canvas, or None.
  636. exit key handler
  637. A callable object that is called when the user presses the Exit softkey.
  638. Setting
  639. exit key handler to None sets it back to the default value.
  640. menu
  641. This is a list of the following kinds of items:
  642. (title, callback) which creates a regular menu item
  643. (title, ((title, callback)[...])) which creates a submenu
  644. title (Unicode) is the name of the item and callback the associated callable object. The
  645. maximum allowed number of items in a menu, or items in a submenu, or submenus in a menu
  646. is 30.
  647. Example:
  648. appuifw.app.menu = [(u"Item 1", item1),
  649. (u"Submenu 1",
  650. ((u"Subitem 1", subitem1),
  651. (u"Subitem 2", subitem2)))]
  652. screen
  653. The screen area used by an application. See Figure 5.3 for example screens. The appearance of
  654. the application on the screen can be affected by setting one of the following values: ’normal’,
  655. ’large’, and ’full’.
  656. Examples:
  657. appuifw.app.screen=’normal’ # (a normal screen with title pane and softkeys)
  658. appuifw.app.screen=’large’ # (only softkeys visible)
  659. appuifw.app.screen=’full’
  660. # (a full screen)
  661. title
  662. The title the application that is visible in the application’s title pane. Must be Unicode.
  663. focus
  664. A callable object that is called with integer as parameter (0 = focus lost, 1 = focus regained)
  665. when the application receives focus or it is switched to background. Focus is received e.g. when
  666. the application is switched from background to foreground or when the focus is regained from
  667. screensaver. Similarly when the screensaver is displayed, focus is lost.
  668. Examples:
  669. >>> import appuifw
  670. >>> def cb(fg):
  671. 5.1. appuifw — Interface to the S60 GUI framework
  672. 17
  673. Page 24
  674. ...
  675. if(fg):
  676. ...
  677. print "foreground"
  678. ...
  679. else:
  680. ...
  681. print "background"
  682. ...
  683. >>> appuifw.app.focus=cb
  684. >>> # switch to background, following text is printed from callback:
  685. >>> background
  686. >>> # switch to foreground, following text is printed from callback:
  687. >>> foreground
  688. Note: An improper callback can cause adverse effects. If you, for example, define a callback
  689. which takes no parameters you will receive never-ending TypeError exceptions on the Nokia
  690. 6600.
  691. orientation
  692. Available only for S60 3rdEd. The orientation of the application. The orientation of the appli-
  693. cation can be one of the following values: ’automatic’ (this is the default value), ’portrait’
  694. or ’landscape’.
  695. Instances of Application type have the following methods:
  696. activate tab(index)
  697. Activates the tab index counting from zero.
  698. full name()
  699. Returns the full name, in Unicode, of the native application in whose context the current
  700. Python interpreter session runs.
  701. uid()
  702. Returns the UID, in Unicode, of the native application in whose context the current Python
  703. interpreter session runs.
  704. set exit()
  705. Requests a graceful exit from the application as soon as the current script execution returns.
  706. set tabs(tab texts[,callback=None ])
  707. Sets tabs with given names on them in the navigation bar; tab texts is a list of Unicode
  708. strings. When the users navigate between tabs, callback gets called with the index of the
  709. active tab as an argument. Tabs can be disabled by giving an empty or one-item tab texts
  710. list.
  711. layout(layout id)
  712. Note: Available from S60 2ndEd FP3 onwards (inclusive).
  713. Returns as a tuple the size and the position of the requested layout id. The logical lay-
  714. outs are outlined partly in Figure 5.2. The position is given from the top left corner. The
  715. layout id can be one of the constants defined in module appuifw1:
  716. EScreen
  717. Screen.
  718. EApplicationWindow
  719. Window that fills the entire screen.
  720. EStatusPane
  721. Indicates common components for most of the applications.
  722. EMainPane
  723. The application main pane is used in all the applications.
  724. EControlPane
  725. Control pane.
  726. ESignalPane
  727. The signal pane is used to indicate signal strength.
  728. EContextPane
  729. The context pane is used to indicate an active application.
  730. ETitlePane
  731. Used to indicate the subject or the name of the main pane content.
  732. 1Descriptions of the values are from the S60 SDK documentation [4].
  733. 18
  734. Chapter 5. User Interface and Graphics
  735. Page 25
  736. EBatteryPane
  737. The battery pane is used to indicate battery strength.
  738. EUniversalIndicatorPane
  739. The universal indicator pane is used to indicate items that require the user’s attention
  740. while browsing applications.
  741. ENaviPane
  742. The navi pane is used to indicate navigation within an application, to provide context
  743. sensitive information to the user while entering or editing data, or to show additional
  744. information.
  745. EFindPane
  746. A fixed find pane is used with lists instead of the find pop-up window.
  747. EWallpaperPane
  748. Wallpaper pane.
  749. EIndicatorPane
  750. The universal indicator pane is used to indicate items that require the user’s attention
  751. while browsing applications.
  752. EAColumn
  753. Used generally to display small sized graphics or heading texts.
  754. EBColumn
  755. Used generally to display large sized icons or heading texts.
  756. ECColumn
  757. Used generally to display data entered by the user. Overlaps with the D column.
  758. EDColumn
  759. Used generally to display additional icons. Overlaps with the C column.
  760. EStaconTop
  761. Top part of status and control panes in landscape layout.
  762. EStaconBottom
  763. Bottom part of status and control panes in landscape layout.
  764. EStatusPaneBottom
  765. Bottom part of status pane in landscape layout.
  766. EControlPaneBottom
  767. Bottom part of control pane in landscape layout.
  768. EControlPaneTop
  769. Top part of control pane in landscape layout.
  770. EStatusPaneTop
  771. Top part of status pane in landscape layout.
  772. Example:
  773. >>> import appuifw
  774. >>> appuifw.app.layout(appuifw.EMainPane)
  775. ((176, 144), (0, 44))
  776. >>> # size and position (x, y) of the main pane in Nokia N70
  777. 5.1.5 Form Type
  778. Form implements a dynamically configurable, editable multi-field dialog. Form caters for advanced dialog
  779. use cases with requirements such as free selectability of the combination of fields, possibility of validating
  780. the user input, and automatically producing the contents of some dialog fields before allowing the closing
  781. of the dialog.
  782. class Form(fields[, flags=0 ])
  783. Creates a Form instance. fields is a list of field descriptors: (label, type[, value]) where
  784. label is a Unicode string
  785. type is one of the following strings: ’text’, ’number’, ’date’, ’time’, ’combo’ orfloat
  786. 5.1. appuifw — Interface to the S60 GUI framework
  787. 19
  788. Page 26
  789. value, depending on type: Unicode string, numeric, float (seconds since Unix epoch rounded down to
  790. the nearest local midnight), float (seconds since local midnight), ([choice label ...], index)
  791. of float. Forfloattype the initial value setting might not be shown in the UI.
  792. Form can also be configured and populated after construction. The configuration flags are visible as
  793. an attribute. Form implements the list protocol that can be used for setting the form fields, as well as
  794. obtaining their values after the dialog has been executed.
  795. Instances of Form type have the following attributes:
  796. flags
  797. This attribute holds the values of the various configuration flags. Currently supported flags are:
  798. FFormEditModeOnly
  799. When this flag is set, the form remains in edit mode while execute runs.
  800. FFormViewModeOnly
  801. When this flag is set, the form cannot be edited at all.
  802. FFormAutoLabelEdit
  803. This flag enables support for allowing the end-users to edit the labels of the form fields.
  804. FFormAutoFormEdit
  805. This flag enables automatic support for allowing the end-users to add and delete the form
  806. fields. Note that this is an experimental feature and is not guaranteed to work with all SDK
  807. versions.
  808. FFormDoubleSpaced
  809. When this flag is set, double-spaced layout is applied when the form is executed: one field
  810. takes two lines, as the label and the value field are on different lines.
  811. menu
  812. A list of (title, callback) pairs, where each pair describes an item in the form’s menu bar that
  813. is active while the dialog is being executed. title (Unicode) is the name of the item and callback
  814. the associated callable object.
  815. save hook
  816. This attribute can be set to a callable object that receives one argument and returns a Boolean
  817. value. It gets called every time the users want to save the contents of an executing Form dialog.
  818. A candidate list for new form content - a list representing the currently visible state of the UI - is
  819. given as an argument. The list can be modified by save hook. If save hook returns True, the
  820. candidate list is set as the new contents of the form. Otherwise, the form UI is reset to reflect the
  821. field list contained in Form object.
  822. Instances of Form type have the following methods:
  823. execute()
  824. Executes the dialog by making it visible on the UI.
  825. insert(index, field descriptor)
  826. Inserts the field descriptor into the Form before the given index.
  827. pop()
  828. Removes the last field descriptor from the Form and returns it.
  829. length()
  830. the number of field descriptors in the form.
  831. The subscript notation f[i] can be used to access or modify the i-th element of the form f. Same
  832. limitations as discussed above in the context of the flag FFormAutoFormEdit apply to modifying a form
  833. while it is executing. The ability to change the schema of a form while it is executing is an experimental
  834. feature.
  835. 5.1.6 Text Type
  836. Text is a text editor UI control. For examples on the options available with Text, see Figure 5.5.
  837. 20
  838. Chapter 5. User Interface and Graphics
  839. Page 27
  840. Figure 5.5: Examples of the options available for Text type
  841. Instances of Text type have the following attributes:
  842. color
  843. The color of the text. color supports the same color representation models as the graphics
  844. module. For the supported color representation models, see Section 5.2.
  845. focus
  846. A Boolean attribute that indicates the focus state of the control. Editor control also takes the
  847. ownership of the navigation bar, and this feature is needed to enable the usage of this control in
  848. applications that use the navigation bar - for example, navigation tabs.
  849. font
  850. The font of the text. There are two possible ways to set this attribute:
  851. •Using a supported Unicode font, for example u"Latin12". Trying to set a font which is not
  852. supported by the device has no effect. A list of supported fonts can be retrieved by using
  853. appuifw.available fonts.
  854. Example, setting font:
  855. t = appuifw.Text()
  856. t.font = u"albi17b" # sets font to Albi 17 bold
  857. t.font = u"LatinPlain12" # sets font to Latin Plain 12
  858. •Using one of the default device fonts that are associated with the following labels (plain
  859. strings): ’annotation’, ’title’, ’legend’, ’symbol’, ’dense’, ’normal’ Example,
  860. setting font:
  861. t.font = "title" # sets font to the one used in titles
  862. Example, checking the currently set font:
  863. unicodeFont = t.font
  864. The attribute value retrieved is always a Unicode string. If the font has been set with a label, for
  865. example, ’title’, the attribute will retrieve the font associated with that label.
  866. highlight color
  867. The highlight color of the text. highlight color supports the same color representation models
  868. as the graphics module. For the supported color representation models, see Section 5.2.
  869. style
  870. The style of the text. The flags for this attribute are defined in the appuifw module. These flags
  871. can be combined by using the binary operator |. The flags can be divided into two types: text
  872. style and text highlight. Text style flags can be freely combined with each other. However, one or
  873. more text style flags can be combined with only one text highlight flag. The flags are:
  874. Text style:
  875. 5.1. appuifw — Interface to the S60 GUI framework
  876. 21
  877. Page 28
  878. STYLE BOLD
  879. Enables bold text.
  880. STYLE UNDERLINE
  881. Enables underlined text.
  882. STYLE ITALIC
  883. Enables italic text.
  884. STYLE STRIKETHROUGH
  885. Enables strikethrough.
  886. Text highlight:
  887. HIGHLIGHT STANDARD
  888. Enables standard highlight.
  889. HIGHLIGHT ROUNDED
  890. Enables rounded highlight.
  891. HIGHLIGHT SHADOW
  892. Enables shadow highlight.
  893. Only one highlight is allowed to be used at once. Therefore, it is possible to combine only one
  894. highlight with one or more text styles.
  895. Examples:
  896. t = appuifw.Text()
  897. # These and other similar values and combinations are valid:
  898. t.style = appuifw.STYLE_BOLD
  899. t.style = appuifw.STYLE_UNDERLINE
  900. t.style = appuifw.STYLE_ITALIC
  901. t.style = appuifw.STYLE_STRIKETHROUGH
  902. t.style = (appuifw.STYLE_BOLD|
  903. appuifw.STYLE_ITALIC|
  904. appuifw.STYLE_UNDERLINE)
  905. # These values are valid:
  906. t.style = appuifw.HIGHLIGHT_STANDARD
  907. t.style = appuifw.HIGHLIGHT_ROUNDED
  908. t.style = appuifw.HIGHLIGHT_SHADOW
  909. # This combination is NOT valid:
  910. # Invalid code, do not try!
  911. t.style = (appuifw.HIGHLIGHT_SHADOW|appuifw.HIGHLIGHT_ROUNDED)
  912. Instances of Text type have the following methods:
  913. add(text)
  914. Inserts the Unicode string text to the current cursor position.
  915. bind(event code, callback)
  916. Binds the callable Python object callback to event event code. The key codes are defined in the
  917. key codes library module. The call bind(event code, None) clears an existing binding. In the
  918. current implementation the event is always passed also to the underlying native UI control.
  919. clear()
  920. Clears the editor.
  921. delete([pos=0, length=len() ])
  922. Deletes length characters of the text held by the editor control, starting from the position pos.
  923. get pos()
  924. Returns the current cursor position.
  925. len()
  926. Returns the length of the text string held by the editor control.
  927. 22
  928. Chapter 5. User Interface and Graphics
  929. Page 29
  930. get([pos=0, length=len() ])
  931. Retrieves length characters of the text held by the editor control, starting from the position pos.
  932. set(text)
  933. Sets the text content of the editor control to Unicode string text.
  934. set pos(cursor pos)
  935. Sets the cursor to cursor pos.
  936. 5.1.7 Listbox Type
  937. Figure 5.6: Listbox with icons
  938. An instance of this UI control type is visible as a listbox, also known as a list in Symbian, that can be
  939. configured to be a single-line item or a double-item listbox. Figure 5.6 shows a single-line item Listbox
  940. with icons. For more information on the MBM and MIF formats, see Section 5.1.8.
  941. class Listbox(list, callback)
  942. Creates a Listbox instance. A callable object callback gets called when a listbox selection has
  943. been made. list defines the content of the listbox and can be one of the following:
  944. •A normal (single-line item) listbox: a list of Unicode strings, for example [unicode string
  945. item1, unicode string item2]
  946. •A double-item listbox:
  947. a two-element tuple of Unicode strings , for exam-
  948. ple [(unicode string item1, unicode string item1description), (unicode string
  949. item2, unicode string item2description)]
  950. •A normal (single-line item) listbox with graphics: a two-element tuple consisting of
  951. a Unicode string and an Icon object, for example [(unicode string item1, icon1),
  952. (unicode string item2, icon2)].
  953. •A
  954. double-item
  955. listbox
  956. with
  957. graphics:
  958. a three-element tuple consisting of
  959. two Unicode strings and one
  960. Icon
  961. object, for example
  962. [(unicode string
  963. item1, unicode string item1description, icon1), (unicode string item2,
  964. unicode string item2description, icon2)]
  965. Example: To produce a normal (single-line item) listbox with graphics:
  966. icon1 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 28, 29)
  967. icon2 = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 40, 41)
  968. entries = [(u"Signal", icon1),
  969. (u"Battery", icon2)]
  970. lb = appuifw.Listbox(entries, lbox_observe)
  971. Instances of Listbox type have the following methods and properties:
  972. 5.1. appuifw — Interface to the S60 GUI framework
  973. 23
  974. Page 30
  975. bind(event code, callback)
  976. Binds the callable Python object callback to event event code. The key codes are defined in the
  977. key codes library module. The call bind(event code, None) clears an existing binding. In the
  978. current implementation the event is always passed also to the underlying native UI control.
  979. current()
  980. Returns the currently selected item’s index in the Listbox.
  981. set list(list[, current ])
  982. Sets the Listbox content to a list of Unicode strings or a list of tuples of Unicode strings. The
  983. accepted structures of list are the same as in the Listbox constructor. The optional argument
  984. current is the index of the focused list item.
  985. size
  986. The size of the Listbox as a tuple (width, height) - Read only. Only on S60 3rd Ed, and higher.
  987. position
  988. The coordinates (as a tuple) of the top left corner of the Listbox - Read only. Only on S60 3rd
  989. Ed. and higher.
  990. 5.1.8 Icon Type
  991. An instance of Icon type encapsulates an icon to be used together with a Listbox instance. Note that
  992. currently Icon can only be used with Listbox (see Section 5.1.7).
  993. MBM is the native Symbian OS format used for pictures. It is a compressed file format where the files
  994. can contain several bitmaps and can be referred to by a number. An .mbg file is the header file usually
  995. associated with an .mbm file, which includes symbolic definitions for each bitmap in the file. For example,
  996. an ‘avkon.mbmfile has an associated index file called ‘avkon.mbg’, which is included in S60 SDKs. For
  997. more information on the MBM format and the bitmap converter tool, see [4] and search the topics with
  998. the key term ”How to provide Icons”; this topic also points you to the Bitmap Converter tool that can
  999. be used for converting bitmaps into the MBM format.
  1000. S60 2nd Edition FP3 introduces a new format for icons called Multi-Image File (MIF). This format is
  1001. very similar to the MBM format and also contains several compressed files. The files to be compressed
  1002. should be in Scalable Vector Graphics Tiny (SVG-T) format. For more information on the SVG format,
  1003. see Scalable Vector Graphics (SVG) 1.1 Specification [10].
  1004. class Icon(filename, bitmap, bitmapMask)
  1005. Creates an icon. filename is a Unicode file name and must include the whole path. Note that
  1006. MBM and MIF (MIF only in S60 2nd Edition FP3) are the only file formats supported. bitmap
  1007. and bitmapMask are integers that represent the index of the icon and icon mask inside that file
  1008. respectively.
  1009. Example: The following builds an icon with the standard signal symbol:
  1010. icon = appuifw.Icon(u"z:\\system\\data\\avkon.mbm", 28, 29)
  1011. 5.1.9 Content handler Type
  1012. An instance of Content handler handles data content by its MIME type.
  1013. class Content handler([callback ])
  1014. Creates a Content handler instance. A Content handler handles data content by its MIME
  1015. type. The optional callback is called when the embedded handler application started with the open
  1016. method finishes.
  1017. Instances of Content handler type have the following methods:
  1018. open(filename)
  1019. Opens the file filename (Unicode) in its handler application if one has been registered for the
  1020. particular MIME type. The handler application is embedded in the caller’s thread. The call to
  1021. 24
  1022. Chapter 5. User Interface and Graphics
  1023. Page 31
  1024. this function returns immediately. When the handler application finishes, the callback that was
  1025. given to the Content handler constructor is called.
  1026. open standalone(filename)
  1027. Opens the file filename (Unicode) in its handler application if one has been registered for the
  1028. particular MIME type. The handler application is started in its own process. The call to this
  1029. function returns immediately. Note that callback is not called for applications started with this
  1030. method.
  1031. 5.1.10 Canvas Type
  1032. Canvas is a UI control that provides a drawable area on the screen and support for handling raw key
  1033. events. Canvas supports the standard drawing methods that are documented in Section 5.2.
  1034. class Canvas([redraw callback=None, event callback=None, resize callback=None ])
  1035. Constructs a Canvas. The optional parameters are callbacks that are called when specific events
  1036. occur.
  1037. Note: Watch out for cyclic references here. For example, if the callbacks are methods of an object
  1038. that holds a reference to the Canvas, a reference cycle is formed that must be broken at cleanup
  1039. time or the Canvas will not be freed.
  1040. redraw callback is called whenever a part of the Canvas has been obscured by something, is then
  1041. revealed, and needs to be redrawn. This can typically happen, for example, when the user switches
  1042. away from the Python application and back again, or after displaying a pop-up menu. The callback
  1043. takes as its argument a four-element tuple that contains the top-left and the bottom-right corner
  1044. of the area that needs to be redrawn. In many cases redrawing the whole Canvas is a reasonable
  1045. option.
  1046. event callback is called whenever a raw key event is received. There are three kinds of key
  1047. events: EEventKeyDown, EEventKey, and EEventKeyUp. When a user presses a key down, events
  1048. EEventKeyDown and EEventKey are generated. When the key is released, an EEventKeyUp event is
  1049. generated.
  1050. The argument to the event callback is a dictionary that contains the following data for key events:
  1051. •’type’: one of EEventKeyDown, EEventKey, or EEventKeyUp
  1052. •’keycode’: the keycode of the key
  1053. •’scancode’: the scancode of the key
  1054. •’modifiers’: the modifiers that apply to this key event
  1055. Each key on the keyboard has one or more scancodes and zero or more keycodes associated with it.
  1056. A scancode represents the physical key itself and a keycode is the result of state-related operating
  1057. system defined processing done on the key. For keys that correspond to a symbol in the current
  1058. character set of the phone, the keycode is equal to the code of the corresponding symbol in that
  1059. character set. For example, if you are using the Nokia Wireless Keyboard (SU-8W), pressing the
  1060. key A will always produce the scancode 65 (ASCII code for an upper case A), but the keycode
  1061. could be either 65 or 91 (ASCII code for a lower case A) depending on whether or not the Shift
  1062. key is pressed or Caps Lock is active.
  1063. The key codes module contains definitions for the keycodes and scancodes. See Figure 5.7 for the
  1064. codes of the most common keys on the phone keypad.
  1065. Some keys are handled in a special way:
  1066. •A short press of the Edit key causes it to stay down, meaning that no EEventKeyUp event is
  1067. sent. The event is only sent after a long press.
  1068. •Detecting presses of the Voice tags key or the Power key is not supported.
  1069. •If the right softkey is pressed, the appuifw.app.exit key handler callback is always exe-
  1070. cuted.
  1071. 5.1. appuifw — Interface to the S60 GUI framework
  1072. 25
  1073. Page 32
  1074. Key Keycode
  1075. Scancode
  1076. 1.
  1077. EKeyLeftSoftkey
  1078. EScancodeLeftSoftkey
  1079. 2.
  1080. EKeyYes
  1081. EScancodeYes
  1082. 3.
  1083. EKeyMenu
  1084. EScancodeMenu
  1085. 4.
  1086. EKey0...9
  1087. EScancode0...9
  1088. 5.
  1089. EKeyStar
  1090. EScancodeStar
  1091. 6.
  1092. EKeyLeftArrow
  1093. EScancodeLeftArrow
  1094. 7.
  1095. EKeyUpArrow
  1096. EScancodeUpArrow
  1097. 8.
  1098. EKeySelect
  1099. EScancodeSelect
  1100. 9.
  1101. EKeyRightArrow
  1102. EScancodeRightArrow
  1103. 10.
  1104. EKeyDownArrow
  1105. EScancodeDownArrow
  1106. 11.
  1107. EKeyRightSoftkey EScancodeRightSoftkey
  1108. 12.
  1109. EKeyNo
  1110. EScancodeNo
  1111. 13.
  1112. EKeyBackspace
  1113. EScancodeBackspace
  1114. 14.
  1115. EKeyEdit
  1116. EScancodeEdit
  1117. 15.
  1118. EKeyHash
  1119. EScancodeHash
  1120. Figure 5.7: Keycodes and scancodes for phone keys usable from Python applications
  1121. There is no way to prevent the standard action of the Hang-up key, the Menu key, the Power key
  1122. or the Voice tags key from taking place.
  1123. resize callback is called when screen size is changed when the Canvas rect size has been changed.
  1124. The callback takes as its argument a two-element tuple that contains the new clientRect width and
  1125. height.
  1126. Instances of Canvas type have the following attribute:
  1127. size
  1128. A two-element tuple that contains the current width and height of the Canvas as integers.
  1129. Instances of Canvas type have the same standard drawing methods that are documented in Section 5.2.
  1130. 5.1.11 InfoPopup Type
  1131. Note: Available from S60 3rd Ed onwards (inclusive).
  1132. An instance of InfoPopup type encapsulates an UI tip widget. This widget can be placed on top of other
  1133. widgets to provide e.g. usage information to the user. The widget disappears as soon as the device’s
  1134. 26
  1135. Chapter 5. User Interface and Graphics
  1136. Page 33
  1137. user presses any key or when the timer behind the InfoPopup is triggered.
  1138. class InfoPopup()
  1139. Creates an InfoPopup.
  1140. show(text, [(x coord, y coord), time shown, time before, alignment ])
  1141. Show text (Unicode) in the InfoPopup. The optional parameters are the location (a tuple from
  1142. the upper left corner), the time the popup is visible, time shown (in milliseconds), the time before
  1143. the popup, time before (in milliseconds) and the alignment of the popup.
  1144. The default values are: the coordinates (0, 0), time shown 5 seconds, time before 0 seconds and
  1145. for the alignment appuifw.EHLeftVTop.
  1146. The alignment can be one of the constants defined in module appuifw2:
  1147. EHLeftVTop
  1148. Object is left and top aligned.
  1149. EHLeftVCenter
  1150. Object is left aligned and centred vertically.
  1151. EHLeftVBottom
  1152. Object is left aligned and at the bottom.
  1153. EHCenterVTop
  1154. Object is centre aligned horizontally and at the top.
  1155. EHCenterVCenter
  1156. Object is centred horizontally and vertically.
  1157. EHCenterVBottom
  1158. Object is centred horizontally and at the bottom.
  1159. EHRightVTop
  1160. Object is right and top aligned.
  1161. EHRightVCenter
  1162. Object is right aligned and centred vertically.
  1163. EHRightVBottom
  1164. Object is right aligned and at the bottom.
  1165. hide()
  1166. Hides the popup immediately.
  1167. Example:
  1168. >>> import appuifw
  1169. >>> i=appuifw.InfoPopup()
  1170. >>> i.show(u"Here is the tip.", (0, 0), 5000, 0, appuifw.EHRightVCenter)
  1171. >>>
  1172. 5.2 graphics — A graphics related services package
  1173. The graphics module provides access to the graphics primitives and image loading, saving, resizing, and
  1174. transformation capabilities provided by the Symbian OS.
  1175. The module is usable from both graphical Python applications and background Python processes. How-
  1176. ever, background processes have some restrictions, namely that plain string symbolic font names are not
  1177. supported in background processes since background processes have no access to the UI framework (see
  1178. also Section 5.2.4).
  1179. For an example on using this module, see [6].
  1180. Functions Image.open and Image.inspect and Image object methods load, save, resize, and
  1181. transpose are not available for S60 1st Edition.
  1182. 2Descriptions of the values are from the S60 SDK documentation [4].
  1183. 5.2. graphics — A graphics related services package
  1184. 27
  1185. Page 34
  1186. 5.2.1 Module Level Functions
  1187. The following free functions - functions that do not belong to any class - are defined in the graphics
  1188. module:
  1189. screenshot()
  1190. Takes a screen shot and returns the image in Image format.
  1191. 5.2.2 Image Class Static Methods
  1192. The following Image class static methods are defined in the graphics module:
  1193. Image.new(size[, mode=’RGB16’ ])
  1194. Creates and returns a new Image object with the given size and mode. size is a two-element tuple.
  1195. mode specifies the color mode of the Image to be created. It can be one of the following:
  1196. •’1’: Black and white (1 bit per pixel)
  1197. •’L’: 256 gray shades (8 bits per pixel)
  1198. •’RGB12’: 4096 colors (12 bits per pixel)
  1199. •’RGB16’: 65536 colors (16 bits per pixel)
  1200. •’RGB’: 16.7 million colors (24 bits per pixel)
  1201. Image.open(filename)
  1202. Note: Not supported in S60 1st Edition!
  1203. Returns a new Image object (mode RGB16) that contains the contents of the named file. The
  1204. supported file formats are JPEG and PNG. The file format is automatically detected based on file
  1205. contents. filename should be a full path name.
  1206. Image.inspect(filename)
  1207. Note: Not supported in S60 1st Edition!
  1208. Examines the given file and returns a dictionary of the attributes of the file. At present the
  1209. dictionary contains only the image size in pixels as a two-element tuple, indexed by key ’size’.
  1210. filename should be a full path name.
  1211. 5.2.3 Image Objects
  1212. An Image object encapsulates an in-memory bitmap.
  1213. Note on asynchronous methods: Methods resize, transpose, save, and load have an optional callback
  1214. argument. If the callback is not given, the method call is synchronous; when the method returns,
  1215. the operation is complete or an exception has been raised. If the callback is given, the method calls
  1216. are asynchronous. If all parameters are valid and the operation can start, the method call will return
  1217. immediately. The actual computation then proceeds in the background. When it is finished, the callback
  1218. is called with an error code as the argument. If the given code is 0, the operation completed without
  1219. errors, otherwise an error occurred.
  1220. It is legal to use an unfinished image as a source in a blit operation; this will use the image data as it is
  1221. at the moment the blit is made and may thus show an incomplete result.
  1222. Image objects have the following methods:
  1223. resize(newsize[, callback=None, keepaspect=0 ])
  1224. Note: Not supported in S60 1st Edition!
  1225. Returns a new image that contains a resized copy of this image. If keepaspect is set to 1, the resize
  1226. will maintain the aspect ratio of the image, otherwise the new image will be exactly the given size.
  1227. If callback is given, the operation is asynchronous, and the returned image will be only partially
  1228. complete until callback is called.
  1229. 28
  1230. Chapter 5. User Interface and Graphics
  1231. Page 35
  1232. transpose(direction[, callback=None ])
  1233. Note: Not supported in S60 1st Edition!
  1234. Creates a new image that contains a transformed copy of this image. The direction parameter can
  1235. be one of the following:
  1236. •FLIP LEFT RIGHT: Flips the image horizontally, exchanging left and right edges.
  1237. •FLIP TOP BOTTOM: Flips the image vertically, exchanging top and bottom edges.
  1238. •ROTATE 90: Rotates the image 90 degrees counterclockwise.
  1239. •ROTATE 180: Rotates the image 180 degrees.
  1240. •ROTATE 270: Rotates the image 270 degrees counterclockwise.
  1241. If callback is given, the operation is asynchronous and the returned image will be only partially
  1242. complete until callback is called.
  1243. load(filename[, callback=None ])
  1244. Note: Not supported in S60 1st Edition!
  1245. Replaces the contents of this Image with the contents of the named file, while keeping the current
  1246. image mode. This Image object must be of the same size as the file to be loaded.
  1247. If callback is given, the operation is asynchronous and the loaded image will be only partially
  1248. complete until callback is called. filename should be a full path name.
  1249. save(filename[,callback=None, format=None, quality=75, bpp=24, compression=’default’ ])
  1250. Note: Not supported in S60 1st Edition!
  1251. Saves the image into the given file. The supported formats are JPEG and PNG. If format is not
  1252. given or is set to None, the format is determined based on the file name extension: ’.jpgor
  1253. ’.jpeg’ are interpreted to be in JPEG format and ’.png’ to be in PNG format. filename should
  1254. be a full path name.
  1255. When saving in JPEG format, the quality argument specifies the quality to be used and can range
  1256. from 1 to 100.
  1257. When saving in PNG format, the bpp argument specifies how many bits per pixel the resulting file
  1258. should have, and compression specifies the compression level to be used.
  1259. Valid values for bpp are:
  1260. 1: Black and white, 1 bit per pixel
  1261. 8: 256 gray shades, 8 bits per pixel
  1262. 24: 16.7 million colors, 24 bits per pixel
  1263. Valid values for compression are:
  1264. •’best’: The highest possible compression ratio, the slowest speed
  1265. •’fast’: The fastest possible saving, moderate compression
  1266. •’no’: No compression, very large file size
  1267. •’default’: Default compression, a compromise between file size and speed
  1268. If callback is given, the operation is asynchronous. When the saving is complete, the callback is
  1269. called with the result code.
  1270. stop()
  1271. Stops the current asynchronous operation, if any. If an asynchronous call is not in progress, this
  1272. method has no effect.
  1273. Image objects have the following attribute:
  1274. size
  1275. A two-element tuple that contains the size of the Image. Read-only.
  1276. 5.2. graphics — A graphics related services package
  1277. 29
  1278. Page 36
  1279. 5.2.4 Common Features of Drawable Objects
  1280. Objects that represent a surface that can be drawn on support a set of common drawing methods,
  1281. described in this section. At present there are two such objects: Canvas from the appuifw module and
  1282. Image from the graphics module.
  1283. Options
  1284. Many of these methods support a set of standard options. This set of options is as follows:
  1285. • outline: The color to be used for drawing outlines of primitives and text. If None, the outlines of
  1286. primitives are not drawn.
  1287. • fill: The color to be used for filling the insides of primitives. If None, the insides of primitives are
  1288. not drawn. If pattern is also specified, fill specifies the color to be used for areas where the pattern
  1289. is white.
  1290. • width: The line width to be used for drawing the outlines of primitives.
  1291. • pattern: Specifies the pattern to be used for filling the insides of primitives. If given, this must be
  1292. either None or a 1-bit (black and white) Image.
  1293. Coordinate representation
  1294. The methods accept an ordered set of coordinates in the form of a coordinate sequence. Coordinates
  1295. can be of type int, long, or float. A valid coordinate sequence is a non-empty sequence of either
  1296. • Alternating x and y coordinates. In this case the sequence length must be even, or
  1297. • Sequences of two elements, that specify x and y coordinates.
  1298. Examples of valid coordinate sequences:
  1299. (1, 221L, 3, 4, 5.85, -3): A sequence of three coordinates
  1300. [(1,221L),(3,4),[5.12,6]): A sequence of three coordinates
  1301. (1,5): A sequence of one coordinate
  1302. [(1,5)]: A sequence of one coordinate
  1303. [[1,5]]: A sequence of one coordinate
  1304. Examples of invalid coordinate sequences:
  1305. Invalid code, do not use!
  1306. []: An empty sequence
  1307. (1,2,3): Odd number of elements in a flat sequence
  1308. [(1,2),(3,4),None]: Contains an invalid element
  1309. ([1,2],3,4): Mixing the flat and nested form is not allowed
  1310. 30
  1311. Chapter 5. User Interface and Graphics
  1312. Page 37
  1313. Color representation
  1314. All methods that take color arguments accept the following two color representations:
  1315. • A three-element tuple of integers in the range from 0 to 255 inclusive, representing the red, green,
  1316. and blue components of the color.
  1317. • An integer of the form 0xrrggbb, where rr is the red, gg the green, and bb the blue component of
  1318. the color.
  1319. For 12 and 16 bit color modes the color component values are simply truncated to the lower bit depth. For
  1320. the 8-bit grayscale mode images the color is converted into grayscale using the formula (2*r+5*g+b)/8,
  1321. rounded down to the nearest integer. For 1-bit black and white mode images the color is converted into
  1322. black (0) or white (1) using the formula (2*r+5*g+b)/1024.
  1323. Examples of valid colors:
  1324. • 0xffff00: Bright yellow
  1325. • 0x004000: Dark green
  1326. (255,0,0): Bright red
  1327. 0: Black
  1328. 255: Bright blue
  1329. (128,128,128): Medium gray
  1330. Examples of invalid colors:
  1331. Invalid code, do not use!
  1332. (0,0.5,0.9): Floats are not supported
  1333. • ’#ff80c0’: The HTML color format is not supported
  1334. (-1,0,1000): Out-of-range values
  1335. (1,2): The sequence is too short
  1336. [128,128,192]: This is not a tuple
  1337. Font specifications
  1338. A font can be specified in three ways:
  1339. None, meaning the default font
  1340. • a Unicode string that represents a full font name, such as u’LatinBold19’
  1341. • a plain string symbolic name that refers to a font setting currently specified by the UI framework
  1342. as a two or three element tuple, where
  1343. – the first element is the font name (unicode or string) or None for default font
  1344. – the second element is the font height in pixels or None for default size
  1345. – the third (optional) element is the flags applied to the font or None for default options.
  1346. The flags are the following:
  1347. • FONT BOLD bold
  1348. 5.2. graphics — A graphics related services package
  1349. 31
  1350. Page 38
  1351. • FONT ITALIC italic
  1352. • FONT SUBSCRIPT subscript
  1353. • FONT SUPERSCRIPT superscript
  1354. • FONT ANTIALIAS forces the font to be antialiased
  1355. • FONT NO ANTIALIAS forces the font to not be antialiased
  1356. You can combine the flags with the binary or operator “—”. For example, the flags setting
  1357. FONT BOLD|FONT ITALIC will produce text that is both bold and italic.
  1358. Note: Antialiasing support is only available for scalable fonts.
  1359. You can obtain a list of all available fonts with the appuifw module function available fonts.
  1360. The symbolic names for UI fonts are:
  1361. • ’normal’
  1362. • ’dense’
  1363. • ’title’
  1364. • ’symbol
  1365. • ’legend’
  1366. • ’annotation’
  1367. Since background processes have no access to the UI framework, these symbolic names are not supported
  1368. in them. You need to specify the full font name.
  1369. Common Methods of Drawable Objects
  1370. line(coordseq[, <options>])
  1371. Draws a line connecting the points in the given coordinate sequence. For more information about
  1372. the choices available for options, see Section 5.2.4.
  1373. polygon(coordseq[, <options>])
  1374. Draws a line connecting the points in the given coordinate sequence, and additionally draws an
  1375. extra line connecting the first and the last point in the sequence. If a fill color or pattern is specified,
  1376. the polygon is filled with that color or pattern. For more information about the choices available
  1377. for options, see Section 5.2.4.
  1378. rectangle(coordseq[, <options>])
  1379. Draws rectangles between pairs of coordinates in the given sequence. The coordinates specify the
  1380. top-left and the bottom- right corners of the rectangle. The sequence must have an even number
  1381. of coordinates. For more information about the choices available for options, see Section 5.2.4.
  1382. ellipse(coordseq[, <options>])
  1383. Draws ellipses between pairs of coordinates in the given sequence. The coordinates specify the top-
  1384. left and bottom-right corners of the rectangle inside which the ellipse is contained. The sequence
  1385. must have an even number of coordinates. For more information about the choices available for
  1386. options, see Section 5.2.4.
  1387. pieslice(coordseq, start, end[, <options>])
  1388. Draws pie slices contained in ellipses between pairs of coordinates in the given sequence. The start
  1389. and end parameters are floats that specify the start and end points of pie slice as the starting and
  1390. ending angle in radians. The angle 0 is to the right, the angle pi/2 is straight up, pi is to the left
  1391. and-pi/2 is straight down. coordseq is interpreted the same way as for the ellipse method. For
  1392. more information about the choices available for options, see Section 5.2.4.
  1393. 32
  1394. Chapter 5. User Interface and Graphics
  1395. Page 39
  1396. arc(coordseq, start, end[, <options>])
  1397. Draws arcs contained in ellipses between pairs of coordinates in the given sequence. The start
  1398. and end parameters are floats that specify the start and end points of pie slice as the starting and
  1399. ending angle in radians. The angle 0 is to the right, the angle pi/2 is straight up, pi is to the left
  1400. and-pi/2 is straight down. coordseq is interpreted the same way as for the ellipse method. For
  1401. more information about the choices available for options, see Section 5.2.4.
  1402. point(coordseq[, <options>])
  1403. Draws points in each coordinate in the given coordinate sequence. If the width option is set to
  1404. greater than 1, draws a crude approximation of a circle filled with the outline color in the locations.
  1405. Note that the approximation is not very accurate for large widths; use the ellipse method if you
  1406. need a precisely formed circle. For more information about the choices available for options, see
  1407. Section 5.2.4.
  1408. clear([color=0xffffff ])
  1409. Sets the entire surface of the drawable to the given color, white by default.
  1410. text(coordseq, text[fill=0, font=None ])
  1411. Draws the given text in the points in the given coordinate sequence with the given color (default
  1412. value is black) and the given font. The font specification format is described above.
  1413. measure text(text[font=None, maxwidth=-1, maxadvance=-1 ])
  1414. Measures the size of the given text when drawn using the given font. Optionally you can specify
  1415. the maximum width of the text or the maximum amount the graphics cursor is allowed to move
  1416. (both in pixels).
  1417. Returns a tuple of three values:
  1418. •the bounding box for the text as a 4-tuple: (topleft-x, topleft-y, bottomright-x, bottomright-y)
  1419. •the number of pixels the graphics cursor would move to the right
  1420. •the number of characters of the text that fits into the given maximum width and advance
  1421. blit(image[,target=(0,0), source=((0,0),image.size), mask=None, scale=0 ])
  1422. Copies the source area from the given image to the target area in this drawable. The source area
  1423. is copied in its entirety if mask is not given or is set to None. If the mask is given, the source area
  1424. is copied where the mask is white. mask can be either None, a 1-bit (black and white) Image or
  1425. (on S60 2nd edition FP2 and later) a grayscale Image, and must be of the same size as the source
  1426. image. A grayscale mask acts as an alpha channel, i.e. partial transparency.
  1427. target and source specify the target area in this image and the source area in the given source. They
  1428. are coordinate sequences of one or two coordinates. If they specify one coordinate, it is interpreted
  1429. as the upper-left corner for the area; if they specify two coordinates, they are interpreted as the
  1430. top-left and bottom-right corners of the area.
  1431. If scale is other than zero, scaling is performed on the fly while copying the source area to the
  1432. target area. If scale is zero, no scaling is performed, and the size of the copied area is clipped to
  1433. the smaller of source and target areas.
  1434. Note that a blit operation with scaling is slower than one without scaling. If you need to blit the
  1435. same Image many times in a scaled form, consider making a temporary Image of the scaling result
  1436. and blitting it without scaling. Note also that the scaling performed by the blit operation is much
  1437. faster but of worse quality than the one done by the resize method, since the blit method does
  1438. not perform any antialiasing.
  1439. 5.3 camera — Interface for taking photographs and video recording
  1440. Note: Not available for S60 1st Edition.
  1441. The camera module enables taking photographs and video recording.
  1442. The following data items for state information are available in camera:
  1443. 5.3. camera — Interface for taking photographs and video recording
  1444. 33
  1445. Page 40
  1446. EOpenComplete
  1447. The opening of the video clip has succeeded.
  1448. ERecordComplete
  1449. The video recording has completed (not called on explicit stop recording call).
  1450. EPrepareComplete
  1451. The device is ready to begin video recording.
  1452. The camera module has the following functions3:
  1453. cameras available()
  1454. Returns the number of cameras available in the device.
  1455. image modes()
  1456. Returns the image modes supported in the device as a list of strings, for example: [’RGB12’,
  1457. ’RGB’, ’JPEG Exif’, ’RGB16’].
  1458. image sizes()
  1459. Returns the image sizes (resolution) supported in the device as a list of (x, y) tuples, for example:
  1460. [(640, 480), (160, 120)].
  1461. flash modes()
  1462. Returns the flash modes available in the device as a list of strings.
  1463. max zoom()
  1464. Returns the maximum digital zoom value supported in the device as an integer.
  1465. exposure modes()
  1466. Returns the exposure settings supported in the device as a list of strings.
  1467. white balance modes()
  1468. Returns the white balance modes available in the device as a list of strings.
  1469. take photo([mode, size, flash, zoom, exposure, white balance, position ])
  1470. Takes a photograph and returns the image in:
  1471. 1.Image format (for more information on Image format, see Chapter 5.2 graphics Module) or
  1472. 2.Raw JPEG data4.
  1473. The settings listed below describe all settings that are supported by the camera module. You can
  1474. retrieve the mode settings available for your device by using the appropriate functions listed at the
  1475. beginning of this chapter.
  1476. •mode is the display mode of the image. The default value is ’RGB16’. The following display
  1477. modes are supported for the Image format pictures taken:
  1478. –’RGB12’: 4096 colors (12 bits per pixel)
  1479. –’RGB16’: 65536 colors (16 bits per pixel). Default value, always supported
  1480. –’RGB’: 16.7 million colors (24 bits per pixel)
  1481. For the JPEG data format images the following modes are supported:
  1482. –’JPEG Exif’: JPEG Exchangeable image file format
  1483. –’JPEG JFIF’: JPEG File Interchange Format
  1484. Note that there is variety between the devices and the supported formats.
  1485. •size is the resolution of the image. The default value is (640, 480). The following sizes are
  1486. supported, for example, in Nokia 6630: (1280, 960), (640, 480) and (160, 120).
  1487. •flash is the flash mode setting. The default value is ’none’. The following flash mode settings
  1488. are supported:
  1489. –’none’
  1490. No flash. Default value, always supported
  1491. 3Descriptions for some of the values are based on information found in S60 SDK documentation [4]
  1492. 4For more information, see e.g. http://en.wikipedia.org/wiki/JPEG.
  1493. 34
  1494. Chapter 5. User Interface and Graphics
  1495. Page 41
  1496. –’auto’
  1497. Flash will automatically fire when required
  1498. –’forced’
  1499. Flash will always fire
  1500. –’fill in
  1501. Reduced flash for general lighting
  1502. –’red eye reduce
  1503. Red-eye reduction mode
  1504. •zoom is the digital zoom factor. It is assumed to be on a linear scale from 0 to the maximum
  1505. zoom value allowed in the device. The default value is 0, meaning that zoom is not used.
  1506. •exposure is the exposure adjustment of the device. Exposure is a combination of lens aperture
  1507. and shutter speed used in taking a photograph. The default value is ’auto’. The following
  1508. exposure modes are supported:
  1509. –’auto’
  1510. Sets exposure automatically. Default value, always supported
  1511. –’night’
  1512. Night-time setting for long exposures
  1513. –’backlight’
  1514. Backlight setting for bright backgrounds
  1515. –’center’
  1516. Centered mode for ignoring surroundings
  1517. •white balance can be used to adjust white balance to match the main source of light. The
  1518. term white balance refers to the color temperature of the current light. A digital camera
  1519. requires a reference point to represent white. It will then calculate all the other colors based
  1520. on this white point. The default value for white balance is ’auto’ and the following white
  1521. balance modes are supported:
  1522. –’auto’
  1523. Sets white balance automatically. Default value, always supported
  1524. –’daylight’
  1525. Sets white balance to normal daylight
  1526. –’cloudy’
  1527. Sets white balance to overcast daylight
  1528. –’tungsten’
  1529. Sets white balance to tungsten filament lighting
  1530. –’fluorescent’
  1531. Sets white balance to fluorescent tube lighting
  1532. –’flash’
  1533. Sets white balance to flash lighting
  1534. •position is the camera used if the device, such as Nokia 6680, has several cameras. In Nokia
  1535. 6680, the camera pointing to the user of the device is located in position 1, whereas the one
  1536. pointing away from the user is located in position 0. The default position is 0.
  1537. If some other application is using the camera, this operation fails, with error SymbianError:
  1538. KErrInUse. Invoking this function right after the device boot, might result in SymbianError:
  1539. KErrNotReady error.
  1540. start finder(callable[, backlight on=1, size=main pane size ])
  1541. Starts the camera viewfinder and binds a callback to receive Image format feed. When a new
  1542. viewfinder frame is ready the callback is invoked with the Image as parameter.
  1543. The optional parameter backlight on determines whether the device backlight is kept on when
  1544. the camera view finder is in operation. By default, the backlight is on (1 = on, 0 = off).
  1545. The optional parameter size (of type tuple, e.g. (176, 144)) can be used to change the size of
  1546. the Image received in the callback. The default size is the same as the application’s main pane
  1547. size.
  1548. Example view finder code:
  1549. 5.3. camera — Interface for taking photographs and video recording
  1550. 35
  1551. Page 42
  1552. >>> import appuifw
  1553. >>> import camera
  1554. >>> def cb(im):
  1555. ...
  1556. appuifw.app.body.blit(im)
  1557. ...
  1558. >>> import graphics
  1559. >>> appuifw.app.body=appuifw.Canvas()
  1560. >>> camera.start_finder(cb)
  1561. >>>
  1562. stop finder()
  1563. Stops the viewfinder.
  1564. release()
  1565. Releases the camera – After invocation other applications can access the camera hardware.
  1566. start record(filename, callable)
  1567. Starts video recording. filename is the file where the video clip is saved and callable will be called
  1568. with possible error code (int) and status information (see data in module camera) as parameter.
  1569. Prior calling this function, the view finder needs to be started.
  1570. stop record()
  1571. Stops the video recording.
  1572. 5.4 keycapture — Interface for global capturing of key events.
  1573. The keycapture module offers an API for global capturing of key events. The keycapture module
  1574. provides the KeyCapturer object as a tool for listening the events.
  1575. The KeyCapturer object uses a callback method to report the key events. The callback method is called
  1576. each time any of the specified keys is pressed.
  1577. Currently the keycapture module does not support capturing separate key-up or key-down events.
  1578. Note: Keycapture module requires capability SwEvent to work in 3rd Edition devices.
  1579. 5.4.1 Module Level Constants
  1580. The following constants are defined in the keycapture module:
  1581. all keys
  1582. A list of all key codes defined in the key codes module.
  1583. 5.4.2 KeyCapturer objects
  1584. KeyCapturer object takes a callback method as a mandatory parameter to its constructor. The callback
  1585. method must have one single parameter for forwarding the key code of the captured key.
  1586. There can be several KeyCapturer objects existing at the same time.
  1587. KeyCapturer object has following methods and properties:
  1588. keys
  1589. List of keys to be captured. Can be read and written.
  1590. Example:
  1591. keys = (key_codes.EkeyUpArrow,)
  1592. keys = keycapture.all_keys
  1593. 36
  1594. Chapter 5. User Interface and Graphics
  1595. Page 43
  1596. forwarding
  1597. Specifies whether captured key events are forwarded to other applications or not. Either has value
  1598. 1 or 0. Can be read and written.
  1599. start()
  1600. Starts the actual capturing of key events.
  1601. stop()
  1602. Stops the actual capturing of key events.
  1603. last key()
  1604. Returns last key code that is captured.
  1605. 5.5 topwindow — Interface for creating windows that are shown on top of
  1606. other applications.
  1607. The topwindow module offers an API for creating windows that are shown on top of other applications
  1608. and managing the content of these windows. Images can be inserted into the windows and the background
  1609. color, visibility, corner type and shadow of the window can be manipulated.
  1610. topwindow extension does not provide sophisticated drawing capabilities by any means but rather relies
  1611. on services provided by the graphics extension: topwindow allows graphics Image objects to be put
  1612. into the windows that are represented by TopWindow objects.
  1613. TopWindow object provides mainly only two services: TopWindow objects can be shown or hidden and
  1614. Images can be put into the windows. However, several images can be added into one TopWindow object
  1615. and several TopWindow objects can be created and shown. Since the images can be manipulated using
  1616. the graphics extension this makes it possible to create many kind of content to the TopWindow objects.
  1617. 5.5.1 TopWindow objects
  1618. class TopWindow()
  1619. Create a TopWindow object.
  1620. TopWindow objects have the following methods and properties:
  1621. show()
  1622. Shows the window. The window is not shown until show() is called.
  1623. hide()
  1624. Hides the window.
  1625. add image(image, position)
  1626. Inserts an image object graphics.Image into the window. The position of the image is specified
  1627. by the ( position) parameter. If only the coordinates of the top left corner are specified, like (x1,
  1628. y1) the image is not resized. If four coordinates are given, like(x1, y1, x2, y2), the image is resized
  1629. to fit to the specified area. Example:
  1630. add_image(image, (10,20))
  1631. add_image(image, (10,20,20,30))
  1632. remove image(image[,position ])
  1633. Removes the image from the window. Mandatory parameter image must be a graphics.Image
  1634. object. Parameter position may specify the top-left corner coordinates of the image or the rectan-
  1635. gular area of the image. If only image parameter is given, all the pictures representing this image
  1636. object are removed from the window. If both parameters are given, only the picture that matches
  1637. both parameters is removed.
  1638. Example:
  1639. remove_image(image)
  1640. remove_image(image, (10,10))
  1641. 5.5. topwindow — Interface for creating windows that are shown on top of other applications.
  1642. 37
  1643. Page 44
  1644. remove_image(image, (10,10,20,20))
  1645. position
  1646. Specifies the coordinates of the top left corner of the window. Can be read and written.
  1647. Example:
  1648. position = (10, 20)
  1649. size
  1650. Specifies the size of the window. Can be read and written.
  1651. Example:
  1652. size = (100, 200)
  1653. images
  1654. The images inserted into the window. Defined as a list of tuple objects. Each tuple contains a
  1655. graphics.Image object and the position of the image. The position may specify the top-left coor-
  1656. dinate of the image and optionally also the bottom-right coordinate of the image. Parameter (x,y)
  1657. specifies the top-left coordinate, but does not resize the image while parameter like (x1,y1,x2,y2)
  1658. specifies both the top-left and bottom-right coordinates and possibly also resizes the image. Can
  1659. be read and written. Also see the add image() and remove image() methods.
  1660. Example:
  1661. images = [(image1,(x1,y1)), (image2,(x1,y1,x2,y2)), (image3,(50,50,100,100))]
  1662. sets the window content to be 3 images. image2 and image3 are possibly resized while the image1
  1663. is not)
  1664. shadow
  1665. Specifies if the shadow of the window is shown and the length of the shadow. Can be read and
  1666. written. Setting shadow = 0 makes the shadow invisible.
  1667. Example: shadow = 5
  1668. corner type
  1669. Specifies the corner type of the window. Can be read and written. Corner type can be one of the
  1670. following values:
  1671. •square
  1672. •corner1
  1673. •corner2
  1674. •corner3
  1675. •corner5
  1676. Example: corner type = square
  1677. maximum size
  1678. Returns the maximum size of the window as a tuple (width, height). Read only property.
  1679. background color
  1680. The background color of the window as an integer (e.g. 0xaabbcc). The two greatest hexadecimal
  1681. digits specify the red, the next two specify the blue and the last ones specify the green color. Can
  1682. be read and written.
  1683. Example: background color = 0xffffff (sets the white color)
  1684. visible
  1685. Can be set to 0 or 1. 1 means that window is visible, 0 means that it is not. Can be read and
  1686. written. Also see the show and hide methods.
  1687. 5.6 gles — Bindings to OpenGL ES
  1688. 38
  1689. Chapter 5. User Interface and Graphics
  1690. Page 45
  1691. The gles module provides Python bindings to OpenGL ES 2D/3D graphics C API. OpenGL ES is a
  1692. standard defined by Khronos Group (www.khronos.org). Currently S60 Python supports OpenGL ES
  1693. version 1.0 from Series 60 version 2.6 onwards. Support for OpenGL ES version 1.1 should also become
  1694. available in the near future, and both versions are documented here. OpenGL ES 1.1 will require Series
  1695. 60 version 3.0 or newer.
  1696. For detailed description of the OpenGL ES API see the official specifications at
  1697. http://www.khronos.org/opengles. This documentation contains only information that is specific
  1698. to the S60 Python bindings to OpenGL ES. Where possible, the conventions of the PyOpenGL desktop
  1699. OpenGL bindings (http://pyopengl.sourceforge.net) have been followed.
  1700. The display of OpenGL ES graphics is handled by separate module, glcanvas. See glcanvas module
  1701. documentation for more information.
  1702. 5.6.1 array type
  1703. gles module defines array type for representing numerical data of specific GL type. array objects are
  1704. convenient when numerical data for OpenGL ES calls is specified in Python code. Class array also
  1705. defines the standard Python sequence methods so its instances can be iterated and individual items in
  1706. arrays can be manipulated easily.
  1707. class array(type, dimension, sequence)
  1708. Constructs a new array object that contains the given type of data that is taken from sequence.
  1709. Parameter dimension specifies how many items there are in each array element. The dimension
  1710. information is stored with the array and is used by those functions that need to know the element
  1711. size of the input data, for example, if colors are specified with three or four components. The
  1712. dimension does not affect the length of an array or its indexing: both are based on individual
  1713. items.
  1714. Value of type must be one of the following: GL FLOAT, GL BYTE, GL UNSIGNED BYTE, GL SHORT,
  1715. GL UNSIGNED SHORT, or GL FIXED.
  1716. The data in sequence is flattened before it is used to fill the array. When type is GL FLOAT, the
  1717. sequence can contains floats or integers. With all other types, sequence must only contain integers.
  1718. Values in sequence are casted in C to the requested type, so if the requested type cannot properly
  1719. represent all the values the results can be unexpected.
  1720. len
  1721. ()
  1722. Returns the number of items in the array. Note that array dimension does not affect the
  1723. calculation of the length.
  1724. getitem
  1725. (index)
  1726. Returns the item in array with index. Note that array dimension does not affect indexing.
  1727. setitem
  1728. (index, value)
  1729. Sets the value of the item in position index to value. Note that array dimension does not
  1730. affect indexing.
  1731. 5.6.2 Error handling
  1732. Errors generated by the API calls are handled similarly as in PyOpenGL: all GL errors are reported
  1733. as Python exceptions of type gles.GLerror. The wrapper code checks GL error status after each call
  1734. automatically. There is no Python binding for glGetError call.
  1735. 5.6.3 Differences to OpenGL ES C API
  1736. Certain OpenGL ES functions require special handling in Python, mainly because of the pointer pa-
  1737. rameters in the C API. Additionally, special Python versions for some OpenGL ES functions have been
  1738. added. Both of sets of functions are documented below. If a function is not listed here its Python version
  1739. should exactly match the C version defined in the official OpenGL ES 1.0 and 1.1 specifications.
  1740. 5.6. gles — Bindings to OpenGL ES
  1741. 39
  1742. Page 46
  1743. OpenGL ES 1.0
  1744. glColorPointer(size, type, stride, sequence)
  1745. Parameter sequence must be either a gles.array object or some other Python sequence object.
  1746. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  1747. object is used, the type and dimension of its data are ignored and size and type are used instead.
  1748. glColorPointerub(sequence)
  1749. Special Python version of glColorPointer that accepts either a gles.array object or some other
  1750. Python sequence object. Other parameters of glColorPointer will be determined as follows:
  1751. •size If sequence is an instance of gles.array, its dimension is used; otherwise the length of
  1752. sequence is used.
  1753. type GL UNSIGNED BYTE
  1754. •stride 0
  1755. glColorPointerf(sequence)
  1756. Special Python version of glColorPointer that behaves exactly as glColorPointerub except
  1757. GL FLOAT is used as type.
  1758. glColorPointerx(sequence)
  1759. Special Python version of glColorPointer that behaves exactly as glColorPointerub except
  1760. GL FIXED is used as type.
  1761. glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data)
  1762. Parameter data must be either a gles.array or a Python string.
  1763. glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data)
  1764. Parameter data must be either a gles.array or a Python string.
  1765. glDeleteTextures(sequence)
  1766. Parameter sequence must be a Python sequence containing integers.
  1767. glDrawElements(mode, count, type, indices)
  1768. Parameter indices must be either a gles.array or some other Python sequence object. gles.array
  1769. objects require less processing and can be therefore slightly faster. If gles.array object is used,
  1770. the type of its data is ignored and type is used instead.
  1771. glDrawElementsub(mode, indices)
  1772. Special Python version of glDrawElements that uses length of the sequence indices as count and
  1773. GL UNSIGNED BYTE as type.
  1774. glDrawElementsus(mode, indices)
  1775. Special Python version of glDrawElements that uses length of the sequence indices as count and
  1776. GL UNSIGNED SHORT as type.
  1777. glFogv(pname, params)
  1778. Parameter params must be a Python sequence containing float values.
  1779. glFogxv(pname, params)
  1780. Parameter params must be a Python sequence containing integer values.
  1781. glGenTextures(n)
  1782. The generated texture names are returned in a Python tuple.
  1783. glGetIntegerv(pname)
  1784. The values are returned in a Python tuple.
  1785. glGetString(name)
  1786. The value is return as a Python string.
  1787. glLightModelfv(pname, params)
  1788. Parameter params must be a Python sequence containing float values.
  1789. glLightModelxv(pname, params)
  1790. Parameter params must be a Python sequence containing integer values.
  1791. 40
  1792. Chapter 5. User Interface and Graphics
  1793. Page 47
  1794. glLightfv(light, pname, params)
  1795. Parameter params must be a Python sequence containing float values.
  1796. glLightxv(light, pname, params)
  1797. Parameter params must be a Python sequence containing integer values.
  1798. glLoadMatrixf(m)
  1799. Parameter m must be a Python sequence containing float values. The sequence is flattened before
  1800. its items are read.
  1801. glLoadMatrixx(m)
  1802. Parameter m must be a Python sequence containing integer values. The sequence is flattened
  1803. before its items are read.
  1804. glMaterialfv(face, pname, params)
  1805. Parameter params must be a Python sequence containing float values.
  1806. glMaterialxv(face, pname, params)
  1807. Parameter params must be a Python sequence containing integer values.
  1808. glMultMatrixf(m)
  1809. Parameter m must be a Python sequence containing float values. The sequence is flattened before
  1810. its items are read.
  1811. glMultMatrixx(m)
  1812. Parameter m must be a Python sequence containing integer values. The sequence is flattened
  1813. before its items are read.
  1814. glNormalPointer(type, stride, sequence)
  1815. Parameter sequence must be either a gles.array object or some other Python sequence object.
  1816. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  1817. object is used, the type of its data is ignored and type is used instead.
  1818. glNormalPointerb(sequence)
  1819. Special Python version of glNormalPointer that uses type GL BYTE and stride 0.
  1820. glNormalPointers(sequence)
  1821. Special Python version of glNormalPointer that uses type GL SHORT and stride 0.
  1822. glNormalPointerf(sequence)
  1823. Special Python version of glNormalPointer that uses type GL FLOAT and stride 0.
  1824. glNormalPointerx(sequence)
  1825. Special Python version of glNormalPointer that uses type GL FIXED and stride 0.
  1826. glReadPixels(x, y, width, height, format, type)
  1827. The pixel data read is returned in a Python string.
  1828. glTexCoordPointer(size, type, stride, sequence)
  1829. Parameter sequence must be either a gles.array object or some other Python sequence object.
  1830. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  1831. object is used, the dimension and type of its data are ignored and size and type are used instead.
  1832. glTexCoordPointerb(sequence)
  1833. Special Python version of glTexCoordPointer that accepts either a gles.array object or some
  1834. other Python sequence object. Other parameters of glTexCoordPointer will be determined as
  1835. follows:
  1836. •size If sequence is an instance of gles.array, its dimension is used; otherwise the length of
  1837. sequence is used.
  1838. type GL BYTE
  1839. •stride 0
  1840. glTexCoordPointers(sequence)
  1841. Special Python version of glTexCoordPointer that behaves exactly as glTexCoordPointerb ex-
  1842. cept GL SHORT is used as type.
  1843. 5.6. gles — Bindings to OpenGL ES
  1844. 41
  1845. Page 48
  1846. glTexCoordPointerf(sequence)
  1847. Special Python version of glTexCoordPointer that behaves exactly as glTexCoordPointerb ex-
  1848. cept GL FLOAT is used as type.
  1849. glTexCoordPointerx(sequence)
  1850. Special Python version of glTexCoordPointer that behaves exactly as glTexCoordPointerb ex-
  1851. cept GL FIXED is used as type.
  1852. glTexEnvfv(face, pname, params)
  1853. Parameter params must be a Python sequence containing float values.
  1854. glTexEnvxv(face, pname, params)
  1855. Parameter params must be a Python sequence containing integer values.
  1856. glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels)
  1857. Parameter pixels must be either a Python string, a gles.array object, or graphics.Image object.
  1858. Python strings are taken as literal data with no conversion. The dimension and type of data in
  1859. gles.array objects are ignored: the raw data in the array is used.
  1860. Use of graphics.Image objects is limited to only some combinations of format and type. Ta-
  1861. ble 5.6.3 below shows the accepted combinations. To get the best results and performance, the
  1862. CFbsBitmap object in the graphics.Image object should be in the equivalent display mode, also
  1863. shown in the table below. Otherwise, the CFbsBitmap object will be first converted to the equiva-
  1864. lent display mode before reading its pixel data, which can degrade the visual quality in some cases.
  1865. Table 5.1: Legal combinations of format and type with the equivalent Symbian display mode.
  1866. format
  1867. type
  1868. The equivalent display mode
  1869. GL LUMINANCE, GL ALPHA GL UNSIGNED BYTE
  1870. EGray256
  1871. GL RGB
  1872. GL UNSIGNED BYTE
  1873. EColor16M
  1874. GL RGB
  1875. GL UNSIGNED SHORT 5 6 5 EColor64K
  1876. glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels)
  1877. The handling of pixels is the same as with glTexImage2D.
  1878. glVertexPointer(size, type, stride, sequence)
  1879. Parameter sequence must be either a gles.array object or some other Python sequence object.
  1880. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  1881. object is used, the dimension and type of its data are ignored and size and type are used instead.
  1882. glVertexPointerb(sequence)
  1883. Special Python version of glVertexPointer that accepts either a gles.array object or some other
  1884. Python sequence object. Other parameters of glVertexPointer will be determined as follows:
  1885. •size If sequence is an instance of gles.array, its dimension is used; otherwise the length of
  1886. sequence is used.
  1887. type GL BYTE
  1888. •stride 0
  1889. glVertexPointers(sequence)
  1890. Special Python version of glVertexPointer that behaves exactly as glVertexPointerb except
  1891. GL SHORT is used as type.
  1892. glVertexPointerf(sequence)
  1893. Special Python version of glVertexPointer that behaves exactly as glVertexPointerb except
  1894. GL FLOAT is used as type.
  1895. glVertexPointerx(sequence)
  1896. Special Python version of glVertexPointer that behaves exactly as glVertexPointerb except
  1897. GL FIXED is used as type.
  1898. 42
  1899. Chapter 5. User Interface and Graphics
  1900. Page 49
  1901. OpenGL ES 1.1
  1902. glBufferData(target, size, data, usage)
  1903. Parameter data must be a gles.array object. If size is -1, the in-memory size of data is used in
  1904. its place.
  1905. glBufferDatab(target, data, usage)
  1906. Special Python version of glBufferData that accepts either a gles.array object or some other
  1907. Python sequence object for data. If gles.array object is used, its in-memory size in bytes is used
  1908. as size. Other sequences are first converted to flat lists of GL BYTE data by casting. The length of
  1909. the resulting sequence in bytes is used as size.
  1910. glBufferDataub(target, data, usage)
  1911. Special Python version of glBufferData that works exactly like glBufferDatab except
  1912. GL UNSIGNED BYTE is used instead of GL BYTE.
  1913. glBufferDatas(target, data, usage)
  1914. Special Python version of glBufferData that works exactly like glBufferDatab except GL SHORT
  1915. is used instead of GL BYTE.
  1916. glBufferDataus(target, data, usage)
  1917. Special Python version of glBufferData that works exactly like glBufferDatab except
  1918. GL UNSIGNED SHORT is used instead of GL BYTE.
  1919. glBufferDataf(target, data, usage)
  1920. Special Python version of glBufferData that works exactly like glBufferDatab except GL FLOAT
  1921. is used instead of GL BYTE.
  1922. glBufferDatax(target, data, usage)
  1923. Special Python version of glBufferData that works exactly like glBufferDatab except GL FIXED
  1924. is used instead of GL BYTE.
  1925. glBufferSubData(target, size, data, usage)
  1926. Parameter data must be a gles.array object. If size is -1, the in-memory size of data is used in
  1927. its place.
  1928. glBufferSubDatab(target, data, usage)
  1929. Special Python version of glBufferSubData that accepts either a gles.array object or some other
  1930. Python sequence object for data. If gles.array object is used, its in-memory size (in bytes) is
  1931. used as size. Other sequences are first converted to flat lists of GL BYTE data by casting. The
  1932. length of the resulting sequence is used as size.
  1933. glBufferSubDataub(target, data, usage)
  1934. Special Python version of glBufferSubData that works exactly like glBufferSubDatab except
  1935. GL UNSIGNED BYTE is used instead of GL BYTE.
  1936. glBufferSubDatas(target, data, usage)
  1937. Special Python version of glBufferSubData that works exactly like glBufferSubDatab except
  1938. GL SHORT is used instead of GL BYTE.
  1939. glBufferSubDataus(target, data, usage)
  1940. Special Python version of glBufferSubData that works exactly like glBufferSubDatab except
  1941. GL UNSIGNED SHORT is used instead of GL BYTE.
  1942. glBufferSubDataf(target, data, usage)
  1943. Special Python version of glBufferSubData that works exactly like glBufferSubDatab except
  1944. GL FLOAT is used instead of GL BYTE.
  1945. glBufferSubDatax(target, data, usage)
  1946. Special Python version of glBufferSubData that works exactly like glBufferSubDatab except
  1947. GL FIXED is used instead of GL BYTE.
  1948. glClipPlanef(plane, equation)
  1949. Parameter equation must be a Python sequence that contains four float values.
  1950. glClipPlanex(plane, equation)
  1951. 5.6. gles — Bindings to OpenGL ES
  1952. 43
  1953. Page 50
  1954. Parameter equation must be a Python sequence that contains four integer values.
  1955. glDeleteBuffers(buffers)
  1956. Parameter buffers must be a Python sequence that contains integer values.
  1957. glDrawTexsvOES(coords)
  1958. Parameter coords must be a Python sequence that contains integer values.
  1959. glDrawTexivOES(coords)
  1960. Parameter coords must be a Python sequence that contains integer values.
  1961. glDrawTexfvOES(coords)
  1962. Parameter coords must be a Python sequence that contains float values.
  1963. glDrawTexfvOES(coords)
  1964. Parameter coords must be a Python sequence that contains integer values.
  1965. glGenBuffers(n)
  1966. The generated buffer names are returned in a Python tuple.
  1967. glGetBooleanv(pname)
  1968. The values are returned in a Python tuple.
  1969. glGetBufferParameteriv(target, pname)
  1970. The value is returned as an integer.
  1971. glGetClipPlanef(plane)
  1972. The values are returned in a Python tuple.
  1973. glGetClipPlanef(plane)
  1974. The values are returned in a Python tuple.
  1975. glGetFixedv(pname)
  1976. The values are returned in a Python tuple.
  1977. glGetFloatv(pname)
  1978. The values are returned in a Python tuple.
  1979. glGetLightfv(light, pname)
  1980. The values are returned in a Python tuple.
  1981. glGetLightxv(light, pname)
  1982. The values are returned in a Python tuple.
  1983. glGetMaterialfv(face, pname)
  1984. The values are returned in a Python tuple.
  1985. glGetMaterialxv(face, pname)
  1986. The values are returned in a Python tuple.
  1987. glGetTexEnvf(face, pname)
  1988. The values are returned in a Python tuple.
  1989. glGetTexEnvx(face, pname)
  1990. The values are returned in a Python tuple.
  1991. glGetTexParameterf(target, pname)
  1992. The value is returned as a float.
  1993. glGetTexParameterx(target, pname)
  1994. The value is returned as an integer.
  1995. glMatrixIndexPointerOES(size, type, stride, sequence)
  1996. Parameter sequence must be either a gles.array object or some other Python sequence object.
  1997. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  1998. object is used, the dimension and type of its data are ignored and size and type are used instead.
  1999. glMatrixIndexPointerOESub(sequence)
  2000. Special Python version of glMatrixIndexPointerOES that accepts either a gles.array object
  2001. or some other Python sequence object. Other parameters of glMatrixIndexPointerOES will be
  2002. 44
  2003. Chapter 5. User Interface and Graphics
  2004. Page 51
  2005. determined as follows:
  2006. •size If sequence is an instance of gles.array, its dimension is used; otherwise the length of
  2007. sequence is used.
  2008. type GL UNSIGNED BYTE
  2009. •stride 0
  2010. glPointParameterfv(pname, params)
  2011. Parameter params must be a Python sequence containing float values.
  2012. glPointParameterxv(pname, params)
  2013. Parameter params must be a Python sequence containing integer values.
  2014. glPointSizePointerOES(type, stride, sequence)
  2015. Parameter sequence must be either a gles.array object or some other Python sequence object.
  2016. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  2017. object is used, the type of its data is ignored and type is used instead.
  2018. glPointSizePointerOESf(sequence)
  2019. Special Python version of glPointSizePointerOES uses GL FLOAT as type and 0 as stride.
  2020. glPointSizePointerOESx(target, data, usage)
  2021. Special Python version of glPointSizePointerOES uses GL FIXED as type and 0 as stride.
  2022. glWeightPointerOES(size, type, stride, sequence)
  2023. Parameter sequence must be either a gles.array object or some other Python sequence object.
  2024. gles.array objects require less processing and can be therefore slightly faster. If gles.array
  2025. object is used, the dimension and type of its data are ignored and size and type are used instead.
  2026. glWeightPointerOESf(sequence)
  2027. Special Python version of glWeightPointerOES that accepts either a gles.array object or some
  2028. other Python sequence object. Other parameters of glWeightPointerOES will be determined as
  2029. follows:
  2030. •size If sequence is an instance of gles.array, its dimension is used; otherwise the length of
  2031. sequence is used.
  2032. type GL FLOAT
  2033. •stride 0
  2034. glWeightPointerOESx(sequence)
  2035. Special Python version of glWeightPointerOES that behaves exactly as glWeightPointerOESf
  2036. except GL FIXED is used as type.
  2037. 5.7 glcanvas — UI Control for Displaying OpenGL ES Graphics
  2038. The glcanvas module provides a UI control, GLCanvas, for displaying OpenGL ES graphics. GLCanvas
  2039. component is similar to the appuifw Canvas component that supports Symbian OS -level drawing.
  2040. Internally GLCanvas uses EGL for displaying the OpenGL ES graphics. EGL, as OpenGL ES, is a
  2041. standard API defined by the Khronos Group (www.khronos.org). Specifically, GLCanvas uses an EGL
  2042. window surface, which supports double-buffered rendering. It is possible to affect selection of the EGL
  2043. config that is used to create the window surface; for details, see the documentation of the GLCanvas
  2044. constructor.
  2045. GLCanvas instances also hold the OpenGL ES context object, which together with the surface, are needed
  2046. for rendering. When one wants to render with a specific OpenGL ES context to a specific surface, they
  2047. need to be made current. This also applies to GLCanvas, which has the makeCurrent method for this
  2048. purpose. Generally, calling makeCurrent has to be done only if multiple GLCanvas objects are used in
  2049. the same program, as each GLCanvas object is automatically made current when it is created and it
  2050. remains current until it is destroyed or makeCurrent of some other GLCanvas object is called.
  2051. 5.7. glcanvas — UI Control for Displaying OpenGL ES Graphics
  2052. 45
  2053. Page 52
  2054. class GLCanvas(redraw callback, [event callback=None, resize callback=None, attributes=None ])
  2055. Constructs a new GLCanvas object that can be used as a UI control for displaying OpenGL ES
  2056. graphics. Parameters redraw callback, event callback, and resize callback have the same meaning
  2057. as with appuifw module Canvas. Using redraw callback to specify the OpenGL ES drawing is
  2058. preferred as it will be automatically called by drawNow method.
  2059. Parameter attributes can be used to specify attributes used in EGL config selection. It must
  2060. be a Python dictionary where keys are EGL attribute names (which are defined in the glcanvas
  2061. module) and values are integers defining the desired attribute values. Unless specified in attributes,
  2062. EGL BUFFER SIZE is set to value based on the display mode of the window owned by the underlying
  2063. CCoeControl object and EGL DEPTH SIZE is set to 16. Attributes specified in attributes are given
  2064. to eglChooseConfig. Refer to the EGL specification for a detailed list of config attributes and
  2065. explanation of how the selection of EGL configs works.
  2066. The new GLCanvas object will be made current when the constructor returns so makeCurrent does
  2067. not have to be called before starting to use OpenGL ES calls.
  2068. bind(key code, c)
  2069. Sets a callback to be called when a specific key is pressed. Parameter key code should be one
  2070. of the standard Symbian key codes defined in key codes. Parameter c must be a callable
  2071. object.
  2072. drawNow()
  2073. Calls the redraw callback (if set) and then calls eglSwapBuffers to render and display the
  2074. OpenGL ES graphics.
  2075. makeCurrent()
  2076. Makes this GLCanvas object current, meaning that it will be used to display the results of the
  2077. subsequent OpenGL ES calls. In EGL terms this means that the EGL context and surface
  2078. held by this object will be passed to eglMakeCurrent. Using makeCurrent makes it possible
  2079. to use several GLCanvas objects in a single application: the receiver of the OpenGL ES calls
  2080. can be switched with makeCurrent easily.
  2081. 5.8 sensor — Module to access the device sensors.
  2082. The sensor module offers direct access to a device’s physical sensors. It has been tested with
  2083. • acceleration sensor: raises events about the 3-axes acceleration of the device
  2084. • tapping sensor: raises an event when the device was tapped twice on the front side
  2085. • rotation sensor: raises an event based on the orientation of the device.
  2086. Instead of just passing on raised events, event filtering is also supported. Two examples of using
  2087. an event filter are also provided by the sensor module, namely the class OrientationEventFilter
  2088. and RotEventFilter. Both filters can be used to raise events when the device’s orientation changes
  2089. (e.g. when it’s turned to the right). The support is device dependent, e.g. Nokia 5500 supports
  2090. OrientationEventFilter and Nokia N95 supports RotEventFilter.
  2091. Note: The module sensor is available from S60 3rd Edition onwards (inclusive).
  2092. 5.8.1 Module Level Functions
  2093. On the module level, sensor provides the following functions:
  2094. sensors()
  2095. Returns a dictionary containing all available sensors. The dictionary’s format is
  2096. {
  2097. {sensor name 1’: {id’: sensor_id_1, ’category’: category_id_1 } },
  2098. {sensor name 2’: {id’: sensor_id_2, ’category’: category_id_2 } },
  2099. 46
  2100. Chapter 5. User Interface and Graphics
  2101. Page 53
  2102. ...
  2103. }
  2104. with sensor id X and category id X being integer values.
  2105. 5.8.2 Constants
  2106. The following orientation constants are used by the OrientationEventFilter class. Callbacks which
  2107. have been connected to a Sensor object that utilises the OrientationEventFilter event filter will
  2108. receive one of these constants as an argument upon a detected orientation change. The constants’ names
  2109. are the side of the device that is currently turned upwards from the user’s point of view. (For example
  2110. FRONT means that the device is lying on its back - its front side is turned upwards.)
  2111. orientation.TOP
  2112. Represents the orientation where the device is held upwards.
  2113. orientation.BOTTOM
  2114. Represents the orientation where the device is held upside down.
  2115. orientation.LEFT
  2116. Represents the orientation where the side of the device that is left of the display is turned down-
  2117. wards.
  2118. orientation.RIGHT
  2119. Represents the orientation where the side of the device that is right of the display is turned down-
  2120. wards.
  2121. orientation.FRONT
  2122. Represents the orientation where the device is lying on its back, i.e. the front side points upwards.
  2123. orientation.BACK
  2124. Represents the orientation where the device is lying on its front, i.e. the back side points upwards.
  2125. 5.8.3 Classes
  2126. The following classes are provided by the sensor module:
  2127. class Sensor
  2128. The Sensor class represents a physical sensor which delivers (possibly filtered) events. By default,
  2129. events are not filtered. A filter can be applied by using the set event filter method. An
  2130. example for an event filter is given by OrientationEventFilter, which can be applied to a device’s
  2131. acceleration sensor.
  2132. In case different filters should be used for the same physical sensor, different Sensor objects have
  2133. to be created for the same physical sensor.
  2134. init
  2135. (sensor id, category id)
  2136. Initialises the Sensor object. sensor id and category id must represent a valid sensor
  2137. id and category id, respectively. This means that the ids passed on to
  2138. init
  2139. must
  2140. also appear in the dictionary returned by the sensors function. In case sensor id and
  2141. category id do not represent a valid sensor, the connect method will raise an exception.
  2142. connect(callback)
  2143. This method connects the sensor to the given callback. A sensor can only be connected to
  2144. one callback, so this will destroy any pre-existing connection to another callback. If an event
  2145. filter has been set, the events passed on to callback will pass this Sensor object’s event filter
  2146. first. If the connection was properly established, this method returns 1, otherwise 0. Note:
  2147. The connection can be established also if the callback does not exist or cannot be called for
  2148. any other reason.
  2149. disconnect()
  2150. Disconnects this Sensor object’s callback connection. After a successful call to this method, a
  2151. callback that has been previously connected via connect will not receive any events anymore.
  2152. If a connection existed and was successfully removed, this method returns 1, otherwise 0.
  2153. 5.8. sensor — Module to access the device sensors.
  2154. 47
  2155. Page 54
  2156. connected()
  2157. Retrieves this Sensor object’s connection status. Returns True if the sensor is connected,
  2158. False otherwise.
  2159. set event filter(event filter)
  2160. Sets an event filter for this Sensor object. After the event filter has been successfully installed,
  2161. this Sensor object’s connected callback will receive only events that have passed the filter.
  2162. event filter must be derived from EventFilter in order to function properly. If a callback
  2163. connection has already been established before calling this method, the connection will be
  2164. re-established after the event filter has been installed.
  2165. class EventFilter
  2166. The EventFilter class provides a generic interface for event filters. The default implementation
  2167. only passes events on, i.e. events are not filtered. Classes deriving from EventFilter can decide
  2168. if an event should be delivered at all as well as they can alter the data that is passed on to the
  2169. callback.
  2170. callback
  2171. This is where the event filter’s callback is stored. In case the EventFilter object is used
  2172. together with a Sensor object, the Sensor object will handle correct setting of this variable.
  2173. init
  2174. ()
  2175. Initialises the event filter object. The callback member is initialised to None.
  2176. del
  2177. ()
  2178. Destructs the event filter object. This method calls cleanup, which can be overridden by
  2179. deriving classes to clean up resources.
  2180. event(data)
  2181. This method is the place where event filtering takes place, and hence this method should be
  2182. overridden by deriving classes. Overridden event methods can deliver their own data to the
  2183. callback; the data delivered may be data or any other set of data. In case the event is decided
  2184. to be delivered, overriding instances should call self.callback, which by default takes one
  2185. argument.
  2186. cleanup()
  2187. Cleans up any resources needed by the event filter. The default implementation does not need
  2188. this feature. This method is called by the destructor
  2189. del
  2190. .
  2191. class OrientationEventFilter
  2192. Derived from EventFilter. This event filter is meant to be used together with the device’s accel-
  2193. eration sensors. Note that it does not make sense to use it with any other sensor type. It generates
  2194. events when the devices orientation changes, e.g. if it is turned from the upright position to lying
  2195. on the back side. If an OrientationEventFiler is used with a Sensor object, the Sensor object’s
  2196. callback will not receive the raw acceleration data as an argument, but only one of the orientation
  2197. constants, representing the device’s new orientation. In case the algorithm needs calibration on
  2198. the device to be used, please check the OrientationCalibration variables in the file sensor.py.
  2199. init
  2200. ()
  2201. Initialises the OrientationEventFilter object.
  2202. event(sensor val)
  2203. Overridden method. Filters 3-axis acceleration events such that it detects orientation changes.
  2204. Only upon detection of such an orientation change, the callback is invoked. The argument
  2205. passed to the callback is a value from this module’s orientation constants.
  2206. cleanup()
  2207. Cleans up this filter’s timer resource. This will be called by EventFilter’s destructor.
  2208. class RotEventFilter
  2209. Derived from EventFilter.
  2210. This event filter generates events when the devices orientation changes, e.g. if it is turned from the
  2211. left side up position to right side up position. This sensor is resident e.g. in Nokia N95.
  2212. event(sensor val)
  2213. Overridden method. Upon detection of an orientation change, the callback is invoked. The
  2214. argument passed to the callback is a value from this module’s orientation constants.
  2215. 48
  2216. Chapter 5. User Interface and Graphics
  2217. Page 55
  2218. CHAPTER
  2219. SIX
  2220. Audio and Communication Services
  2221. 6.1 audio — An audio related services package
  2222. The audio module enables recording and playing audio files and access to device text-to-speech engine.
  2223. The audio module supports all the formats supported by the device, typically: WAV, AMR, MIDI, MP3,
  2224. AAC, and Real Audio1. For more information on the audio types supported by different devices, see the
  2225. Forum Nokia Web site [7] and S60 Platform Web site [8].
  2226. The following Sound class static methods are defined in the audio module:
  2227. Sound.open(filename)
  2228. Returns a new initialized Sound object with the named file opened. Note that filename should be
  2229. a full Unicode path name and must also include the file extension, for example u’c:\\foo.wav’.
  2230. The following data items for state information are available in audio:
  2231. ENotReady
  2232. The Sound object has been constructed but no audio file is open.
  2233. EOpen
  2234. An audio file is open but no playing or recording operation is in progress.
  2235. EPlaying
  2236. An audio file is playing.
  2237. ERecording
  2238. An audio file is being recorded.
  2239. The following data item is provided for continuous playback of an audio file:
  2240. KMdaRepeatForever
  2241. Possible value for times parameter in open.
  2242. The following method is available in the audio module:
  2243. say(text, prefix=audio.TTS PREFIX)
  2244. Passes the text to the device text-to-speech engine. The default prefix is the text-to-speech prefix
  2245. "(tts)".
  2246. 6.1.1 Sound Objects
  2247. Note: The method current volume is not available for S60 1st Edition.
  2248. class Sound
  2249. Sound objects have the following functions:
  2250. play([times=1, interval=0, callback=None ])
  2251. Starts playback of an audio file from the beginning. Without the parameters times and
  2252. 1The dynamically loaded audio codec for the sound file is based on the MIME-type information inside the audio file
  2253. and file extension.
  2254. 49
  2255. Page 56
  2256. interval it plays the audio file one time. times defines the number of times the audio file is
  2257. played, the default being 1. If the audio file is played several times, interval gives the time
  2258. interval between the subsequent plays in microseconds.
  2259. The optional callback is called when the playing starts and when the end of the sound file
  2260. is reached. The callback should take three parameters: the previous state, the current state
  2261. and the possible error code. The possible states given as parameters to the callback are data
  2262. items in the module audio.
  2263. Other issues:
  2264. •Calling play(audio.KMdaRepeatForever) will repeat the file forever.
  2265. •If an audio file is played but not stopped before exiting, the Python script will leave audio
  2266. playing on; therefore stop needs to be called explicitly prior to exit.
  2267. •Currently the module does not support playing simultaneous audio files, calling play to a
  2268. second Sound instance while another audio file is playing, stops the earlier audio file and
  2269. starts to play the second Sound instance.
  2270. •Calling play while a telephone call is ongoing plays the sound file to uplink. In some
  2271. devices the sound file is also played to the device speaker.
  2272. •Calling play when already playing or recording results in RuntimeError. Calling stop
  2273. prior to play will prevent this from happening.
  2274. stop()
  2275. Stops playback or recording of an audio file.
  2276. record()
  2277. Starts recording audio data to a file. If the file already exists, the operation appends to the
  2278. file. For Nokia devices, WAV is typically supported for recording. For more information on
  2279. the audio types supported by different devices, see the Forum Nokia Web site [7] and S60
  2280. Platform Web site [8]. Other issues:
  2281. •Calling record while a telephone call is ongoing starts the recording of the telephone call.
  2282. •Calling record when already playing or recording results in RuntimeError. Calling stop
  2283. prior to record will prevent this from happening.
  2284. close()
  2285. Closes an opened audio file.
  2286. state()
  2287. Returns the current state of the Sound type instance. The different states (constants) are
  2288. defined in the audio module. The possible states2 are:
  2289. •ENotReady
  2290. The Sound object has been constructed but no audio file is open.
  2291. •EOpen
  2292. An audio file is open but no playing or recording operation is in progress.
  2293. •EPlaying
  2294. An audio file is playing.
  2295. •ERecording
  2296. An audio file is being recorded.
  2297. max volume()
  2298. Returns the maximum volume of the device.
  2299. set volume(volume)
  2300. Sets the volume. If the given volume is negative, then the volume is set to zero which mutes
  2301. the device. If the volume is greater than max volume, then max volume is used.
  2302. current volume()
  2303. Returns the current volume set.
  2304. duration()
  2305. Returns the duration of the file in microseconds.
  2306. set position(microseconds)
  2307. Set the position for the playhead.
  2308. 2Descriptions for these options are based on information found in S60 SDK documentation [4].
  2309. 50
  2310. Chapter 6. Audio and Communication Services
  2311. Page 57
  2312. current position()
  2313. Returns the current playhead position in microseconds.
  2314. 6.2 telephone — Telephone services
  2315. This module provides an API to a telephone.
  2316. Since the users of the device can also hang-up the phone explicitly, they might affect the current status
  2317. of the call. In addition, using this extension in an emulator has no effect since no calls can be connected.
  2318. The telephone module has the following functions:
  2319. dial(number)
  2320. Dials the number set in number. number is a string, for example u’+358501234567’ where ’+’ is
  2321. the international prefix, ’358is the country code, ’50is the mobile network code (or the area
  2322. code), and1234567is the subscriber number. If there is an ongoing phone call prior to calling
  2323. dial from Python, then the earlier call is put on hold and a new call is established. Calling dial
  2324. multiple times when, for example, the first call has been answered and a line has been established
  2325. results in subsequent calls not being connected.
  2326. hang up()
  2327. Hangs up if a call initiated by dial is in process. If this call has already been finished,
  2328. SymbianError: KErrNotReady is raised.
  2329. Note: The following functions and data items are available from S60 3rd Edition onwards (inclusive).
  2330. incoming call()
  2331. Wait for incoming call, returns immediately. If a call arrives, answer can be called to answer the
  2332. call. Without the invocation of function incoming call, the function answer has no effect.
  2333. answer()
  2334. Answers an incoming call - see also incoming call.
  2335. call state(callable)
  2336. The callable will be called when there are changes in the telephone line (lines) in the device. The
  2337. argument for the call is a tuple with first item the possible new state and the second item, the
  2338. possible incoming call number as a Unicode string.
  2339. The possible states in the tuple are defined as telephone module constants.
  2340. The following data items for state information are available in telephone3:
  2341. EStatusUnknown
  2342. Indicates that the status is unknown.
  2343. EStatusIdle
  2344. Idle line status (no active calls).
  2345. EStatusDialling
  2346. Call dialling status.
  2347. EStatusRinging
  2348. Call ringing status.
  2349. EStatusAnswering
  2350. Call answering status.
  2351. EStatusConnecting
  2352. Call connecting status.
  2353. EStatusConnected
  2354. Call connected status.
  2355. EStatusReconnectPending
  2356. Call is undergoing temporary channel loss and it may or may not be reconnected.
  2357. 3The descriptions are taken from the S60 SDK documentation [4]
  2358. 6.2. telephone — Telephone services
  2359. 51
  2360. Page 58
  2361. EStatusDisconnecting
  2362. Call disconnecting status.
  2363. EStatusHold
  2364. Call on hold.
  2365. EStatusTransferring
  2366. Call is transferring.
  2367. EStatusTransferAlerting
  2368. Call in transfer is alerting the remote party.
  2369. 6.3 messaging — A messaging services package
  2370. The messaging module offers APIs to messaging services. Currently, the messaging module has func-
  2371. tions:
  2372. sms send(recipient, message, [encoding=’7bit’, callback=None ])
  2373. Sends an SMS message with body text message (Unicode) to telephone number recipient (string).
  2374. The optional parameter encoding is used to define encoding in the message. The parameter values
  2375. can be ’7bit’, ’8bit’ or ’UCS2’.
  2376. The optional parameter callback is invoked with the current status of the send operation as param-
  2377. eter. The possible states are data items in the module messaging. Invoking another send while a
  2378. previous send request is ongoing will result in RuntimeError being raised.
  2379. If the callback is not given, the sms send function will block until the message in the queue is
  2380. either deleted or the sending has failed4.
  2381. mms send(recipient, message, [attachment=None ])
  2382. Note: Available from S60 3.0 onwards (inclusive).
  2383. Sends an MMS message with body text message (Unicode) to telephone number recipient (string).
  2384. The optional parameter attachment is full path to e.g. image file attached to the message.
  2385. The following data items for SMS sending state information are available in the module messaging:
  2386. ECreated
  2387. EMovedToOutBox
  2388. EScheduledForSend
  2389. ESent
  2390. The SMS message has been sent.
  2391. EDeleted
  2392. The SMS message has been deleted from device’s outbox queue. The sms send operation has
  2393. finalized and subsequent SMS sending is possible.
  2394. EScheduleFailed
  2395. ESendFailed
  2396. This state information is returned when the SMS subsystem has tried to send the message several
  2397. times in vain. The sms send operation has finalized and subsequent SMS sending is possible.
  2398. ENoServiceCentre
  2399. This state information is returned by the SMS subsystem in S60 3.x emulator. In emulator this
  2400. indicates that the sms send operation has finalized and subsequent SMS sending is possible.
  2401. EFatalServerError
  2402. The underlying messaging subsystem in S60 devices might give error messages to the user if the device
  2403. is not connected to a network while trying to send a message – An ”SMS send failed!” note is a common
  2404. error message.
  2405. 4Please note that this blocking might last for several minutes and hence supplying the callback might be more suitable
  2406. in many cases.
  2407. 52
  2408. Chapter 6. Audio and Communication Services
  2409. Page 59
  2410. When sending messages in offline-mode or with no network connection these messages are actually added
  2411. to an outgoing message queue and they might be sent if the device is later on connected to a suitable
  2412. network5. This occurs despite the possibly misleading error messages. The current network conditions
  2413. can be checked e.g. with sysinfo.active profile() and sysinfo.signal bars() invocations.
  2414. The following is example code for state information processing with sms send operation:
  2415. >>> import messaging
  2416. >>>
  2417. >>> def cb(state):
  2418. ...
  2419. if state==messaging.ESent:
  2420. ...
  2421. print "**Message was sent**"
  2422. ...
  2423. if state==messaging.ESendFailed:
  2424. ...
  2425. print "**Something went wrong - Truly sorry for this**"
  2426. ...
  2427. >>> messaging.sms_send("1234567", "Hello from PyS60!", ’7bit’, cb)
  2428. >>> **Message was sent** # This is printed from the callback
  2429. 6.4 inbox — Interface to device inbox
  2430. The inbox module offers APIs to device inbox, outbox, sent and drafts folders. Currently, the inbox
  2431. module supports only SMS handling and notifications of incoming messages to the device inbox.
  2432. class Inbox([folder type ])
  2433. Create an Inbox object.
  2434. The optional parameter folder type defines the type of the folder to which the created Inbox
  2435. object has access to. The default is the device’s inbox folder, inbox.EInbox.
  2436. The following data items are available in the inbox module to define the type of the folder for Inbox
  2437. objects:
  2438. EInbox
  2439. The device’s inbox folder.
  2440. EOutbox
  2441. The device’s outbox folder.
  2442. ESent
  2443. The sent messages folder.
  2444. EDraft
  2445. The draft messages folder.
  2446. 6.4.1 Inbox Objects
  2447. Inbox objects have the following functions:
  2448. sms messages()
  2449. Returns a list of SMS message IDs in device inbox.
  2450. content(sms id)
  2451. Retrieve the SMS message content in Unicode.
  2452. time(sms id)
  2453. Retrieve the SMS message time of arrival in seconds since epoch.
  2454. address(sms id)
  2455. Retrieve the SMS message sender address in Unicode.
  2456. 5Note also that prior this the user of the device can explicitly delete the messages from the native messaging application.
  2457. The amount of resending is approx. 4 times – After this the sending operation is cancelled and the user of the device will
  2458. see a visual cue of the failure in the status pane.
  2459. 6.4. inbox — Interface to device inbox
  2460. 53
  2461. Page 60
  2462. delete(sms id)
  2463. Delete the SMS message from inbox.
  2464. unread(( )
  2465. sms id) Returns the status (1=unread, 0=read) of the SMS with id.
  2466. bind(callable)
  2467. Bind a callback to receive new message events in device inbox. When a new message arrives to the
  2468. device inbox the callback gets called with the received message ID. The received message can be
  2469. other than an SMS message.
  2470. If the message received is deleted immediately after e.g. checking the message content, the ”new
  2471. message” sound and dialog are not activated. This functionality might be useful in notification
  2472. type of applications.
  2473. Examples:
  2474. >>> import inbox
  2475. >>> i=inbox.Inbox() # Give inbox.ESent as parameter for sent SMSes
  2476. >>> m=i.sms_messages()
  2477. >>> i.content(m[0])
  2478. u’foobar’
  2479. >>> i.time(m[0])
  2480. 1130267365.03125
  2481. >>> i.address(m[0])
  2482. u’John Doe’
  2483. >>> i.delete(m[0])
  2484. >>>
  2485. >>> import inbox
  2486. >>> id=0
  2487. >>> def cb(id_cb):
  2488. ... global id
  2489. ... id=id_cb
  2490. ...
  2491. >>> i=inbox.Inbox()
  2492. >>> i.bind(cb)
  2493. >>> # Send an SMS to your inbox here. The "id" gets updated
  2494. >>> i.address(id)
  2495. u’John Doe’
  2496. >>> i.content(id)
  2497. u’print 1
  2498. >>>
  2499. 6.5 location — GSM location information
  2500. The location module offers APIs to location information related services. Currently, the location has
  2501. one function:
  2502. Note:
  2503. Location module requires capabilities ReadDeviceData, ReadUserData and Location in 3rd
  2504. Edition devices.
  2505. gsm location()
  2506. Retrieves GSM location information: Mobile Country Code, Mobile Network Code, Location Area
  2507. Code, and Cell ID. A location area normally consists of several base stations. It is the area where
  2508. the terminal can move without notifying the network about its exact position. mcc and mnc
  2509. together form a unique identification number of the network into which the phone is logged.
  2510. 6.5.1 Examples
  2511. Here is an example of how to use the location package to fetch the location information:
  2512. 54
  2513. Chapter 6. Audio and Communication Services
  2514. Page 61
  2515. >>> import location
  2516. >>> print location.gsm_location()
  2517. 6.6 positioning — Simplified interface to the position information
  2518. The positioning module provides basic access to the S60 position information 6. The module can be
  2519. e.g. used to access position information provided by external Bluetooth GPS-devices and by built-in
  2520. GPS-receivers7 from S60 2nd Edition FP 2 onwards.
  2521. The module offers a large amount of information (cost of service, device power consumption etc.) about
  2522. accessible positioning devices (like GPS-modules), position, course, accuracy and satellite information
  2523. (depending on the position device used) and much more. This module can also be used to obtain
  2524. device/vendor specific extended information.
  2525. Note: The module position requires Location capability to work fully in S60 3rd Edition devices.
  2526. The following data items are available in positioning:
  2527. POSITION INTERVAL
  2528. The time interval (in microseconds) between the position function callback invocation. The
  2529. default value set is 1 000 000 microseconds (= 1 second)
  2530. The positioning module has the following functions (for examples of the values returned, see Section
  2531. 6.6.1):
  2532. modules()
  2533. Get information about available positioning modules.
  2534. default module()
  2535. Get default module id.
  2536. module info(module id)
  2537. Get detailed information about the specified module.
  2538. select module(module id)
  2539. Select a module.
  2540. set requestors(requestors)
  2541. Set the requestors of the service (at least one must be set).
  2542. position(course=0,satellites=0,callback=None, interval=positioning.POSITION INTERVAL, partial=0)
  2543. By default, returns the position information in a dictionary. With course and/or satellites set to
  2544. 1, information about course and satellites is also returned (if available).
  2545. With no callback provided, this call blocks until the position information is available.
  2546. The call returns immediately if a valid callback function is given. This callback function is then
  2547. invoked with the specified time interval (in microseconds) in between the invocations. The callback
  2548. function is called with the the current position information as parameter.
  2549. If partial update is set to 1, the function might return e.g. information about satellites before the
  2550. final location fix has been calculated.
  2551. For an example of the dictionary returned and the detailed keys, see Section 6.6.1.
  2552. stop position()
  2553. Stops an ongoing position request.
  2554. 6For details, please see the Location Acquisition API in the S60 API documentation. The Location Acquisition API
  2555. gathers different positioning technologies together to be used through a consistent interface.
  2556. 7For more information on GPS, please see http://en.wikipedia.org/wiki/Global Positioning System.
  2557. 6.6. positioning — Simplified interface to the position information
  2558. 55
  2559. Page 62
  2560. 6.6.1 Example
  2561. The following example (invoked in a Nokia N95 device) demonstrates how to use the Python positioning
  2562. module to obtain information about the positioning technologies in the device:
  2563. >>> positioning.modules()
  2564. [{’available’: 0, ’id’: 270526873, ’name’: u’Bluetooth GPS’}, {’available’: 1, ’
  2565. id’: 270526858, ’name’: u’Integrated GPS’}, {’available’: 1, ’id’: 270559509, ’n
  2566. ame’: u’Network based’}]
  2567. >>> positioning.default_module()
  2568. 270526858
  2569. >>> positioning.module_info(270526858)
  2570. {’available’: 1, ’status’: {’data_quality’: 3, ’device_status’: 7}, ’version’: u
  2571. 1.00(0)’, ’name’: u’Integrated GPS’, ’position_quality’: {’vertical_accuracy’:
  2572. 10.0, ’time_to_first_fix’: 1000000L, ’cost’: 1, ’time_to_next_fix’: 1000000L, ’h
  2573. orizontal_accuracy’: 10.0, ’power_consumption’: 3}, ’technology’: 1, ’id’: 27052
  2574. 6858, ’capabilities’: 127, ’location’: 1}
  2575. >>>
  2576. The following example demonstrates how to use the Python positioning module.
  2577. # information about available positioning modules
  2578. print "***available modules***"
  2579. print positioning.modules()
  2580. print ""
  2581. # id of the default positioning module
  2582. print "***default module***"
  2583. print positioning.default_module()
  2584. print ""
  2585. # detailed information about the default positioning module
  2586. print "***detailed module info***"
  2587. print positioning.module_info(positioning.default_module())
  2588. print ""
  2589. # select a module (in practise, selecting default module has no
  2590. # relevance.).
  2591. positioning.select_module(positioning.default_module())
  2592. # set requestors.
  2593. # at least one requestor must be set before requesting the position.
  2594. # the last requestor must always be service requestor
  2595. # (whether or not there are other requestors).
  2596. positioning.set_requestors([{"type":"service",
  2597. "format":"application",
  2598. "data":"test_app"}])
  2599. # Example 1. Blocking call
  2600. # get the position.
  2601. # note that the first position()-call may take a long time
  2602. # (because of gps technology).
  2603. print "***position info***"
  2604. print positioning.position()
  2605. print ""
  2606. # re-get the position.
  2607. # this call should be much quicker.
  2608. # ask also course and satellite information.
  2609. print "***course and satellites***"
  2610. print positioning.position(course=1,satellites=1)
  2611. 56
  2612. Chapter 6. Audio and Communication Services
  2613. Page 63
  2614. print ""
  2615. # Example 2. Non-blocking call
  2616. def cb(event):
  2617. print "---"
  2618. print event
  2619. print "---"
  2620. print "***starts the position feed***"
  2621. print positioning.position(course=1,satellites=1,
  2622. callback=cb, interval=500000,
  2623. partial=0)
  2624. An example dictionary returned/printed from the above example script could be as follows:
  2625. {’satellites’: {’horizontal_dop’: 2.34999990463257, ’used_satellites’: 5, ’verti
  2626. cal_dop’: 2.29999995231628, ’time’: 1187167353.0, ’satellites’: 11, ’time_dop’:
  2627. 1.26999998092651}, ’position’: {’latitude’: 60.217033666473, ’altitude’: 42.0, ’
  2628. vertical_accuracy’: 58.0, ’longitude’: 24.878942093007, ’horizontal_accuracy’: 4
  2629. 7.531005859375}, ’course’: {’speed’: 0.0500000007450581, ’heading’: 68.959999084
  2630. 4727, ’heading_accuracy’: 359.989990234375, ’speed_accuracy’: NaN}}
  2631. To run the script in the emulator you must configure PSY emulation from your emulator (SimPSYCon-
  2632. figurator → Select Config File → <some config files>or Tools → Position).
  2633. 6.6. positioning — Simplified interface to the position information
  2634. 57
  2635. Page 64
  2636. 58
  2637. Page 65
  2638. CHAPTER
  2639. SEVEN
  2640. Data Management
  2641. 7.1 contacts — A contacts related services package
  2642. The contacts module offers an API to address book services allowing the creation of contact information
  2643. databases. The contacts module represents a Symbian contact database as a dictionary-like ContactDb
  2644. object, which contains Contact objects and which is indexed using the unique IDs of those objects. A
  2645. Contact object is itself a list-like object, which contains ContactField objects and which is indexed using
  2646. the field indices. Unique IDs and field indices are integers. The ContactDb object supports a limited
  2647. subset of dictionary functionality. Therefore, only
  2648. iter
  2649. ,
  2650. getitem
  2651. ,
  2652. delitem
  2653. ,
  2654. len
  2655. ,
  2656. keys, values, and items are included.
  2657. ContactDb objects represent a live view into the database. If a contact is changed outside your Python ap-
  2658. plication, the changes are visible immediately, and conversely any changes you commit into the database
  2659. are visible immediately to other applications. It is possible to lock a contact for editing, which will pre-
  2660. vent other applications from modifying the contact for as long as the lock is held. This can be done in,
  2661. for example, a contacts editor application when a contact is opened for editing, very much like with the
  2662. Contacts application in your Nokia device. If you try to modify a contact without locking it for editing,
  2663. the contact is automatically locked before the modification and released immediately afterwards.
  2664. 7.1.1 Module Level Functions
  2665. The following free functions - functions that do not belong to any class - are defined in the Contact
  2666. module:
  2667. open([filename[, mode ]])
  2668. Opens a contacts database and returns a ContactDb object. filename should be a full Unicode
  2669. path name. If filename is not given, opens the default contacts database. If mode is not given, the
  2670. database must exist. If mode is ’c’, the database is created if it does not already exist. If mode is
  2671. ’n’, a new, empty database is created, overwriting the possible previous database.
  2672. Warning: Using open together with the additional parameters filename or mode is intended for testing
  2673. purposes only. Due to S60 SDK functionality, the open method can sometimes be unreliable with these
  2674. parameters.
  2675. 7.1.2 ContactDb Object
  2676. There is one default contact database, but it is possible to create several databases with the open function.
  2677. class ContactDb
  2678. ContactDb objects have the following methods:
  2679. add contact()
  2680. Adds a new contact into the database. Returns a Contact object that represents the new
  2681. contact. The returned object is already locked for modification. Note that a newly created
  2682. contact will contain some empty default fields. If you do not want to use the default fields for
  2683. anything, you can ignore them.
  2684. 59
  2685. Page 66
  2686. find(searchterm)
  2687. Finds the contacts that contain the given Unicode string as a substring and returns them as
  2688. a list.
  2689. import vcards(vcards)
  2690. Imports the vCard(s) in the given string into the database.
  2691. export vcards(ids)
  2692. Converts the contacts corresponding to the ID’s in the given tuple ids to vCards and returns
  2693. them as a string.
  2694. keys()
  2695. Returns a list of unique IDs of all Contact objects in the database.
  2696. compact required()
  2697. Verifies whether compacting is recommended. Returns an integer value indicating either a
  2698. true or false state. Returns True if more than 32K of space is unused and if this comprises
  2699. more than 50 percent of the database file, or if more than 256K is wasted in the database file.
  2700. compact()
  2701. Compacts the database to its minimum size.
  2702. delitem
  2703. (id)
  2704. Deletes the given contact from the database.
  2705. field types()
  2706. Returns a list of dictionary objects that contains information on all supported field types.
  2707. The list contains dictionary objects, which each describe one field type. The most important
  2708. keys in the dictionary are ’type’ and ’location’ which together indentify the field type.
  2709. ’type’ can have string values such as ’email address’. ’location’ can have the string
  2710. values ’none’, ’home’, or ’work’. Another important key is ’storagetype’, which defines
  2711. the storage type of the field. ’storagetype’ can have the string values ’text’, ’datetime’,
  2712. ’item id’, or ’binary’. Note that the Contacts extension does not support adding, read-
  2713. ing, or modifying fields of any other type than ’text’ or ’datetime’. The other content
  2714. returned by field types is considered to be advanced knowledge and is not documented
  2715. here.
  2716. groups
  2717. Returns contact groups of the database. Read-only.
  2718. 7.1.3 Contact Object
  2719. A Contact object represents a live view into the state of a single contact in the database. You can access
  2720. the fields either with a contact’s numeric field ID as contact[fieldid], or using the find method.
  2721. Attempting to modify a contact while it has been locked for editing in another application will raise the
  2722. exception ContactBusy.
  2723. class Contact
  2724. Contact objects have the following attributes:
  2725. id
  2726. The unique ID of this Contact. Read-only.
  2727. title
  2728. The title of this Contact. Read-only.
  2729. is group
  2730. Returns 1 if this contact is a contact group. Returns 0 if normal contact entry. Read-only.
  2731. Contact objects have the following methods:
  2732. begin()
  2733. Locks the contact for editing. This prevents other applications from modifying the contact for
  2734. as long as the lock is held. This method will raise the exception ContactBusy if the contact
  2735. has already been locked.
  2736. commit()
  2737. Releases the lock and commits the changes made into the database.
  2738. 60
  2739. Chapter 7. Data Management
  2740. Page 67
  2741. rollback()
  2742. Releases the lock and discards all changes that were made. The contact remains in the state
  2743. it was before begin.
  2744. as vcard()
  2745. Returns the contact as a string in vCard format.
  2746. add field(type [, value [, label=field label ][, location=location spec ]])
  2747. Adds a new field into this Contact. This method raises ContactBusy if the contact has been
  2748. locked by some other application. type can be one of the supported field types as a string.
  2749. In Series 60 editions older than the 3rd one the following field types can be added:
  2750. •city
  2751. •company name
  2752. •country
  2753. •date
  2754. •dtmf string
  2755. •email address
  2756. •extended address
  2757. •fax number
  2758. •first name
  2759. •job title
  2760. •last name
  2761. •mobile number
  2762. •note
  2763. •pager number
  2764. •phone number
  2765. •po box
  2766. •postal address
  2767. •postal code
  2768. •state
  2769. •street address
  2770. •url
  2771. •video number
  2772. •wvid
  2773. The following field types are recognized but cannot be created:
  2774. •first name reading
  2775. •last name reading
  2776. •picture
  2777. •speed dial
  2778. •thumbnail image
  2779. •voicetag
  2780. If 3rd edition of Series 60 is used the following field types can be added:
  2781. •city
  2782. •company name
  2783. •country
  2784. •date
  2785. •dtmf string
  2786. •email address
  2787. •extended address
  2788. •fax number
  2789. •first name
  2790. •job title
  2791. 7.1. contacts — A contacts related services package
  2792. 61
  2793. Page 68
  2794. •last name
  2795. •mobile number
  2796. •note
  2797. •pager number
  2798. •phone number
  2799. •po box
  2800. •postal address
  2801. •postal code
  2802. •state
  2803. •street address
  2804. •url
  2805. •video number
  2806. •picture
  2807. •second name
  2808. •voip
  2809. •sip id
  2810. •personal ringtone
  2811. •share view
  2812. •prefix
  2813. •suffix
  2814. •push to talk
  2815. •locationid indication
  2816. The following field types are recognized but cannot be created at present:
  2817. •first name reading
  2818. •last name reading
  2819. •speed dial
  2820. •thumbnail image
  2821. •voice tag
  2822. •wvid
  2823. All supported field types are passed as strings or Unicode strings, except for ’date’ which is
  2824. a float that represents Unix time. For more information on Unix time, see Section 3.5, Date
  2825. and Time.
  2826. field label is the name of the field shown to the user. If you do not pass a label, the default
  2827. label for the field type is used.
  2828. location spec, if given, must be ’home’ or ’work’. Note that not all combinations of type
  2829. and location are valid. The settings of the current contacts database in use determine which
  2830. ones are valid.
  2831. find([type=field type ][, location=field location ])
  2832. Finds the fields of this contact that match the given search specifications. If no parameters
  2833. are given, all fields are returned.
  2834. delitem
  2835. (fieldindex)
  2836. Deletes the given field from this contact. Note that since this will change the indices of all
  2837. fields that appear after this field in the contact, and since the ContactField objects refer to
  2838. the fields by index, old ContactField objects that refer to fields after the deleted field will
  2839. refer to different fields after this operation.
  2840. 7.1.4 ContactField Object
  2841. A ContactField represents a field of a Contact at a certain index. A ContactField has attributes,
  2842. some of which can be modified. If the parent Contact has not been locked for editing, modifications
  2843. are committed immediately to the database. If the parent Contact has been locked, the changes are
  2844. committed only when commit is called on the Contact.
  2845. 62
  2846. Chapter 7. Data Management
  2847. Page 69
  2848. class ContactField
  2849. ContactField objects have the following attributes:
  2850. label
  2851. The user-visible label of this field. Read-write.
  2852. value
  2853. The value of this field. Read-write.
  2854. type
  2855. The type of this field. Read-only.
  2856. location
  2857. The location of this field. This can be ’none’, ’work’, or ’home’.
  2858. schema
  2859. A dictionary that contains some properties of this field. The contents of this dictionary
  2860. correspond to those returned by the ContactDb method field types.
  2861. 7.1.5 Groups Object
  2862. A Groups object represents Symbian contact groups as a dictionary like object with limited subset of
  2863. dictionary functionality. Each group can be accessed using the group’s unique id as a key. The Groups
  2864. object returns a list like Group object as the value matching the given key.
  2865. The following common methods are supported:
  2866. iter
  2867. ,
  2868. getitem
  2869. ,
  2870. delitem
  2871. and
  2872. len
  2873. .
  2874. class Groups
  2875. Groups objects have the following attributes:
  2876. add group([name ])
  2877. Creates new contact group and returns corresponding Group object. Group name can be given
  2878. as an optional parameter.
  2879. 7.1.6 Group Object
  2880. A Group object represents single Symbian contact group as a list object with limited subset of list
  2881. functionality. The Group object lists Contact entry ids that belong to the group.
  2882. The native Symbian group objects are represented as Symbian contact entries in the database. Therefore
  2883. they can also be accessed as Python Contact objects, but this way their group handling properties cannot
  2884. be used from Python. Use Groups and Group objects to access group functionalities.
  2885. The following common methods are supported:
  2886. iter
  2887. ,
  2888. getitem
  2889. ,
  2890. delitem
  2891. and
  2892. len
  2893. .
  2894. class Group
  2895. Group objects have the following attributes:
  2896. id
  2897. The unique id of the Group object. Read-only.
  2898. name
  2899. The name of the Group object. Read-write.
  2900. 7.1. contacts — A contacts related services package
  2901. 63
  2902. Page 70
  2903. Figure 7.1: The calendar module objects
  2904. 7.2 calendar — Access to calendar related services
  2905. The calendar module offers an API to calendar services. The calendar module represents a Symbian
  2906. agenda database as a dictionary-like CalendarDb object, which contains Entry objects and which is
  2907. indexed using the unique IDs of those objects. There are four types of entry objects: AppointmentEntry,
  2908. EventEntry, AnniversaryEntry, and TodoEntry.
  2909. CalendarDb objects represent a live view into the database. If an entry is changed outside your Python
  2910. application, the changes are visible immediately, and conversely any changes you commit into the
  2911. database are visible immediately to other applications.
  2912. In addition to entries, there are todo lists which contain todo entries. Todo lists are accessed using the
  2913. dictionary-like TodoListDict and TodoList objects.
  2914. All time parameters use Unix time unless stated otherwise. For more information on Unix time, see
  2915. Section 3.5, Date and Time.
  2916. Figure 7.1 demonstrates the relationships of the calendar module objects.
  2917. 7.2.1 Module Level Functions
  2918. The following free functions - functions that do not belong to any class - are defined in the calendar
  2919. module:
  2920. open([filename=None, mode=None ])
  2921. Opens a calendar database and returns a new CalendarDb object.
  2922. If filename is None, the default database is opened.
  2923. If filename is given, it should be a full, absolute path name in Unicode that specifies the calendar
  2924. database to open.
  2925. mode can be:
  2926. •None: Opens an existing calendar database.
  2927. •’c’: Opens an existing calendar database, or creates it if it doesn’t exist.
  2928. •’n’: Creates a new, empty calendar database. If filename exists, the previous contents are
  2929. erased.
  2930. 64
  2931. Chapter 7. Data Management
  2932. Page 71
  2933. 7.2.2 CalendarDb Objects
  2934. Calendar entries and todo lists are stored in a calendar database. There is one default calendar database
  2935. but more calendar databases can be created by invoking open with parameters ’n’ or ’c’.
  2936. class CalendarDb
  2937. CalendarDb objects have the following methods:
  2938. add appointment()
  2939. Creates and returns a new appointment entry AppointmentEntry. The entry is not added
  2940. and saved into the database until Entry.commit is called.
  2941. add event()
  2942. Creates and returns a new event entry EventEntry. The entry is not added and saved into
  2943. the database until Entry.commit is called.
  2944. add anniversary()
  2945. Creates and returns a new anniversary entry AnniversaryEntry. The entry is not added and
  2946. saved into the database until Entry.commit is called.
  2947. add todo()
  2948. Creates and returns new todo entry TodoEntry. The entry is not added and saved into the
  2949. database until Entry.commit is called.
  2950. find instances(start date, end date, search str=u”[ ,appointments=0,events=0,anniversaries=0,todos=0 ])
  2951. The parameters for this function include the start date, end date, search string, and optional
  2952. parameters. The optional parameters define the entry types to be included into the search.
  2953. By default all entry types are included. Returns a list that contains Entry instances found in
  2954. the search. An instance is a dictionary that contains the entry ID and the datetime value. An
  2955. entry may have several instances if it is repeated, for example once every week, etc. However,
  2956. all the returned instances occur on the same day, i.e. on the first day between the start
  2957. and end datetime values that contains instances. To search all instances between the initial
  2958. start and end datetime values, you may have to execute several searches and change the start
  2959. datetime value for each search. A match is detected if the search string is a substring of an
  2960. entry’s content.
  2961. monthly instances(month, appointments=0, events=0, anniversaries=0, todos=0)
  2962. The parameters for this function include month (float) and optional parameters. The optional
  2963. parameters define the entry types to be returned. Returns a list that contains entry instances
  2964. occurring during the specified calendar month.
  2965. daily instances(day, appointments=0, events=0, anniversaries=0, todos=0)
  2966. The parameters for this function include day (float) and optional parameters. The optional
  2967. parameters define the entry types to be returned. Returns a list that contains entry instances
  2968. occurring on the specified day.
  2969. add todo list([name=None ])
  2970. Creates a new todo list. name sets the name of the todo list (Unicode). Returns the ID of
  2971. the created todo list.
  2972. export vcalendars((int,...))
  2973. Returns a vcalendar string that contains the specified entries in vCalendar format. The
  2974. parameter for this function is a tuple that contains the entry IDs of the exported entries.
  2975. import vcalendars(string)
  2976. Imports vcalendar entries, given in the string parameter, to the database. Returns a tuple
  2977. that contains the unique IDs of the imported entries.
  2978. todo lists
  2979. Contains a dictionary-like TodoListDict object for accessing the todo lists of this database.
  2980. delitem
  2981. (id)
  2982. Deletes the given calendar Entry from the database. id is the unique ID of the calendar
  2983. Entry.
  2984. getitem
  2985. (id)
  2986. Returns a calendar Entry object indicated by the unique ID. The returned object can be one
  2987. 7.2. calendar — Access to calendar related services
  2988. 65
  2989. Page 72
  2990. of the following: AppointmentEntry, EventEntry, AnniversaryEntry, or TodoEntry. id is
  2991. the unique ID of the calendar Entry.
  2992. compact()
  2993. Compacts the database file. The returned value (integer) indicates the success of compaction;
  2994. a value other than zero means that the compaction was successful.
  2995. 7.2.3 Entry Objects
  2996. An Entry object represents a live view into the state of a single entry in the database. You can access
  2997. the entries with an entry’s unique ID. If you create a new entry using db.add appointment etc., it is
  2998. saved into the database only if you call the entry’s commit method. In case an entry is already saved
  2999. into the database, the autocommit mode is on by default and all the changes are automatically saved
  3000. into the database, unless you call the entry’s begin method. If you call the entry’s begin method, the
  3001. changes are not saved into the database until you call the entry’s commit method.
  3002. Database entries cannot be locked. In other words, other applications are able to make changes to the
  3003. database entries you are using (not directly to the EntryObjects you are using, but to their representation
  3004. in the database) at the same time you are modifying them, even if you use begin and commit methods.
  3005. class Entry
  3006. Entry objects have the following methods and properties:
  3007. content
  3008. Sets or returns the entry’s content text (Unicode).
  3009. commit()
  3010. Saves the entry or in case of a new entry adds the entry into the database. Note that this can
  3011. be called only in case of a new entry, created with db.add appointment etc., or after begin
  3012. is called.
  3013. rollback()
  3014. Undoes the changes made after last commit.
  3015. set repeat(dictionary)
  3016. Sets the repeat data of the entry. dictionary is a repeat data dictionary that contains all the
  3017. repeat rules. For more information on repeat rules, see Section 7.3.4, Repeat Rules.
  3018. get repeat()
  3019. Returns the repeat data dictionary of the entry.
  3020. location
  3021. Sets or returns the entry’s location data (Unicode), for example meeting room information.
  3022. set time(start[, end ])
  3023. Sets the start and end datetime values of the entry (floats). If only one parameter is given,
  3024. the other will have the same value.
  3025. In case of events, anniversaries, and todo entries the datetime values are truncated to corre-
  3026. sponding date values.
  3027. TodoEntries can be made undated with TodoEntry.set time(None). Making the todo entry
  3028. undated means removing the start and end date and all the repeat rules.
  3029. start time
  3030. The start datetime value (float) of the entry or None if the start datetime of the entry is not
  3031. set.
  3032. end time
  3033. The end datetime value (float) of the entry or None if the end datetime of the entry is not set.
  3034. id
  3035. The unique ID of the entry.
  3036. last modified
  3037. The datetime value (float) of the entry’s last modification in universal time.
  3038. 66
  3039. Chapter 7. Data Management
  3040. Page 73
  3041. alarm
  3042. The alarm datetime value (float) for the entry. None if alarm is not set. Alternatively removes
  3043. the alarm if the value is set to None.
  3044. Alarms can be set to all Entry types. However, only alarms set to Appointments and Anniver-
  3045. saries will actually cause an alarm; this is similar to the Calendar application in your Nokia
  3046. device, which allows you to set an alarm only for Meetings and Anniversaries. In addition,
  3047. alarms set to any entries residing in a database other than the default database do not cause
  3048. actual alarms either.
  3049. priority
  3050. The priority of the entry, which can be an integer ranging from 0 to 255. Native Phonebook
  3051. and Calendar applications in Nokia devices use value 1 for high priority, 2 for normal priority,
  3052. and 3 for low priority.
  3053. crossed out
  3054. The crossed out value of an entry. A value that is interpreted as false means that the entry is
  3055. not crossed out, whereas a value that is interpreted as true means that the entry is crossed out.
  3056. Note that TodoEntries must also have a cross-out time while the other entry types cannot
  3057. have one. If TodoEntry is crossed out using this method, the moment of crossing out is set
  3058. to the cross-out time of the TodoEntry. See also Section 7.3.3, TodoEntry, cross out time.
  3059. replication
  3060. Sets or returns the entry’s replication status, which can be one of the following: ’open’,
  3061. ’private’, or ’restricted’.
  3062. as vcalendar()
  3063. Returns this entry as a vCalendar string.
  3064. AppointmentEntry Objects
  3065. class AppointmentEntry
  3066. AppointmentEntry class contains no additional methods compared to the Entry class from which it is
  3067. derived.
  3068. EventEntry
  3069. class EventEntry
  3070. EventEntry class contains no additional methods compared to the Entry class from which it is derived.
  3071. AnniversaryEntry
  3072. class AnniversaryEntry
  3073. AnniversaryEntry class contains no additional methods compared to the Entry class from which it is
  3074. derived.
  3075. TodoEntry
  3076. TodoEntryobjects represent todo entry types. They have additional properties compared to the Entry
  3077. class from which they are derived.
  3078. class TodoEntry
  3079. TodoEntryobjects have the following additional properties:
  3080. cross out time
  3081. The cross-out date value of the entry. The value can be None meaning that the entry is
  3082. not crossed out, or the cross-out date (float). The set value must be date (float). Setting a
  3083. cross-out time also crosses out the entry. See also Section 7.3.3, Entry Object, crossed out.
  3084. 7.2. calendar — Access to calendar related services
  3085. 67
  3086. Page 74
  3087. todo list
  3088. The ID of the todo list to which this entry belongs.
  3089. TodoListDict
  3090. TodoListDict objects are dictionary-like objects that enable accessing todo lists.
  3091. class TodoListDict
  3092. TodoListDict objects have the following property:
  3093. default list
  3094. The ID of the default todo list.
  3095. TodoList
  3096. TodoList objects are dictionary-like objects that enable accessesing todo lists.
  3097. class TodoList
  3098. TodoList objects have the following properties:
  3099. name
  3100. The name of the todo list as a Unicode string.
  3101. id
  3102. Returns the ID of the todo list as an integer.
  3103. 7.2.4 Repeat Rules
  3104. Repeat rules specify an entry’s repeat status, that is, the recurrence of the entry. There are six repeat
  3105. types:
  3106. • daily: repeated daily
  3107. • weekly: repeat on the specified days of the week, such as Monday and Wednesday, etc.
  3108. • monthly by dates: repeat monthly on the specified dates, such as the 15th and 17th day of the
  3109. month
  3110. • monthly by days: repeat monthly on the specified days, such as the fourth Wednesday of the
  3111. month, or the last Monday of the month
  3112. • yearly by date: repeat yearly on the specified date, such as December 24
  3113. • yearly by day: repeat yearly on the specified day, such as every third Tuesday of May
  3114. There are exceptions to repeat rules. For example, you can specify the datetime value (float) in such a
  3115. way that the entry is not repeated on a specific day even if the repeat rule would specify otherwise.
  3116. You must set the start and end dates (floats) of the repeat. The end date can also be set to None to
  3117. indicate that the repeating continues forever. You can set interval defining how often the repeat occurs,
  3118. for example in a daily repeat: 1 means every day, 2 means every second day, etc. You can also set the
  3119. days specifier which lets you explicitly specify the repeat days; for example in a weekly repeat you can
  3120. set "days":[0,2] which sets the repeat to occur on Mondays and Wednesdays. If you do not set the
  3121. days specifier, the repeat days are calculated automatically based on the start date.
  3122. You can modify repeat data by calling rep data = entry.get repeat(), then making changes to
  3123. rep data dictionary, and then calling entry.set repeat(rep data).
  3124. Repeating can be cancelled by calling entry.set repeat with a parameter that is interpreted to be
  3125. false, such as entry.set repeat(None).
  3126. Repeat definition examples:
  3127. 68
  3128. Chapter 7. Data Management
  3129. Page 75
  3130. repeat = {"type":"daily", #repeat type
  3131. "exceptions":[exception_day, exception_day+2*24*60*60],
  3132. #no appointment on those days
  3133. "start":appt_start_date, #start of the repeat
  3134. "end":appt_start_date+30*24*60*60, #end of the repeat
  3135. "interval":1} #interval (1=every day, 2=every second day etc.)
  3136. repeat = {"type":"weekly", #repeat type
  3137. "days":[0,1], #which days in a week (Monday, Tuesday)
  3138. "exceptions":[exception_day], #no appointment on that day
  3139. "start":appt_start_date, #start of the repeat
  3140. "end":appt_start_date+30*24*60*60, #end of the repeat
  3141. "interval":1}
  3142. #interval (1=every week, 2=every second week etc.)
  3143. repeat = {"type":"monthly_by_days", #repeat type
  3144. # appointments on second Tuesday and last Monday of the month
  3145. "days":[{"week":1, "day":1},{"week":4, "day":0}],
  3146. "exceptions":[exception_day], #no appointment on that day
  3147. "start":appt_start_date, #start of the repeat
  3148. "end":appt_start_date+30*24*60*60, #end of the repeat
  3149. "interval":1}
  3150. #interval (1=every month, 2=every second month etc.)
  3151. repeat = {"type":"monthly_by_dates", #repeat type
  3152. "days":[0,15],
  3153. # appointments on the 1st and 16th day of the month.
  3154. "exceptions":[exception_day], #no appointment on that day
  3155. "start":appt_start_date, #start of the repeat
  3156. "end":appt_start_date+30*24*60*60, #end of the repeat
  3157. "interval":1}
  3158. #interval (1=every month, 2=every second month etc.)
  3159. repeat = {"type":"yearly_by_date", #repeat type
  3160. "exceptions":[exception_day], #no appointment on that day
  3161. "start":appt_start_date, #start of the repeat
  3162. "end":appt_start_date+3*365*24*60*60, #end of the repeat
  3163. "interval":1}
  3164. #interval (1=every year, 2=every second year etc.)
  3165. repeat = {"type":"yearly_by_day", #repeat type
  3166. # appointments on the second Tuesday of February
  3167. "days":{"day":1, "week":1, "month":1},
  3168. "exceptions":[exception_day], #no appointment on that day
  3169. "start":appt_start_date, #start of the repeat
  3170. "end":appt_start_date+3*365*24*60*60, #end of the repeat
  3171. "interval":1}
  3172. #interval (1=every year, 2=every second year etc.)
  3173. 7.3 calendar for EKA2 — Access to calendar related services
  3174. The calendar module offers an API to calendar services. The calendar module represents a Symbian
  3175. agenda database as a dictionary-like CalendarDb object, which contains Entry objects and which is
  3176. indexed using the unique IDs of those objects. There are five types of entry objects: AppointmentEntry,
  3177. EventEntry, AnniversaryEntry, ReminderEntry, and TodoEntry.
  3178. CalendarDb objects represent a live view into the database. If an entry is changed outside your Python
  3179. application, the changes are visible immediately, and conversely any changes you commit into the
  3180. database are visible immediately to other applications.
  3181. 7.3. calendar for EKA2 — Access to calendar related services
  3182. 69
  3183. Page 76
  3184. All time parameters use Unix time unless stated otherwise. For more information on Unix time, see
  3185. Section 3.5, Date and Time.
  3186. 7.3.1 Module Level Functions
  3187. The following free functions - functions that do not belong to any class - are defined in the calendar
  3188. module:
  3189. open([filename=None, mode=None ])
  3190. Opens a calendar database and returns a new CalendarDb object.
  3191. If filename is None, the default database is opened.
  3192. If filename is given, it should contain drive letter, colon and file’s name, but no absolute path.
  3193. mode can be:
  3194. •None: Opens an existing calendar database.
  3195. •’c’: Opens an existing calendar database, or creates it if it doesn’t exist.
  3196. •’n’: Creates a new, empty calendar database. If filename exists, the previous contents are
  3197. erased.
  3198. 7.3.2 CalendarDb Objects
  3199. Calendar entries are stored in a calendar database. There is one default calendar database but more
  3200. calendar databases can be created by invoking open with parameters ’n’ or ’c’.
  3201. class CalendarDb
  3202. CalendarDb objects have the following methods:
  3203. add appointment()
  3204. Creates and returns a new appointment entry AppointmentEntry. The entry is not added
  3205. and saved into the database until Entry.commit is called.
  3206. add event()
  3207. Creates and returns a new event entry EventEntry. The entry is not added and saved into
  3208. the database until Entry.commit is called.
  3209. add anniversary()
  3210. Creates and returns a new anniversary entry AnniversaryEntry. The entry is not added and
  3211. saved into the database until Entry.commit is called.
  3212. add todo()
  3213. Creates and returns new todo entry TodoEntry. The entry is not added and saved into the
  3214. database until Entry.commit is called.
  3215. add reminder()
  3216. Creates and returns new reminder entry ReminderEntry. The entry is not added and saved
  3217. into the database until Entry.commit is called.
  3218. find instances(start date, end date, search str=u”[ ,appointments=0,events=0,anniversaries=0,todos=0,reminders=0 ])
  3219. The parameters for this function include the start date, end date, search string, and optional
  3220. parameters. The optional parameters define the entry types to be included into the search.
  3221. By default all entry types are included. Returns a list that contains Entry instances found
  3222. in the search. An instance is a dictionary that contains the entry ID and the datetime value.
  3223. An entry may have several instances if it is repeated, for example once every week, etc.
  3224. monthly instances(month, appointments=0, events=0, anniversaries=0, todos=0, reminders=0)
  3225. The parameters for this function include month (float) and optional parameters. The optional
  3226. parameters define the entry types to be returned. Returns a list that contains entry instances
  3227. occurring during the specified calendar month.
  3228. 70
  3229. Chapter 7. Data Management
  3230. Page 77
  3231. daily instances(day, appointments=0, events=0, anniversaries=0, todos=0)
  3232. The parameters for this function include day (float) and optional parameters. The optional
  3233. parameters define the entry types to be returned. Returns a list that contains entry instances
  3234. occurring on the specified day.
  3235. export vcalendars((int,...))
  3236. Returns a vcalendar string that contains the specified entries in vCalendar format. The
  3237. parameter for this function is a tuple that contains the entry IDs of the exported entries.
  3238. import vcalendars(string)
  3239. Imports vcalendar entries, given in the string parameter, to the database. Returns a list
  3240. that contains the unique IDs of the imported entries.
  3241. delitem
  3242. (id)
  3243. Deletes the given calendar Entry from the database. id is the unique ID of the calendar
  3244. Entry.
  3245. getitem
  3246. (id)
  3247. Returns a calendar Entry object indicated by the unique ID. The returned object can be one
  3248. of the following: AppointmentEntry, EventEntry, AnniversaryEntry, ReminderEntry, or
  3249. TodoEntry. id is the unique ID of the calendar Entry.
  3250. 7.3.3 Entry Objects
  3251. An Entry object represents a live view into the state of a single entry in the database. You can access
  3252. the entries with an entry’s unique ID. If you create a new entry using db.add appointment etc., it is
  3253. saved into the database only if you call the entry’s commit method. In case an entry is already saved
  3254. into the database, the autocommit mode is on by default and all the changes are automatically saved
  3255. into the database, unless you call the entry’s begin method. If you call the entry’s begin method, the
  3256. changes are not saved into the database until you call the entry’s commit method.
  3257. Database entries cannot be locked. In other words, other applications are able to make changes to the
  3258. database entries you are using (not directly to the EntryObjects you are using, but to their representation
  3259. in the database) at the same time you are modifying them, even if you use begin and commit methods.
  3260. class Entry
  3261. Entry objects have the following methods and properties:
  3262. content
  3263. Sets or returns the entry’s content text (Unicode).
  3264. commit()
  3265. Saves the entry or in case of a new entry adds the entry into the database. Note that this can
  3266. be called only in case of a new entry, created with db.add appointment etc., or after begin
  3267. is called.
  3268. rollback()
  3269. Undoes the changes made after last commit.
  3270. set repeat(dictionary)
  3271. Sets the repeat data of the entry. dictionary is a repeat data dictionary that contains all the
  3272. repeat rules. For more information on repeat rules, see Section 7.3.4, Repeat Rules.
  3273. get repeat()
  3274. Returns the repeat data dictionary of the entry.
  3275. location
  3276. Sets or returns the entry’s location data (Unicode), for example meeting room information.
  3277. set time(start[, end ])
  3278. Sets the start and end datetime values of the entry (floats). If only one parameter is given,
  3279. the other will have the same value.
  3280. In case of events, anniversaries, and todo entries the datetime values are truncated to corre-
  3281. sponding date values.
  3282. TodoEntries can be made undated with TodoEntry.set time(None). Making the todo entry
  3283. undated means removing the start and end date and all the repeat rules.
  3284. 7.3. calendar for EKA2 — Access to calendar related services
  3285. 71
  3286. Page 78
  3287. start time
  3288. The start datetime value (float) of the entry or None if the start datetime of the entry is not
  3289. set.
  3290. end time
  3291. The end datetime value (float) of the entry or None if the end datetime of the entry is not set.
  3292. id
  3293. The unique ID of the entry.
  3294. last modified
  3295. The datetime value (float) of the entry’s last modification in universal time.
  3296. originating
  3297. An integer value indicating if the entry is an originating entry or a modifying entry.
  3298. alarm
  3299. The alarm datetime value (float) for the entry. None if alarm is not set. Alternatively removes
  3300. the alarm if the value is set to None.
  3301. Alarms can be set to all Entry types. However, only alarms set to Appointments and Anniver-
  3302. saries will actually cause an alarm; this is similar to the Calendar application in your Nokia
  3303. device, which allows you to set an alarm only for Meetings and Anniversaries. In addition,
  3304. alarms set to any entries residing in a database other than the default database do not cause
  3305. actual alarms either.
  3306. priority
  3307. The priority of the entry, which can be an integer ranging from 0 to 255. Native Phonebook
  3308. and Calendar applications in Nokia devices use value 1 for high priority, 2 for normal priority,
  3309. and 3 for low priority.
  3310. crossed out
  3311. The crossed out value of an entry. Only valid for todo entries. A value that is interpreted as
  3312. false means that the entry is not crossed out, whereas a value that is interpreted as true means
  3313. that the entry is crossed out. Note that TodoEntries must also have a cross-out time. If
  3314. TodoEntry is crossed out using this method, the moment of crossing out is set to the cross-out
  3315. time of the TodoEntry. See also Section 7.3.3, TodoEntry, cross out time.
  3316. replication
  3317. Sets or returns the entry’s replication status, which can be one of the following: ’open’,
  3318. ’private’, or ’restricted’.
  3319. as vcalendar()
  3320. Returns this entry as a vCalendar string.
  3321. AppointmentEntry Objects
  3322. class AppointmentEntry
  3323. AppointmentEntry class contains no additional methods compared to the Entry class from which it is
  3324. derived.
  3325. EventEntry
  3326. class EventEntry
  3327. EventEntry class contains no additional methods compared to the Entry class from which it is derived.
  3328. AnniversaryEntry
  3329. class AnniversaryEntry
  3330. AnniversaryEntry class contains no additional methods compared to the Entry class from which it is
  3331. derived.
  3332. 72
  3333. Chapter 7. Data Management
  3334. Page 79
  3335. ReminderEntry
  3336. class ReminderEntry
  3337. ReminderEntry class contains no additional methods compared to the Entry class from which it is
  3338. derived.
  3339. TodoEntry
  3340. TodoEntryobjects represent todo entry types. They have additional properties compared to the Entry
  3341. class from which they are derived.
  3342. class TodoEntry
  3343. TodoEntryobjects have the following additional properties:
  3344. cross out time
  3345. The cross-out date value of the entry. The value can be None meaning that the entry is
  3346. not crossed out, or the cross-out date (float). The set value must be date (float). Setting a
  3347. cross-out time also crosses out the entry. See also Section 7.3.3, Entry Object, crossed out.
  3348. 7.3.4 Repeat Rules
  3349. Repeat rules specify an entry’s repeat status, that is, the recurrence of the entry. There are six repeat
  3350. types:
  3351. • daily: repeated daily
  3352. • weekly: repeat on the specified days of the week, such as Monday and Wednesday, etc.
  3353. • monthly by dates: repeat monthly on the specified dates, such as the 15th and 17th day of the
  3354. month
  3355. • monthly by days: repeat monthly on the specified days, such as the fourth Wednesday of the
  3356. month, or the last Monday of the month
  3357. • yearly by date: repeat yearly on the specified date, such as December 24
  3358. • yearly by day: repeat yearly on the specified day, such as every third Tuesday of May
  3359. There are exceptions to repeat rules. For example, you can specify the datetime value (float) in such a
  3360. way that the entry is not repeated on a specific day even if the repeat rule would specify otherwise.
  3361. You must set the start and end dates (floats) of the repeat. The end date can also be set to None to
  3362. indicate that the repeating continues forever. You can set interval defining how often the repeat occurs,
  3363. for example in a daily repeat: 1 means every day, 2 means every second day, etc. You can also set the
  3364. days specifier which lets you explicitly specify the repeat days; for example in a weekly repeat you can
  3365. set "days":[0,2] which sets the repeat to occur on Mondays and Wednesdays. If you do not set the
  3366. days specifier, the repeat days are calculated automatically based on the start date.
  3367. You can modify repeat data by calling rep data = entry.get repeat(), then making changes to
  3368. rep data dictionary, and then calling entry.set repeat(rep data).
  3369. Repeating can be cancelled by calling entry.set repeat with a parameter that is interpreted to be
  3370. false, such as entry.set repeat(None).
  3371. Repeat definition examples:
  3372. repeat = {"type":"daily", #repeat type
  3373. "exceptions":[exception_day, exception_day+2*24*60*60],
  3374. #no appointment on those days
  3375. "start":appt_start_date, #start of the repeat
  3376. 7.3. calendar for EKA2 — Access to calendar related services
  3377. 73
  3378. Page 80
  3379. "end":appt_start_date+30*24*60*60, #end of the repeat
  3380. "interval":1} #interval (1=every day, 2=every second day etc.)
  3381. repeat = {"type":"weekly", #repeat type
  3382. "days":[0,1], #which days in a week (Monday, Tuesday)
  3383. "exceptions":[exception_day], #no appointment on that day
  3384. "start":appt_start_date, #start of the repeat
  3385. "end":appt_start_date+30*24*60*60, #end of the repeat
  3386. "interval":1}
  3387. #interval (1=every week, 2=every second week etc.)
  3388. repeat = {"type":"monthly_by_days", #repeat type
  3389. # appointments on second Tuesday and last Monday of the month
  3390. "days":[{"week":1, "day":1},{"week":4, "day":0}],
  3391. "exceptions":[exception_day], #no appointment on that day
  3392. "start":appt_start_date, #start of the repeat
  3393. "end":appt_start_date+30*24*60*60, #end of the repeat
  3394. "interval":1}
  3395. #interval (1=every month, 2=every second month etc.)
  3396. repeat = {"type":"monthly_by_dates", #repeat type
  3397. "days":[0,15],
  3398. # appointments on the 1st and 16th day of the month.
  3399. "exceptions":[exception_day], #no appointment on that day
  3400. "start":appt_start_date, #start of the repeat
  3401. "end":appt_start_date+30*24*60*60, #end of the repeat
  3402. "interval":1}
  3403. #interval (1=every month, 2=every second month etc.)
  3404. repeat = {"type":"yearly_by_date", #repeat type
  3405. "exceptions":[exception_day], #no appointment on that day
  3406. "start":appt_start_date, #start of the repeat
  3407. "end":appt_start_date+3*365*24*60*60, #end of the repeat
  3408. "interval":1}
  3409. #interval (1=every year, 2=every second year etc.)
  3410. repeat = {"type":"yearly_by_day", #repeat type
  3411. # appointments on the second Tuesday of February
  3412. "days":{"day":1, "week":1, "month":1},
  3413. "exceptions":[exception_day], #no appointment on that day
  3414. "start":appt_start_date, #start of the repeat
  3415. "end":appt_start_date+3*365*24*60*60, #end of the repeat
  3416. "interval":1}
  3417. #interval (1=every year, 2=every second year etc.)
  3418. 7.4 e32db — Interface to the Symbian native DB
  3419. The e32db module provides an API for relational database manipulation with a restricted SQL syntax.
  3420. For details of DBMS support, see the S60 SDK documentation. For examples on using this module, see
  3421. [6].
  3422. The e32db module defines the following functions:
  3423. format rawtime(timevalue)
  3424. Formats timevalue (Symbian time) according to the current system’s date/time formatting rules
  3425. and returns it as a Unicode string.
  3426. format time(timevalue)
  3427. Formats timevalue according to the current system’s date/time formatting rules and returns it as
  3428. a Unicode string.
  3429. 74
  3430. Chapter 7. Data Management
  3431. Page 81
  3432. 7.4.1 Dbms Objects
  3433. class Dbms()
  3434. Creates a Dbms object. Dbms objects support basic operations on a database.
  3435. Dbms objects have the following methods:
  3436. begin()
  3437. Begins a transaction on the database.
  3438. close()
  3439. Closes the database object. It is safe to try to close a database object even if it is not open.
  3440. commit()
  3441. Commits the current transaction.
  3442. compact()
  3443. Compacts the database, reclaiming unused space in the database file.
  3444. create(dbname)
  3445. Creates a database with path dbname.
  3446. execute(query)
  3447. Executes an SQL query. On success, returns 0 if a DDL (SQL schema update) statement was
  3448. executed. Returns the number of rows inserted, updated, or deleted, if a DML (SQL data update)
  3449. statement was executed.
  3450. open(dbname)
  3451. Opens the database in file dbname. This should be a full Unicode path name, for example,
  3452. u’c:\\foo.db’.
  3453. rollback()
  3454. Rolls back the current transaction.
  3455. 7.4.2 DB view Objects
  3456. class Db view()
  3457. Creates a Db view object. DB view objects generate rowsets from a SQL query. They provide
  3458. functions to parse and evaluate the rowsets.
  3459. Db view objects have the following methods:
  3460. col(column)
  3461. Returns the value in column. The first column of the rowset has the index 1. If the type of the
  3462. column is not supported, a TypeError is raised. See Table 7.1 for a list of supported data types.
  3463. col count()
  3464. Returns the number of columns defined in the rowset.
  3465. col length(column)
  3466. Gets the length of the value in column. Empty columns have a length of zero; non-empty numerical
  3467. and date/time columns have a length of 1. For text columns, the length is the character count,
  3468. and for binary columns, the length is the byte count.
  3469. col raw(column)
  3470. Extracts the value of column as raw binary data, and returns it as a Python string. The first
  3471. column of the rowset has the index 1. See Table 7.1 for a list of supported data types.
  3472. col rawtime(column)
  3473. Extracts the value of a date/time column at index column as a long integer, which represents the
  3474. raw Symbian time value. The first column of the rowset has the index 1. See Table 7.1 for a list
  3475. of the supported data types.
  3476. col type(column)
  3477. Returns the numeric type of the given column as an integer from a Symbian-specific list of types.
  3478. This function is used in the implementation of method col.
  3479. 7.4. e32db — Interface to the Symbian native DB
  3480. 75
  3481. Page 82
  3482. count line()
  3483. Returns the number of rows available in the rowset.
  3484. first line()
  3485. Positions the cursor on the first row in the rowset.
  3486. get line()
  3487. Gets the current row data for access.
  3488. is col null(column)
  3489. Tests whether column is empty. Empty columns can be accessed like normal columns. Empty
  3490. numerical columns return a 0 or an equivalent value, and text and binary columns have a zero
  3491. length.
  3492. next line()
  3493. Moves the cursor to the next row in the rowset.
  3494. prepare(db, query)
  3495. Prepares the view object for evaluating an SQL select statement. db is a Dbms object and query
  3496. the SQL query to be executed.
  3497. 7.4.3 Mapping Between SQL and Python Data Types
  3498. See Table 7.1 for a summary of mapping between SQL and Python data types. The col function can
  3499. extract any value except LONG VARBINARY and return it as the proper Python value. In addition, the
  3500. col raw function can extract any column type except LONG VARCHAR and LONG VARBINARY as raw binary
  3501. data and return it as a Python string.
  3502. Inserting, updating, or searching for BINARY, VARBINARY, or LONG VARBINARY values is not supported.
  3503. BINARY and VARBINARY values can be read with col or col raw.
  3504. SQLtype
  3505. Symbian column type (in the
  3506. DBMS C++ API)
  3507. Python type
  3508. Supported
  3509. BIT
  3510. EDbColBit
  3511. int
  3512. yes
  3513. TINYINT
  3514. EDbColInt8
  3515. UNSIGNED TINYINT
  3516. EDbColUint8
  3517. SMALLINT
  3518. EDbColInt16
  3519. UNSIGNED SMALLINT
  3520. EDbColUint16
  3521. INTEGER
  3522. EDbColInt32
  3523. UNSIGNED INTEGER
  3524. EDbColUint32
  3525. COUNTER
  3526. EDbColUint32 (with the TDb-
  3527. Col::EAutoIncrement attribute)
  3528. BIGINT
  3529. EDbColInt64
  3530. long
  3531. REAL
  3532. EDbColReal32
  3533. float
  3534. FLOAT
  3535. EDbColReal64
  3536. DOUBLE
  3537. DOUBLE PRECISION
  3538. DATE
  3539. EDbColDateTime
  3540. float (or long, with col rawtime())
  3541. TIME
  3542. TIMESTAMP
  3543. CHAR(n)
  3544. EDbColText
  3545. Unicode
  3546. VARCHAR(n)
  3547. LONG VARCHAR
  3548. EDbColLongText
  3549. BINARY(n)
  3550. EDbColBinary
  3551. str
  3552. read only
  3553. VARBINARY(n)
  3554. LONG VARBINARY
  3555. EDbColLongBinary
  3556. n/a
  3557. no
  3558. Table 7.1: Mapping between SQL and Python types
  3559. 76
  3560. Chapter 7. Data Management
  3561. Page 83
  3562. 7.4.4 Date and Time Handling
  3563. The functions col and format time use Unix time, seconds since January 1, 1970, 00:00:00 UTC, as the
  3564. time format. Internally the database uses the native Symbian time representation that provides greater
  3565. precision and range than the Unix time. The native Symbian time format is a 64-bit value that represents
  3566. microseconds since January 1st 0 AD 00:00:00 local time, nominal Gregorian. BC dates are represented
  3567. by negative values. Since converting this format to Unix time and back may cause slight round-off errors,
  3568. you have to use the functions col rawtime and format rawtime if you need to be able to handle these
  3569. values with full precision.
  3570. The representation of date and time literals in SQL statements depends on the current system date and
  3571. time format. Note that the only accepted ordering of day, month, and year is the one that the system is
  3572. currently configured to use. Dates in other order are rejected. The recommended way to form date/time
  3573. literals for SQL statements is to use the functions format time or format rawtime that format the
  3574. given date/time values properly according to the current system’s date/time format settings.
  3575. 7.5 e32dbm — DBM implemented using the Symbian native DBMS
  3576. The e32dbm module provides a DBM API that uses the native Symbian RDBMS as its storage back-end.
  3577. The module API resembles that of the gdbm module. The main differences are:
  3578. • The firstkey() - nextkey() interface for iterating through keys is not supported. Use the "for
  3579. key in db" idiom or the keys or keysiter methods instead.
  3580. • This module supports a more complete set of dictionary features than gdbm
  3581. • The values are always stored as Unicode, and thus the values returned are Unicode strings even if
  3582. they were given to the DBM as normal strings.
  3583. 7.5.1 Module Level Functions
  3584. The e32dbm defines the following functions:
  3585. open(dbname[,flags, mode ])
  3586. Opens or creates the given database file and returns an e32dbm object. Note that dbname should
  3587. be a full path name, for example, u’c:\\foo.db’. Flags can be:
  3588. •’r’: opens an existing database in read-only mode. This is the default value.
  3589. •’w’: opens an existing database in read-write mode.
  3590. •’c’: opens a database in read-write mode. Creates a new database if the database does not
  3591. exist.
  3592. •’n’: creates a new empty database and opens it in read-write mode.
  3593. If the character ’f’ is appended to flags, the database is opened in fast mode. In fast mode, updates
  3594. are written to the database only when one of these methods is called: sync, close, reorganize,
  3595. or clear.
  3596. Since the connection object destructor calls close, it is not strictly necessary to close the database before
  3597. exiting to ensure that data is saved, but it is still good practice to call the close method when you are
  3598. done with using the database. Closing the database releases the lock on the file and allows the file to be
  3599. reopened or deleted without exiting the interpreter.
  3600. If you plan to do several updates, it is highly recommended that you open the database in fast mode,
  3601. since inserts and updates are more efficient when they are bundled together in a larger transaction. This
  3602. is especially important when you plan to insert large amounts of data, since inserting records to e32db
  3603. is very slow if done one record at a time.
  3604. 7.5. e32dbm — DBM implemented using the Symbian native DBMS
  3605. 77
  3606. Page 84
  3607. 7.5.2 e32dbm Objects
  3608. The e32dbm objects returned by the open function support most of the standard dictionary methods.
  3609. The supported dictionary methods are:
  3610. getitem
  3611. setitem
  3612. delitem
  3613. • has key
  3614. • update
  3615. len
  3616. iter
  3617. • iterkeys
  3618. • iteritems
  3619. • itervalues
  3620. • get
  3621. • setdefault
  3622. • pop
  3623. • popitem
  3624. • clear
  3625. These work the same way as the corresponding methods in a normal dictionary.
  3626. In addition, e32dbm objects have the following methods:
  3627. close()
  3628. Closes the database. In fast mode, commits all pending updates to disk. close raises an exception
  3629. if called on a database that is not open.
  3630. reorganize()
  3631. Reorganizes the database. Reorganization calls compact on the underlying e32db database file,
  3632. which reclaims unused space in the file. Reorganizing the database is recommended after several
  3633. updates.
  3634. sync()
  3635. In fast mode, commits all pending updates to disk.
  3636. 78
  3637. Chapter 7. Data Management
  3638. Page 85
  3639. CHAPTER
  3640. EIGHT
  3641. Standard Library Support and Extensions
  3642. 8.1 Support for Python Standard Library
  3643. The standard library support in Python for S60 is summarized in Table 8.1. For API descriptions, see
  3644. [1].
  3645. Name
  3646. Type
  3647. Status Remarks
  3648. testcapi
  3649. PYD
  3650. Y
  3651. anydbm
  3652. PY
  3653. X
  3654. DBM API is implemented by PY e32dbm that
  3655. relies on PYD e32db (see Chapter 7.5, e32dbm
  3656. Module)
  3657. atexit
  3658. PY
  3659. X
  3660. base64
  3661. PY
  3662. X
  3663. bdb
  3664. PY
  3665. (X)
  3666. binascii
  3667. built-in X
  3668. cmd
  3669. PY
  3670. (X)
  3671. code
  3672. PY
  3673. X
  3674. codecs
  3675. PY
  3676. X
  3677. codeop
  3678. PY
  3679. X
  3680. copy
  3681. PY
  3682. X
  3683. copy reg
  3684. PY
  3685. X
  3686. cStringIO
  3687. built-in X
  3688. dis
  3689. PY
  3690. (X)
  3691. errno
  3692. built-in X
  3693. exceptions
  3694. built-in X
  3695. future
  3696. PY
  3697. X
  3698. httplib
  3699. PY
  3700. X
  3701. imp
  3702. built-in X
  3703. keyword
  3704. PY
  3705. X
  3706. linecache
  3707. PY
  3708. X
  3709. marshal
  3710. built-in X
  3711. math
  3712. built-in X
  3713. md51
  3714. built-in X
  3715. mimetools
  3716. PY
  3717. X
  3718. operator
  3719. built-in X
  3720. os, os.path
  3721. PY
  3722. X
  3723. Wraps built-in e32posix. Limitations dis-
  3724. cussed in Section 3.9, Limitations and Areas
  3725. of Development.
  3726. pdb
  3727. PY
  3728. (X)
  3729. quopri
  3730. PY
  3731. X
  3732. Name
  3733. Type
  3734. Status
  3735. Remarks
  3736. 1Derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
  3737. 79
  3738. Page 86
  3739. random
  3740. PY
  3741. X
  3742. re
  3743. PY
  3744. X
  3745. Uses PY sre as its engine.
  3746. repr
  3747. PY
  3748. X
  3749. rfc822
  3750. PY
  3751. X
  3752. select
  3753. PY
  3754. X
  3755. A minimal implementation: select is sup-
  3756. ported only for input from sockets.
  3757. socket
  3758. PY
  3759. X
  3760. Requires PYD e32socket. Contains exten-
  3761. sions as described in Section 8.2.2, socket
  3762. Module. Limitations discussed in Section 3.9,
  3763. Limitations and Areas of Development.
  3764. sre
  3765. PY
  3766. X
  3767. Wraps built-in sre.
  3768. string
  3769. PY
  3770. X
  3771. StringIO
  3772. PY
  3773. X
  3774. struct
  3775. built-in X
  3776. sys
  3777. built-in X
  3778. thread
  3779. built-in X
  3780. Contains extensions as described in Section
  3781. 8.2.1, thread Module
  3782. threading
  3783. PY
  3784. (X)
  3785. time
  3786. built-in X
  3787. traceback
  3788. PY
  3789. X
  3790. types
  3791. PY
  3792. X
  3793. urllib
  3794. PY
  3795. X
  3796. urlparse(urlsplit only) PY
  3797. X
  3798. uu
  3799. PY
  3800. X
  3801. warnings
  3802. PY
  3803. X
  3804. whichdb
  3805. PY
  3806. X
  3807. xreadlines
  3808. built-in X
  3809. zipfile
  3810. PY
  3811. X
  3812. zlib
  3813. PYD
  3814. X
  3815. Table 8.1: Status of library module support.
  3816. Table 8.1 uses the following coding for module types:
  3817. • PY – module is implemented in Python.
  3818. • Built-in – module is a built-in C/C++ module.
  3819. • PYD – module is a dynamically loadable C/C++ module.
  3820. For support status, the following codes are used:
  3821. • X – included to the Series 60 Python distribution.
  3822. • (X) – not included to the Series 60 Python distribution, but works both on phone and SDK.
  3823. • Y – included only to the SDK distribution.
  3824. 8.2 Extensions to Standard Library Modules
  3825. The following standard modules have been extended.
  3826. 80
  3827. Chapter 8. Standard Library Support and Extensions
  3828. Page 87
  3829. 8.2.1 thread — S60 extensions to standard thread module
  3830. The following function has been added to the standard thread module:
  3831. ao waittid(thread id)
  3832. Synchronizes with the end of the execution of the thread identified by the given thread id. The
  3833. implementation is based on a Symbian OS active object. For the blocking behavior, see Section
  3834. 4.1.2, Ao lock Type.
  3835. 8.2.2 socket — S60 extensions to standard socket module
  3836. Bluetooth (BT) support has been added to the standard socket module. The following related constants
  3837. and functions are defined:
  3838. Note:
  3839. In release 1.0 the functions bt advertise service, bt obex receive, and
  3840. bt rfcomm get available server channel incorrectly expected to be given the internal
  3841. e32socket.socket object as the socket parameter instead of the proper socket object. Now the func-
  3842. tions work correctly. The old calling convention is still supported but it is deprecated and may be
  3843. removed in a future release.
  3844. AF BT
  3845. Represents the Bluetooth address family.
  3846. BTPROTO RFCOMM
  3847. This constant represents the Bluetooth protocol RFCOMM.
  3848. RFCOMM
  3849. OBEX
  3850. Bluetooth service classes supported by bt advertise service.
  3851. AUTH
  3852. ENCRYPT
  3853. AUTHOR
  3854. Bluetooth security mode flags.
  3855. bt advertise service(name, socket, flag, class)
  3856. Sets a service advertising the service name (Unicode) on local channel that is bound to socket.
  3857. If flag is True, the advertising is turned on, otherwise it is turned off. The service class to be
  3858. advertised is either RFCOMM or OBEX.
  3859. bt discover([address ])
  3860. Performs the Bluetooth device discovery (if the optional BT device address is not given) and the
  3861. discovery of RFCOMM class services on the chosen device. Returns a pair: BT device address,
  3862. dictionary of services, where Unicode service name is the key and the corresponding port is the
  3863. value.
  3864. bt obex discover([address ])
  3865. Same as discover, but for discovery of OBEX class services on the chosen device.
  3866. bt obex send file(address, channel, filename)
  3867. Sends file filename (Unicode) wrapped into an OBEX object to remote address, channel.
  3868. bt obex receive(socket, filename)
  3869. Receives a file as an OBEX object, unwraps and stores it into filename (Unicode). socket is a
  3870. bound OBEX socket.
  3871. bt rfcomm get available server channel(socket)
  3872. Returns an available RFCOMM server channel for socket.
  3873. set security(socket, mode)
  3874. Sets the security level of the given bound socket. The mode is an integer flag that is formed using
  3875. a binary or operation of one or more of: AUTH (authentication), ENCRYPT, AUTHOR (authorization).
  3876. Example: set security(s, AUTH | AUTHOR).
  3877. 8.2. Extensions to Standard Library Modules
  3878. 81
  3879. Page 88
  3880. Note: When listening to a Bluetooth socket on the phone, it is necessary to set the security level.
  3881. Note: SSL is not supported in S60 1st Edition. SSL client certificates are not supported at all.
  3882. For examples on the usage of these functions, see Programming with Python for S60 Platform [6].
  3883. Setting default Access Point (AP) has been added to the standard socket module. The following related
  3884. constants and functions are defined:
  3885. select access point()
  3886. This opens popup selection where access points are listed and can be selected. Returns selected
  3887. access point id.
  3888. access point(apid)
  3889. This creates access point object by given apid. Returns access point object.
  3890. set default access point(apo)
  3891. This sets the default access point that is used when socket is opened. Setting apo to "None" will
  3892. clear default access point.
  3893. access points()
  3894. This lists access points id’s and names that are available.
  3895. Example 1:
  3896. #access point is selected from the list
  3897. apid = select_access_point()
  3898. apo = access_point(apid)
  3899. set_default_access_point(apo)
  3900. s = socket(AF_INET, SOCK_STREAM)
  3901. print apo.ip()
  3902. s.connect((’www.sourceforge.net’,80))
  3903. s.send(’GET /\r\n\r\n’)
  3904. s.recv(100)
  3905. s.close()
  3906. apo.stop()
  3907. Example 2:
  3908. #Access point id is already known
  3909. apo = access_point(1)
  3910. set_default_access_point(apo)
  3911. s = socket(AF_INET, SOCK_STREAM)
  3912. s.connect((’www.sourceforge.net’,80))
  3913. s.send(’GET /\r\n\r\n’)
  3914. s.recv(100)
  3915. s.close()
  3916. apo.stop()
  3917. Example 3:
  3918. #display interface ip.
  3919. #access point is selected from the list
  3920. apid = select_access_point()
  3921. apo = access_point(apid)
  3922. apo.start()
  3923. #Note that ip-address is given by operator, if static ip-address is not defined,
  3924. #when connection is started
  3925. print apo.ip()
  3926. #When connection is closed dynamic ip-address is released
  3927. apo.stop()
  3928. 82
  3929. Chapter 8. Standard Library Support and Extensions
  3930. Page 89
  3931. CHAPTER
  3932. NINE
  3933. Extending and Embedding
  3934. 9.1 Python/C API Extensions
  3935. The native API exported by the interpreter in S60 environment consists of class CSPyInterpreter,
  3936. Python/C API (see [3]) and and a small set of extensions to Python/C API.
  3937. 9.1.1 class CSPyInterpreter
  3938. The class CSPyInterpreter offers an interface for initializing the interpreter and for running scripts. It
  3939. exports the following public interface:
  3940. static CSPyInterpreter*
  3941. NewInterpreterL(TBool aCloseStdlib = ETrue,
  3942. void(*aStdioInitFunc)(void*) = NULL,
  3943. void* aStdioInitCookie = NULL);
  3944. TInt RunScript(int argc, char** argv);
  3945. void PrintError();
  3946. void (*iStdI)(char* buf, int n);
  3947. void (*iStdO)(const char* buf, int n);
  3948. The caller of the constructor CSPyInterpreter::NewInterpreterL() may provide its own function
  3949. aStdioInitFunc for initializing Symbian OS STDLIB’s standard I/O descriptors. It gets called with the
  3950. argument aStdioInitCookie. The CSPyInterpreter class can also be requested to leave STDLIB open
  3951. at its destruction.
  3952. The RunScript method establishes a Python interpreter context and runs the script file whose full path
  3953. name is in argv[0] with the given argument vector. After completion, it leaves the interpreter context
  3954. and returns a Symbian error code to indicate success or failure.
  3955. The CSPyInterpreter::PrintError method can be used to print current Python exception information
  3956. to the standard error output.
  3957. 9.1.2 Extensions to Python/C API
  3958. Defined in symbian python ext util.h
  3959. PyObject* SPyErr SetFromSymbianOSErr(int error)
  3960. Sets Python exception of type PyExc SymbianError with the value field set to symbolic name of
  3961. the Symbian OS enumeration value error and returns NULL. In case error has the special value
  3962. KErrPython, it assumes that a Python exception has already been set and returns NULL.
  3963. The following functions can be used for storing the global data in a module implementa-
  3964. tion. They are thin wrappers around PyDict SetItem, PyDict SetItemString, PyDict GetItem,
  3965. PyDict GetItemString, PyDict DelItem and PyDict DelItemString, respectively, and can be used
  3966. in the same way. The data is stored in a special completely global dictionary shared by all modules and
  3967. threads in the current interpreter.
  3968. 83
  3969. Page 90
  3970. int SPyAddGlobal(PyObject *key, PyObject *value)
  3971. int SPyAddGlobalString(char *key, PyObject *value)
  3972. PyObject* SPyGetGlobal(PyObject *key)
  3973. PyObject* SPyGetGlobalString(char *key)
  3974. void SPyRemoveGlobal(PyObject *key)
  3975. void SPyRemoveGlobalString(char *key)
  3976. Defined in python globals.h
  3977. PyThreadState* PYTHON TLS->thread state
  3978. Current thread state.
  3979. Thread state and interpreter lock management must be performed according to the instructions; see
  3980. [3]. Python for S60 Platform extends the Python/C API by offering a facility for querying the related
  3981. Python thread state (PYTHON TLS->thread state) from the context of the currently running thread.
  3982. This can be used to re-establish the interpreter context with PyEval RestoreThread in C/C++ code.
  3983. To save/restore the interpreter context:
  3984. Py_BEGIN_ALLOW_THREADS
  3985. /* ...your code... */
  3986. Py_END_ALLOW_THREADS
  3987. To restore/save the interpreter context:
  3988. PyEval_RestoreThread(PYTHON_TLS-$>$thread_state)
  3989. /* ...your code... */
  3990. PyEval_SaveThread()
  3991. Defined in pythread.h
  3992. int PyThread AtExit(void(*)())
  3993. An extenstion to the standard thread module’s C API that can be used for registering thread-
  3994. specific exit functions. In the main thread calling this function has the same effect as calling
  3995. Py AtExit. For more information, see [1].
  3996. 9.2 Extending Python for S60
  3997. The general rules and guidelines for writing Python extensions apply in the S60 Python environment as
  3998. well; for more information, see [2]. The Python/C API is available, see [3] In addition, for an example
  3999. on porting a simple extension to S60, see [6].
  4000. The issues that need to be considered in the implementation of the extension modules include:
  4001. • Preparation of the data structures that make the C/C++ coded extensions visible to the Python
  4002. interpreter and make it possible to perform calls from Python to C/C++ code
  4003. • Conversions between C/C++ representations of the Python objects and object types used in the
  4004. extension code
  4005. • Maintenance of the reference counts of the C/C++ representations of the Python objects
  4006. • Passing of exceptions between C/C++ code and Python
  4007. • Management of interpreter’s thread state and the interpreter lock
  4008. 84
  4009. Chapter 9. Extending and Embedding
  4010. Page 91
  4011. In addition to the concerns common for all Python C extensions, the following principles should be
  4012. considered when implementing new Python interfaces in the S60 environment:
  4013. • Maximize the usage of Python’s built-in types at the interfaces.
  4014. • Related to the above: design interfaces in such a way that information can be passed between them
  4015. with minimal conversions.
  4016. • Convert Symbian operating system exceptions / errors to Python exceptions.
  4017. • Unicode strings are used at the interfaces to represent text that gets shown on the GUI. They can
  4018. be passed to and from Symbian operating system without conversions.
  4019. • While performing potentially long-lasting / blocking calls from an extension implementation to
  4020. services outside the interpreter, the interpreter lock must be released and then re-acquired after
  4021. the call.
  4022. • Rather than always implementing a thin wrapper on top of a Symbian OS facility, consider the
  4023. actual task for which the script writer needs the particular interface. For example, if the task
  4024. involves interaction with the users using the GUI, the script writer’s interest may well be limited
  4025. to performing the interaction / information exchange in a way that is compatible with the UI style
  4026. rather than having full control of the low-level details of the GUI implementation.
  4027. • The C/C++ implementation of a Python interface should be optimized for performance and cov-
  4028. ering access to the necessary features of the underlying Platform. Where necessary, the Python
  4029. programming interface can be further refined by wrapper modules written in Python.
  4030. An extension module is packaged in its own dynamically loadable library that must be installed into
  4031. \system\libs’ directory and named ‘module name.pyd’. The module initialization function must be ex-
  4032. ported at ordinal 1. The module identification is based on the filename only. As a special feature of
  4033. PyS60, an optional module finalizer function may be exported at ordinal 2.
  4034. The macro versions of memory-management functions PyMem MALLOC and PyObject NEW are not in-
  4035. cluded. Use the functions PyMem Malloc and PyObject New instead.
  4036. 9.2.1 Services for Extensions
  4037. S60 Python Platform implements an adaptation layer between S60 UI application framework and script
  4038. language UI extensions to simplify UI extension development. This API is used by the implementation of
  4039. the appuifw module but not exported in the current release. Some general utility services for extensions
  4040. are also provided, see Chapter 9.1.
  4041. 9.2.2 Example
  4042. This extension code snippet demonstrates some of the issues mentioned in this chapter, such as:
  4043. • Conversion from Python data types, usage of built-in data types at extension interface, usage of
  4044. Unicode strings (lines 8-12)
  4045. • Maintenance of the reference counts (line 36)
  4046. • Passing of exceptions between C/C++ code and Python (line 34)
  4047. • Releasing the interpreter lock while performing a blocking call to a service outside the interpreter
  4048. (lines 29, 31)
  4049. • Simplifying the API to the note facility of the Platform
  4050. 9.2. Extending Python for S60
  4051. 85
  4052. Page 92
  4053. 01 extern "C" PyObject *
  4054. 02 note(PyObject* /*self*/, PyObject *args)
  4055. 03 {
  4056. 04
  4057. TInt error = KErrNone;
  4058. 05
  4059. int l_tx, l_ty;
  4060. 06
  4061. char *b_tx, *b_ty;
  4062. 07
  4063. 08
  4064. if (!PyArg_ParseTuple(args, "u#s#", &b_tx, &l_tx, &b_ty, &l_ty))
  4065. 09
  4066. return NULL;
  4067. 10
  4068. 11
  4069. TPtrC8 stype((TUint8*)b_ty, l_ty);
  4070. 12
  4071. TPtrC note_text((TUint16 *)b_tx, l_tx);
  4072. 13
  4073. CAknResourceNoteDialog* dlg = NULL;
  4074. 14
  4075. 15
  4076. if (stype.Compare(KErrorNoteType) == 0)
  4077. 16
  4078. dlg = new CAknErrorNote(ETrue);
  4079. 17
  4080. else if (stype.Compare(KInfoNoteType) == 0)
  4081. 18
  4082. dlg = new CAknInformationNote(ETrue);
  4083. 19
  4084. else if (stype.Compare(KConfNoteType) == 0)
  4085. 20
  4086. dlg = new CAknConfirmationNote(ETrue);
  4087. 21
  4088. else {
  4089. 22
  4090. PyErr_BadArgument();
  4091. 23
  4092. return NULL;
  4093. 24
  4094. }
  4095. 25
  4096. 26
  4097. if (dlg == NULL)
  4098. 27
  4099. return PyErr_NoMemory();
  4100. 28
  4101. 29
  4102. Py_BEGIN_ALLOW_THREADS
  4103. 30
  4104. TRAP(error, dlg->ExecuteLD(note_text));
  4105. 31
  4106. Py_END_ALLOW_THREADS
  4107. 32
  4108. 33
  4109. if (error != KErrNone)
  4110. 34
  4111. return SPyErr_SetFromSymbianOSErr(error);
  4112. 35
  4113. else {
  4114. 36
  4115. Py_INCREF(Py_None);
  4116. 37
  4117. return Py_None;
  4118. 38
  4119. }
  4120. 39 }
  4121. 86
  4122. Chapter 9. Extending and Embedding
  4123. Page 93
  4124. CHAPTER
  4125. TEN
  4126. Terms and Abbreviations
  4127. The following list defines the terms and abbreviations used in this document:
  4128. Term
  4129. Definition
  4130. AAC; Adaptive
  4131. Audio Coding
  4132. AAC provides basically the same sound quality as MP3 while using a
  4133. smaller bit rate. AAC is mainly used to compress music.
  4134. Advertise
  4135. Advertise service in Bluetooth makes it known that a certain Bluetooth
  4136. service is available.
  4137. AMR
  4138. Adaptive Multi-rate Codec file format.
  4139. API
  4140. Application Programming Interface
  4141. Bluetooth
  4142. Bluetooth is a technology for wireless communication between devices that
  4143. is based on a low-cost short-range radio link.
  4144. BPP
  4145. Bits Per Pixel
  4146. C STDLIB
  4147. Symbian OS’s implementation of the C standard library
  4148. Dialog
  4149. A temporary user interface window for presenting context-specific informa-
  4150. tion to the user, or prompting for information in a specific context.
  4151. Discovery
  4152. Discovery is a process where Bluetooth finds other nearby Bluetooth devices
  4153. and their advertised services.
  4154. DLL
  4155. Dynamic link library
  4156. GSM;
  4157. Global
  4158. System
  4159. for
  4160. Mobile commu-
  4161. nication
  4162. GSM is a digital mobile telephone system that uses a variation of time
  4163. division multiple access. It digitizes and compresses data, then sends it
  4164. down a channel with two other streams of user data, each in its own time
  4165. slot.
  4166. GUI
  4167. Graphical User Interface
  4168. I/O
  4169. input/output
  4170. IP
  4171. Internet Protocol
  4172. MBM;
  4173. Multi-
  4174. BitMap
  4175. The native Symbian OS format used for pictures. MBM files can be gener-
  4176. ated with the bmconv.exe tool included in the S60 SDK.
  4177. MIDI;
  4178. Musi-
  4179. cal Instrument
  4180. Digital Interface
  4181. A protocol and a set of commands for storing and transmitting information
  4182. about music.
  4183. MIF;
  4184. Multi-
  4185. Image File
  4186. MIF files are similar to MBM files and can contain compressed SVG-T files.
  4187. This file type can be generated with the MifConv.exe tool.
  4188. MIME; Multi-
  4189. purpose Internet
  4190. Mail Extensions
  4191. MIME is an extension of the original Internet e-mail protocol that can be
  4192. used to exchange different kinds of data files on the Internet.
  4193. MP3
  4194. A standard technology and format for compressing a sound sequence into
  4195. a very small file while preserving the original level of sound quality when
  4196. it is played.
  4197. OS
  4198. Operating System
  4199. Real Audio
  4200. An audio format developed by Real Networks.
  4201. RDBMS
  4202. Relational database management system
  4203. SMS;
  4204. Short
  4205. Message System
  4206. (within GSM)
  4207. SMS is a service for sending messages of up to 160 characters, or 224 charac-
  4208. ters if using a 5-bit mode, to mobile phones that use GSM communication.
  4209. 87
  4210. Page 94
  4211. Term
  4212. Definition
  4213. Softkey
  4214. Softkey is a key that does not have a fixed function nor a function label
  4215. printed on it. On a phone, selection keys reside below or above on the
  4216. side of the screen, and derive their meaning from what is presently on the
  4217. screen.
  4218. SQL
  4219. Structured Query Language
  4220. SVG,
  4221. SVG-T;
  4222. Scalable
  4223. Vec-
  4224. tor
  4225. Graphics
  4226. (-Tiny)
  4227. XML-based vector graphics format for describing two-dimensional graphics
  4228. and graphical applications.
  4229. Twip
  4230. Twips are screen-independent units to ensure that the proportion of screen
  4231. elements are the same on all display systems. A twip is defined as 1/1440
  4232. of an inch, or 1/567 of a centimeter.
  4233. UI
  4234. User Interface
  4235. UI control
  4236. UI control is a GUI component that enables user interaction and represents
  4237. properties or operations of an object.
  4238. WAV
  4239. A file format for recording sound, especially in multimedia applications.
  4240. 88
  4241. Chapter 10. Terms and Abbreviations
  4242. Page 95
  4243. BIBLIOGRAPHY
  4244. [1] G. van Rossum, and F.L. Drake, Jr., editor. [Python] Library Reference. Available at
  4245. http://www.python.org/doc
  4246. [2] G. van Rossum, and F.L. Drake, Jr., editor. Extending and Embedding [the Python Interpreter].
  4247. Available at http://www.python.org/doc
  4248. [3] G. van Rossum, and F.L. Drake, Jr., editor. Python/C API [Reference Manual]. Available at
  4249. http://www.python.org/doc
  4250. [4] S60 SDK documentation, available at http://www.forum.nokia.com/
  4251. [5] Getting Started with Python for S60 Platform, available at http://www.forum.nokia.com/
  4252. [6] Programming with Python for S60 Platform, available at http://www.forum.nokia.com/
  4253. [7] Audio &
  4254. Video section
  4255. on
  4256. the
  4257. Forum
  4258. Nokia
  4259. Web
  4260. site (for Nokia devices),
  4261. http://www.forum.nokia.com/audiovideo
  4262. [8] Developers section on the S60 Platform Web site (for all S60 devices), http://www.s60.com/
  4263. [9] Python for S60 developer discussion board http://discussion.forum.nokia.com/
  4264. [10] Scalable Vector Graphics (SVG) 1.1 Specification http://www.w3.org/TR/SVG/
  4265. 89
  4266. Page 96
  4267. 90
  4268. Page 97
  4269. APPENDIX
  4270. A
  4271. Reporting Bugs
  4272. In order to improve the quality of Python for S60 the developers would like to know of any deficiencies
  4273. you find in Python for S60 or its documentation.
  4274. Before submitting a report, you will be required to log into SourceForge; this will make it possible for
  4275. the developers to contact you for additional information if needed. It is not possible to submit a bug
  4276. report anonymously.
  4277. All bug reports should be submitted via the project PyS60 Bug Tracker on SourceForge
  4278. (http://sourceforge.net/tracker/?group id=154155). The bug tracker offers a Web form which allows per-
  4279. tinent information to be entered and submitted to the developers.
  4280. The first step in filing a report is to determine whether the problem has already been reported. The
  4281. advantage in doing so, aside from saving the developers time, is that you learn what has been done to
  4282. fix it; it may be that the problem has already been fixed for the next release, or additional information
  4283. is needed (in which case you are welcome to provide it if you can!). To do this, search the bug database
  4284. using the search box near the bottom of the page.
  4285. If the problem you’re reporting is not already in the bug tracker, go back to the project PyS60 Bug
  4286. Tracker (http://sourceforge.net/tracker/?group id=154155). Select the “Submit a Bug” link at the top of
  4287. the page to open the bug reporting form.
  4288. The submission form has a number of fields. The only fields that are required are the “Summary” and
  4289. “Details” fields. For the summary, enter a very short description of the problem; less than ten words is
  4290. good. In the Details field, describe the problem in detail, including what you expected to happen and
  4291. what did happen. Be sure to include the version of Python for S60 you used, whether any extension
  4292. modules were involved and what hardware (the S60 device model or emulator) you were using, including
  4293. version information of the S60 SDK and your device firmware version as appropriate. You can see the
  4294. device firmware version by entering *#0000# on the device keypad - please include all information that
  4295. is shown by this code.
  4296. The only other field that you may want to set is the “Category” field, which allows you to place the bug
  4297. report into a broad category (such as “Documentation” or “Library”).
  4298. Each bug report will be assigned to a developer who will determine what needs to be done to correct the
  4299. problem. You will receive an update each time action is taken on the bug.
  4300. See Also:
  4301. How to Report Bugs Effectively
  4302. (http://www-mice.cs.ucl.ac.uk/multimedia/software/documentation/ReportingBugs.html)
  4303. Article which goes into some detail about how to create a useful bug report. This describes what
  4304. kind of information is useful and why it is useful.
  4305. Bug Writing Guidelines
  4306. (http://www.mozilla.org/quality/bug-writing-guidelines.html)
  4307. Information about writing a good bug report. Some of this is specific to the Mozilla project, but
  4308. describes general good practices.
  4309. 91
  4310. Page 98
  4311. 92
  4312. Page 99
  4313. MODULE INDEX
  4314. appuifw, 13
  4315. audio, 49
  4316. calendar, 64, 69
  4317. camera, 33
  4318. contacts, 59
  4319. e32, 9
  4320. e32db, 74
  4321. e32dbm, 77
  4322. glcanvas, 45
  4323. gles, 38
  4324. graphics, 27
  4325. inbox, 53
  4326. keycapture, 36
  4327. location, 54
  4328. messaging, 52
  4329. positioning, 55
  4330. sensor, 46
  4331. socket, 81
  4332. sysinfo, 11
  4333. telephone, 51
  4334. thread, 81
  4335. topwindow, 37
  4336. 93
  4337. Page 100
  4338. 94
  4339. Page 101
  4340. INDEX
  4341. del
  4342. () (EventFilter method), 48
  4343. delitem
  4344. () (CalendarDb method), 65, 71
  4345. delitem
  4346. () (ContactDb method), 60
  4347. delitem
  4348. () (Contact method), 62
  4349. getitem
  4350. () (CalendarDb method), 65, 71
  4351. getitem
  4352. () (array method), 39
  4353. init
  4354. () (EventFilter method), 48
  4355. init
  4356. () (OrientationEventFilter method), 48
  4357. init
  4358. () (Sensor method), 47
  4359. len
  4360. () (array method), 39
  4361. setitem
  4362. () (array method), 39
  4363. access point() (in module socket), 82
  4364. access points() (in module socket), 82
  4365. activate tab() (Application method), 18
  4366. active profile() (in module sysinfo), 11
  4367. add() (Text method), 22
  4368. add anniversary() (CalendarDb method), 65, 70
  4369. add appointment() (CalendarDb method), 65, 70
  4370. add contact() (ContactDb method), 59
  4371. add event() (CalendarDb method), 65, 70
  4372. add field() (Contact method), 61
  4373. add group() (Groups method), 63
  4374. add image() (TopWindow method), 37
  4375. add reminder() (CalendarDb method), 70
  4376. add todo() (CalendarDb method), 65, 70
  4377. add todo list() (CalendarDb method), 65
  4378. address() (Inbox method), 53
  4379. AF BT (data in socket), 81
  4380. after() (Ao timer method), 11
  4381. alarm (Entry attribute), 67, 72
  4382. all keys (data in keycapture), 36
  4383. AnniversaryEntry (class in calendar), 67, 72
  4384. answer() (in module telephone), 51
  4385. ao callgate() (in module e32), 9
  4386. Ao lock (class in e32), 10
  4387. ao sleep() (in module e32), 9
  4388. Ao timer (class in e32), 11
  4389. ao waittid() (in module thread), 81
  4390. ao yield() (in module e32), 9
  4391. Application (class in appuifw), 16
  4392. AppointmentEntry (class in calendar), 67, 72
  4393. appuifw (standard module), 13
  4394. arc() ( method), 33
  4395. array (class in gles), 39
  4396. as vcalendar() (Entry method), 67, 72
  4397. as vcard() (Contact method), 61
  4398. audio (extension module), 49
  4399. AUTH (data in socket), 81
  4400. AUTHOR (data in socket), 81
  4401. available fonts() (in module appuifw), 15
  4402. background color (TopWindow attribute), 38
  4403. battery() (in module sysinfo), 11
  4404. begin()
  4405. Contact method, 60
  4406. Dbms method, 75
  4407. bind()
  4408. GLCanvas method, 46
  4409. Inbox method, 54
  4410. Listbox method, 24
  4411. Text method, 22
  4412. blit() ( method), 33
  4413. body (Application attribute), 16
  4414. bt advertise service() (in module socket), 81
  4415. bt discover() (in module socket), 81
  4416. bt obex discover() (in module socket), 81
  4417. bt obex receive() (in module socket), 81
  4418. bt obex send file() (in module socket), 81
  4419. bt rfcomm get available server channel()
  4420. (in module socket), 81
  4421. BTPROTO RFCOMM (data in socket), 81
  4422. calendar (extension module), 64, 69
  4423. CalendarDb (class in calendar), 65, 70
  4424. call state() (in module telephone), 51
  4425. callback (EventFilter attribute), 48
  4426. camera (extension module), 33
  4427. cameras available() (in module camera), 34
  4428. cancel() (Ao timer method), 11
  4429. Canvas (class in appuifw), 25
  4430. cleanup()
  4431. EventFilter method, 48
  4432. OrientationEventFilter method, 48
  4433. clear()
  4434. method, 33
  4435. Text method, 22
  4436. close()
  4437. Dbms method, 75
  4438. e32dbm method, 78
  4439. Sound method, 50
  4440. col() (Db view method), 75
  4441. 95
  4442. Page 102
  4443. col count() (Db view method), 75
  4444. col length() (Db view method), 75
  4445. col raw() (Db view method), 75
  4446. col rawtime() (Db view method), 75
  4447. col type() (Db view method), 75
  4448. color (Text attribute), 21
  4449. commit()
  4450. Contact method, 60
  4451. Dbms method, 75
  4452. Entry method, 66, 71
  4453. compact()
  4454. CalendarDb method, 66
  4455. ContactDb method, 60
  4456. Dbms method, 75
  4457. compact required() (ContactDb method), 60
  4458. connect() (Sensor method), 47
  4459. connected() (Sensor method), 48
  4460. Contact (class in contacts), 60
  4461. ContactDb (class in contacts), 59
  4462. ContactField (class in contacts), 63
  4463. contacts (extension module), 59
  4464. content() (Inbox method), 53
  4465. content (Entry attribute), 66, 71
  4466. Content handler (class in appuifw), 24
  4467. corner type (TopWindow attribute), 38
  4468. count line() (Db view method), 76
  4469. create() (Dbms method), 75
  4470. cross out time (TodoEntry attribute), 67, 73
  4471. crossed out (Entry attribute), 67, 72
  4472. current() (Listbox method), 24
  4473. current position() (Sound method), 51
  4474. current volume() (Sound method), 50
  4475. daily instances() (CalendarDb method), 65, 71
  4476. Db view (class in e32db), 75
  4477. Dbms (class in e32db), 75
  4478. default list (TodoListDict attribute), 68
  4479. default module() (in module positioning), 55
  4480. delete()
  4481. Inbox method, 54
  4482. Text method, 22
  4483. dial() (in module telephone), 51
  4484. disconnect() (Sensor method), 47
  4485. display pixels() (in module sysinfo), 11
  4486. display twips() (in module sysinfo), 11
  4487. drawNow() (GLCanvas method), 46
  4488. drive list() (in module e32), 9
  4489. duration() (Sound method), 50
  4490. e32 (extension module), 9
  4491. e32db (extension module), 74
  4492. e32dbm (module), 77
  4493. EAColumn (data in appuifw), 19
  4494. EApplicationWindow (data in appuifw), 18
  4495. EBatteryPane (data in appuifw), 19
  4496. EBColumn (data in appuifw), 19
  4497. ECColumn (data in appuifw), 19
  4498. EContextPane (data in appuifw), 18
  4499. EControlPane (data in appuifw), 18
  4500. EControlPaneBottom (data in appuifw), 19
  4501. EControlPaneTop (data in appuifw), 19
  4502. ECreated (data in messaging), 52
  4503. EDColumn (data in appuifw), 19
  4504. EDeleted (data in messaging), 52
  4505. EDraft (data in inbox), 53
  4506. EFatalServerError (data in messaging), 52
  4507. EFindPane (data in appuifw), 19
  4508. EHCenterVBottom (data in appuifw), 27
  4509. EHCenterVCenter (data in appuifw), 27
  4510. EHCenterVTop (data in appuifw), 27
  4511. EHLeftVBottom (data in appuifw), 27
  4512. EHLeftVCenter (data in appuifw), 27
  4513. EHLeftVTop (data in appuifw), 27
  4514. EHRightVBottom (data in appuifw), 27
  4515. EHRightVCenter (data in appuifw), 27
  4516. EHRightVTop (data in appuifw), 27
  4517. EInbox (data in inbox), 53
  4518. EIndicatorPane (data in appuifw), 19
  4519. ellipse() ( method), 32
  4520. EMainPane (data in appuifw), 18
  4521. EMovedToOutBox (data in messaging), 52
  4522. ENaviPane (data in appuifw), 19
  4523. ENCRYPT (data in socket), 81
  4524. end time (Entry attribute), 66, 72
  4525. ENoServiceCentre (data in messaging), 52
  4526. ENotReady (data in audio), 49
  4527. Entry (class in calendar), 66, 71
  4528. EOpen (data in audio), 49
  4529. EOpenComplete (data in camera), 34
  4530. EOutbox (data in inbox), 53
  4531. EPlaying (data in audio), 49
  4532. EPrepareComplete (data in camera), 34
  4533. ERecordComplete (data in camera), 34
  4534. ERecording (data in audio), 49
  4535. EScheduledForSend (data in messaging), 52
  4536. EScheduleFailed (data in messaging), 52
  4537. EScreen (data in appuifw), 18
  4538. ESendFailed (data in messaging), 52
  4539. ESent
  4540. data in inbox, 53
  4541. data in messaging, 52
  4542. ESignalPane (data in appuifw), 18
  4543. EStaconBottom (data in appuifw), 19
  4544. EStaconTop (data in appuifw), 19
  4545. EStatusAnswering (data in telephone), 51
  4546. EStatusConnected (data in telephone), 51
  4547. EStatusConnecting (data in telephone), 51
  4548. EStatusDialling (data in telephone), 51
  4549. EStatusDisconnecting (data in telephone), 52
  4550. EStatusHold (data in telephone), 52
  4551. EStatusIdle (data in telephone), 51
  4552. EStatusPane (data in appuifw), 18
  4553. EStatusPaneBottom (data in appuifw), 19
  4554. EStatusPaneTop (data in appuifw), 19
  4555. EStatusReconnectPending (data in telephone), 51
  4556. EStatusRinging (data in telephone), 51
  4557. EStatusTransferAlerting (data in telephone), 52
  4558. 96
  4559. Index
  4560. Page 103
  4561. EStatusTransferring (data in telephone), 52
  4562. EStatusUnknown (data in telephone), 51
  4563. ETitlePane (data in appuifw), 18
  4564. EUniversalIndicatorPane (data in appuifw), 19
  4565. event()
  4566. EventFilter method, 48
  4567. OrientationEventFilter method, 48
  4568. EventEntry (class in calendar), 67, 72
  4569. EventFilter (class in sensor), 48
  4570. EWallpaperPane (data in appuifw), 19
  4571. execute()
  4572. Dbms method, 75
  4573. Form method, 20
  4574. exit key handler (Application attribute), 17
  4575. export vcalendars() (CalendarDb method), 65,
  4576. 71
  4577. export vcards() (ContactDb method), 60
  4578. exposure modes() (in module camera), 34
  4579. FFormAutoFormEdit (data in appuifw), 20
  4580. FFormAutoLabelEdit (data in appuifw), 20
  4581. FFormDoubleSpaced (data in appuifw), 20
  4582. FFormEditModeOnly (data in appuifw), 20
  4583. FFormViewModeOnly (data in appuifw), 20
  4584. field types() (ContactDb method), 60
  4585. file copy() (in module e32), 9
  4586. find()
  4587. Contact method, 62
  4588. ContactDb method, 60
  4589. find instances() (CalendarDb method), 65, 70
  4590. first line() (Db view method), 76
  4591. flags (Form attribute), 20
  4592. flash modes() (in module camera), 34
  4593. focus
  4594. Application attribute, 17
  4595. Text attribute, 21
  4596. font (Text attribute), 21
  4597. Form (class in appuifw), 19
  4598. format rawtime() (in module e32db), 74
  4599. format time() (in module e32db), 74
  4600. forwarding (KeyCapturer attribute), 37
  4601. free drivespace() (in module sysinfo), 11
  4602. free ram() (in module sysinfo), 12
  4603. full name() (Application method), 18
  4604. get() (Text method), 23
  4605. get line() (Db view method), 76
  4606. get pos() (Text method), 22
  4607. get repeat() (Entry method), 66, 71
  4608. glBufferData() (in module gles), 43
  4609. glBufferDatab() (in module gles), 43
  4610. glBufferDataf() (in module gles), 43
  4611. glBufferDatas() (in module gles), 43
  4612. glBufferDataub() (in module gles), 43
  4613. glBufferDataus() (in module gles), 43
  4614. glBufferDatax() (in module gles), 43
  4615. glBufferSubData() (in module gles), 43
  4616. glBufferSubDatab() (in module gles), 43
  4617. glBufferSubDataf() (in module gles), 43
  4618. glBufferSubDatas() (in module gles), 43
  4619. glBufferSubDataub() (in module gles), 43
  4620. glBufferSubDataus() (in module gles), 43
  4621. glBufferSubDatax() (in module gles), 43
  4622. GLCanvas (class in glcanvas), 46
  4623. glcanvas (extension module), 45
  4624. glClipPlanef() (in module gles), 43
  4625. glClipPlanex() (in module gles), 43
  4626. glColorPointer() (in module gles), 40
  4627. glColorPointerf() (in module gles), 40
  4628. glColorPointerub() (in module gles), 40
  4629. glColorPointerx() (in module gles), 40
  4630. glCompressedTexImage2D() (in module gles), 40
  4631. glCompressedTexSubImage2D() (in module gles),
  4632. 40
  4633. glDeleteBuffers() (in module gles), 44
  4634. glDeleteTextures() (in module gles), 40
  4635. glDrawElements() (in module gles), 40
  4636. glDrawElementsub() (in module gles), 40
  4637. glDrawElementsus() (in module gles), 40
  4638. glDrawTexfvOES() (in module gles), 44
  4639. glDrawTexivOES() (in module gles), 44
  4640. glDrawTexsvOES() (in module gles), 44
  4641. gles (extension module), 38
  4642. glFogv() (in module gles), 40
  4643. glFogxv() (in module gles), 40
  4644. glGenBuffers() (in module gles), 44
  4645. glGenTextures() (in module gles), 40
  4646. glGetBooleanv() (in module gles), 44
  4647. glGetBufferParameteriv() (in module gles), 44
  4648. glGetClipPlanef() (in module gles), 44
  4649. glGetFixedv() (in module gles), 44
  4650. glGetFloatv() (in module gles), 44
  4651. glGetIntegerv() (in module gles), 40
  4652. glGetLightfv() (in module gles), 44
  4653. glGetLightxv() (in module gles), 44
  4654. glGetMaterialfv() (in module gles), 44
  4655. glGetMaterialxv() (in module gles), 44
  4656. glGetString() (in module gles), 40
  4657. glGetTexEnvf() (in module gles), 44
  4658. glGetTexEnvx() (in module gles), 44
  4659. glGetTexParameterf() (in module gles), 44
  4660. glGetTexParameterx() (in module gles), 44
  4661. glLightfv() (in module gles), 41
  4662. glLightModelfv() (in module gles), 40
  4663. glLightModelxv() (in module gles), 40
  4664. glLightxv() (in module gles), 41
  4665. glLoadMatrixf() (in module gles), 41
  4666. glLoadMatrixx() (in module gles), 41
  4667. glMaterialfv() (in module gles), 41
  4668. glMaterialxv() (in module gles), 41
  4669. glMatrixIndexPointerOES() (in module gles), 44
  4670. glMatrixIndexPointerOESub() (in module gles),
  4671. 44
  4672. glMultMatrixf() (in module gles), 41
  4673. glMultMatrixx() (in module gles), 41
  4674. glNormalPointer() (in module gles), 41
  4675. glNormalPointerb() (in module gles), 41
  4676. Index
  4677. 97
  4678. Page 104
  4679. glNormalPointerf() (in module gles), 41
  4680. glNormalPointers() (in module gles), 41
  4681. glNormalPointerx() (in module gles), 41
  4682. glPointParameterfv() (in module gles), 45
  4683. glPointParameterxv() (in module gles), 45
  4684. glPointSizePointerOES() (in module gles), 45
  4685. glPointSizePointerOESf() (in module gles), 45
  4686. glPointSizePointerOESx() (in module gles), 45
  4687. glReadPixels() (in module gles), 41
  4688. glTexCoordPointer() (in module gles), 41
  4689. glTexCoordPointerb() (in module gles), 41
  4690. glTexCoordPointerf() (in module gles), 42
  4691. glTexCoordPointers() (in module gles), 41
  4692. glTexCoordPointerx() (in module gles), 42
  4693. glTexEnvfv() (in module gles), 42
  4694. glTexEnvxv() (in module gles), 42
  4695. glTexImage2D() (in module gles), 42
  4696. glTexSubImage2D() (in module gles), 42
  4697. glVertexPointer() (in module gles), 42
  4698. glVertexPointerb() (in module gles), 42
  4699. glVertexPointerf() (in module gles), 42
  4700. glVertexPointers() (in module gles), 42
  4701. glVertexPointerx() (in module gles), 42
  4702. glWeightPointerOES() (in module gles), 45
  4703. glWeightPointerOESf() (in module gles), 45
  4704. glWeightPointerOESx() (in module gles), 45
  4705. graphics (extension module), 27
  4706. Group (class in contacts), 63
  4707. Groups (class in contacts), 63
  4708. groups (ContactDb attribute), 60
  4709. gsm location() (in module location), 54
  4710. hang up() (in module telephone), 51
  4711. hide()
  4712. InfoPopup method, 27
  4713. TopWindow method, 37
  4714. highlight color (Text attribute), 21
  4715. HIGHLIGHT ROUNDED (data in appuifw), 22
  4716. HIGHLIGHT SHADOW (data in appuifw), 22
  4717. HIGHLIGHT STANDARD (data in appuifw), 22
  4718. Icon (class in appuifw), 24
  4719. id
  4720. Contact attribute, 60
  4721. Entry attribute, 66, 72
  4722. Group attribute, 63
  4723. TodoList attribute, 68
  4724. Image.inspect() (in module graphics), 28
  4725. Image.new() (in module graphics), 28
  4726. Image.open() (in module graphics), 28
  4727. image modes() (in module camera), 34
  4728. image sizes() (in module camera), 34
  4729. images (TopWindow attribute), 38
  4730. imei() (in module sysinfo), 11
  4731. import vcalendars() (CalendarDb method), 65,
  4732. 71
  4733. import vcards() (ContactDb method), 60
  4734. in emulator() (in module e32), 9
  4735. inactivity() (in module e32), 10
  4736. Inbox (class in inbox), 53
  4737. inbox (extension module), 53
  4738. incoming call() (in module telephone), 51
  4739. InfoPopup (class in appuifw), 27
  4740. insert() (Form method), 20
  4741. is col null() (Db view method), 76
  4742. is group (Contact attribute), 60
  4743. is ui thread() (in module e32), 10
  4744. keycapture (extension module), 36
  4745. keys() (ContactDb method), 60
  4746. keys (KeyCapturer attribute), 36
  4747. KMdaRepeatForever (data in audio), 49
  4748. label (ContactField attribute), 63
  4749. last key() (KeyCapturer method), 37
  4750. last modified (Entry attribute), 66, 72
  4751. layout() (Application method), 18
  4752. len() (Text method), 22
  4753. length() (Form method), 20
  4754. line() ( method), 32
  4755. Listbox (class in appuifw), 23
  4756. load() (Image method), 29
  4757. location
  4758. ContactField attribute, 63
  4759. Entry attribute, 66, 71
  4760. extension module, 54
  4761. makeCurrent() (GLCanvas method), 46
  4762. max ramdrive size() (in module sysinfo), 12
  4763. max volume() (Sound method), 50
  4764. max zoom() (in module camera), 34
  4765. maximum size (TopWindow attribute), 38
  4766. measure text() ( method), 33
  4767. menu
  4768. Application attribute, 17
  4769. Form attribute, 20
  4770. messaging (extension module), 52
  4771. mms send() (in module messaging), 52
  4772. module info() (in module positioning), 55
  4773. modules() (in module positioning), 55
  4774. monthly instances() (CalendarDb method), 65,
  4775. 70
  4776. multi query() (in module appuifw), 16
  4777. multi selection list() (in module appuifw),
  4778. 16
  4779. name
  4780. Group attribute, 63
  4781. TodoList attribute, 68
  4782. next line() (Db view method), 76
  4783. note() (in module appuifw), 16
  4784. OBEX (data in socket), 81
  4785. open()
  4786. Content handler method, 24
  4787. Dbms method, 75
  4788. in module calendar, 64, 70
  4789. in module contacts, 59
  4790. 98
  4791. Index
  4792. Page 105
  4793. in module e32dbm, 77
  4794. open standalone() (Content handler method),
  4795. 25
  4796. orientation (Application attribute), 18
  4797. orientation.BACK ( attribute), 47
  4798. orientation.BOTTOM ( attribute), 47
  4799. orientation.FRONT ( attribute), 47
  4800. orientation.LEFT ( attribute), 47
  4801. orientation.RIGHT ( attribute), 47
  4802. orientation.TOP ( attribute), 47
  4803. OrientationEventFilter (class in sensor), 48
  4804. originating (Entry attribute), 72
  4805. os version() (in module sysinfo), 12
  4806. pieslice() ( method), 32
  4807. play() (Sound method), 49
  4808. point() ( method), 33
  4809. polygon() ( method), 32
  4810. pop() (Form method), 20
  4811. popup menu() (in module appuifw), 16
  4812. position() (in module positioning), 55
  4813. position
  4814. Listbox attribute, 24
  4815. TopWindow attribute, 38
  4816. POSITION INTERVAL (data in positioning), 55
  4817. positioning (extension module), 55
  4818. prepare() (Db view method), 76
  4819. priority (Entry attribute), 67, 72
  4820. pys60 version (data in e32), 9
  4821. pys60 version info (data in e32), 9
  4822. PYTHON TLS->thread state, 84
  4823. PyThread AtExit(), 84
  4824. query() (in module appuifw), 15
  4825. record() (Sound method), 50
  4826. rectangle() ( method), 32
  4827. release() (in module camera), 36
  4828. ReminderEntry (class in calendar), 73
  4829. remove image() (TopWindow method), 37
  4830. reorganize() (e32dbm method), 78
  4831. replication (Entry attribute), 67, 72
  4832. reset inactivity() (in module e32), 10
  4833. resize() (Image method), 28
  4834. RFCOMM (data in socket), 81
  4835. ring type() (in module sysinfo), 12
  4836. rollback()
  4837. Contact method, 61
  4838. Dbms method, 75
  4839. Entry method, 66, 71
  4840. RotEventFilter (class in sensor), 48
  4841. s60 version info (data in e32), 10
  4842. save() (Image method), 29
  4843. save hook (Form attribute), 20
  4844. say() (in module audio), 49
  4845. schema (ContactField attribute), 63
  4846. screen (Application attribute), 17
  4847. screenshot() (in module graphics), 28
  4848. select access point() (in module socket), 82
  4849. select module() (in module positioning), 55
  4850. selection list() (in module appuifw), 16
  4851. Sensor (class in sensor), 47
  4852. sensor (extension module), 46
  4853. sensors() (in module sensor), 46
  4854. set() (Text method), 23
  4855. set default access point()
  4856. (in
  4857. module
  4858. socket), 82
  4859. set event filter() (Sensor method), 48
  4860. set exit() (Application method), 18
  4861. set home time() (in module e32), 9
  4862. set list() (Listbox method), 24
  4863. set pos() (Text method), 23
  4864. set position() (Sound method), 50
  4865. set repeat() (Entry method), 66, 71
  4866. set requestors() (in module positioning), 55
  4867. set security() (in module socket), 81
  4868. set tabs() (Application method), 18
  4869. set time() (Entry method), 66, 71
  4870. set volume() (Sound method), 50
  4871. shadow (TopWindow attribute), 38
  4872. show()
  4873. InfoPopup method, 27
  4874. TopWindow method, 37
  4875. signal() (Ao lock method), 11
  4876. signal bars() (in module sysinfo), 12
  4877. signal dbm() (in module sysinfo), 12
  4878. size
  4879. Canvas attribute, 26
  4880. Image attribute, 29
  4881. Listbox attribute, 24
  4882. TopWindow attribute, 38
  4883. sms messages() (Inbox method), 53
  4884. sms send() (in module messaging), 52
  4885. socket (extension module), 81
  4886. Sound (class in audio), 49
  4887. Sound.open() (in module audio), 49
  4888. SPyAddGlobal(), 84
  4889. SPyAddGlobalString(), 84
  4890. SPyErr SetFromSymbianOSErr(), 83
  4891. SPyGetGlobal(), 84
  4892. SPyGetGlobalString(), 84
  4893. SPyRemoveGlobal(), 84
  4894. SPyRemoveGlobalString(), 84
  4895. start() (KeyCapturer method), 37
  4896. start exe() (in module e32), 10
  4897. start finder() (in module camera), 35
  4898. start record() (in module camera), 36
  4899. start server() (in module e32), 10
  4900. start time (Entry attribute), 66, 72
  4901. state() (Sound method), 50
  4902. stop()
  4903. Image method, 29
  4904. KeyCapturer method, 37
  4905. Sound method, 50
  4906. stop finder() (in module camera), 36
  4907. stop position() (in module positioning), 55
  4908. Index
  4909. 99
  4910. Page 106
  4911. stop record() (in module camera), 36
  4912. style (Text attribute), 21
  4913. STYLE BOLD (data in appuifw), 22
  4914. STYLE ITALIC (data in appuifw), 22
  4915. STYLE STRIKETHROUGH (data in appuifw), 22
  4916. STYLE UNDERLINE (data in appuifw), 22
  4917. sw version() (in module sysinfo), 12
  4918. sync() (e32dbm method), 78
  4919. sysinfo (extension module), 11
  4920. take photo() (in module camera), 34
  4921. telephone (extension module), 51
  4922. text() ( method), 33
  4923. thread (extension module), 81
  4924. time() (Inbox method), 53
  4925. title
  4926. Application attribute, 17
  4927. Contact attribute, 60
  4928. todo list (TodoEntry attribute), 68
  4929. todo lists (CalendarDb attribute), 65
  4930. TodoEntry (class in calendar), 67, 73
  4931. TodoList (class in calendar), 68
  4932. TodoListDict (class in calendar), 68
  4933. TopWindow (class in topwindow), 37
  4934. topwindow (extension module), 37
  4935. total ram() (in module sysinfo), 12
  4936. total rom() (in module sysinfo), 12
  4937. transpose() (Image method), 29
  4938. type (ContactField attribute), 63
  4939. uid() (Application method), 18
  4940. unread() (Inbox method), 54
  4941. value (ContactField attribute), 63
  4942. visible (TopWindow attribute), 38
  4943. wait() (Ao lock method), 10
  4944. white balance modes() (in module camera), 34
  4945. 100
  4946. Index
Add Comment
Please, Sign In to add comment