1 /* xscreensaver, Copyright (c) 2012-2016 Jamie Zawinski <jwz@jwz.org>
3 * Permission to use, copy, modify, distribute, and sell this software and its
4 * documentation for any purpose is hereby granted without fee, provided that
5 * the above copyright notice appear in all copies and that both that
6 * copyright notice and this permission notice appear in supporting
7 * documentation. No representations are made about the suitability of this
8 * software for any purpose. It is provided "as is" without express or
11 * Loading URLs and returning the underlying text.
13 * This is necessary because iOS doesn't have Perl installed, so we can't
14 * run "xscreensaver-text" to do this.
19 #ifdef USE_IPHONE // whole file
21 #include "textclient.h"
24 textclient_mobile_date_string (void)
26 UIDevice *dd = [UIDevice currentDevice];
27 NSString *name = [dd name]; // My iPhone
28 NSString *model = [dd model]; // iPad
29 // NSString *system = [dd systemName]; // iPhone OS
30 NSString *vers = [dd systemVersion]; // 5.0
33 localizedStringFromDate:[NSDate date]
34 dateStyle: NSDateFormatterMediumStyle
35 timeStyle: NSDateFormatterMediumStyle];
38 NSString *result = name;
39 result = [result stringByAppendingString: nl];
40 result = [result stringByAppendingString: model];
41 // result = [result stringByAppendingString: nl];
42 // result = [result stringByAppendingString: system];
43 result = [result stringByAppendingString: @" "];
44 result = [result stringByAppendingString: vers];
45 result = [result stringByAppendingString: nl];
46 result = [result stringByAppendingString: nl];
47 result = [result stringByAppendingString: date];
48 result = [result stringByAppendingString: nl];
49 result = [result stringByAppendingString: nl];
50 return strdup ([result cStringUsingEncoding:NSISOLatin1StringEncoding]);
54 /* Returns the contents of the URL. */
56 textclient_mobile_url_string (Display *dpy, const char *url)
60 [NSString stringWithCString: url
61 encoding:NSISOLatin1StringEncoding]];
63 [NSString stringWithContentsOfURL: nsurl
64 encoding: NSUTF8StringEncoding
67 ? strdup ([body cStringUsingEncoding:NSUTF8StringEncoding])
71 #endif // USE_IPHONE -- whole file