Debian Codegraph @

plyer/platforms/ios/email.py

raw symbols SCIP
1 '''
2 Module of iOS API for plyer.email.
3 '''
4
5 try:
6 from urllib.parse import quote
7 except ImportError:
8 from urllib import quote
9
10 from plyer.facades import Email
11 from pyobjus import autoclass, objc_str
12 from pyobjus.dylib_manager import load_framework
13
14 load_framework('/System/Library/Frameworks/UIKit.framework')
15
16 NSURL = autoclass('NSURL')
17 NSString = autoclass('NSString')
18 UIApplication = autoclass('UIApplication')
19
20
21 class IOSEmail(Email):
22 '''
23 Implementation of iOS battery API.
24 '''
25
26 def _send(self, **kwargs):
27 recipient = kwargs.get('recipient')
28 subject = kwargs.get('subject')
29 text = kwargs.get('text')
30
31 uri = "mailto:"
32 if recipient:
33 uri += str(recipient)
34 if subject:
35 uri += "?" if "?" not in uri else "&"
36 uri += "subject="
37 uri += quote(str(subject))
38 if text:
39 uri += "?" if "?" not in uri else "&"
40 uri += "body="
41 uri += quote(str(text))
42
43 nsurl = NSURL.alloc().initWithString_(objc_str(uri))
44
45 UIApplication.sharedApplication().openURL_(nsurl)
46
47
48 def instance():
49 '''
50 Instance for facade proxy.
51 '''
52 return IOSEmail()