Skip to content

Latest commit

 

History

History
516 lines (438 loc) · 19.6 KB

gui_cocoa.m

File metadata and controls

516 lines (438 loc) · 19.6 KB
 
1
2
3
4
5
6
7
8
/**
* MojoSetup; a portable, flexible installation application.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
May 7, 2009
May 7, 2009
9
10
11
// !!! FIXME: needs to catch Apple-Q.
// !!! FIXME: cancel during progress is wanged.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#if !SUPPORT_GUI_COCOA
#error Something is wrong in the build system.
#endif
#import <Cocoa/Cocoa.h>
#undef true
#undef false
#define BUILDING_EXTERNAL_PLUGIN 1
#include "gui.h"
MOJOGUI_PLUGIN(cocoa)
#if !GUI_STATIC_LINK_COCOA
CREATE_MOJOGUI_ENTRY_POINT(cocoa)
#endif
typedef enum
{
CLICK_BACK=-1,
CLICK_CANCEL,
CLICK_NEXT,
CLICK_NONE
} ClickValue;
May 7, 2009
May 7, 2009
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// This nasty hack is because we appear to need to be under
// [NSApp run] when calling things like NSRunAlertPanel().
// So we push a custom event, call -[NSApp run], catch it, do
// the panel, then call -[NSApp stop]. Yuck.
typedef enum
{
CUSTOMEVENT_RUNQUEUE,
CUSTOMEVENT_MSGBOX,
CUSTOMEVENT_PROMPTYN,
CUSTOMEVENT_PROMPTYNAN,
CUSTOMEVENT_INSERTMEDIA,
} CustomEvent;
51
52
53
54
55
56
57
58
59
60
61
62
63
static NSAutoreleasePool *GAutoreleasePool = nil;
@interface MojoSetupController : NSView
{
IBOutlet NSButton *BackButton;
IBOutlet NSButton *CancelButton;
IBOutlet NSButton *NextButton;
IBOutlet NSWindow *MainWindow;
IBOutlet NSComboBox *DestinationCombo;
IBOutlet NSTextField *FinalText;
IBOutlet NSTextView *ReadmeText;
IBOutlet NSTabView *TabView;
IBOutlet NSTextField *TitleLabel;
May 7, 2009
May 7, 2009
64
65
66
IBOutlet NSTextField *ProgressComponentLabel;
IBOutlet NSTextField *ProgressItemLabel;
IBOutlet NSProgressIndicator *ProgressBar;
67
68
ClickValue clickValue;
boolean canForward;
May 7, 2009
May 7, 2009
69
MojoGuiYNAN answerYNAN;
May 7, 2009
May 7, 2009
71
- (void)awakeFromNib;
72
73
74
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
- (void)prepareWidgets:(const char*)winTitle;
- (void)unprepareWidgets;
May 7, 2009
May 7, 2009
75
76
77
78
79
80
81
- (void)fireCustomEvent:(CustomEvent)eventType data1:(NSInteger)data1 data2:(NSInteger)data2 atStart:(BOOL)atStart;
- (void)doCustomEvent:(NSEvent *)event;
- (void)doMsgBox:(const char *)title text:(const char *)text;
- (void)doPromptYN:(const char *)title text:(const char *)text;
- (void)doPromptYNAN:(const char *)title text:(const char *)text;
- (void)doInsertMedia:(const char *)medianame;
- (MojoGuiYNAN)getAnswerYNAN;
82
83
84
85
- (IBAction)backClicked:(NSButton *)sender;
- (IBAction)cancelClicked:(NSButton *)sender;
- (IBAction)nextClicked:(NSButton *)sender;
- (IBAction)browseClicked:(NSButton *)sender;
May 7, 2009
May 7, 2009
86
- (int)doPage:(NSString *)pageId title:(const char *)_title canBack:(boolean)canBack canFwd:(boolean)canFwd canCancel:(boolean)canCancel canFwdAtStart:(boolean)canFwdAtStart shouldBlock:(BOOL)shouldBlock;
87
88
89
90
91
92
93
94
95
- (int)doReadme:(const char *)title text:(NSString *)text canBack:(boolean)canBack canFwd:(boolean)canFwd;
- (int)doOptions:(MojoGuiSetupOptions *)opts canBack:(boolean)canBack canFwd:(boolean)canFwd;
- (char *)doDestination:(const char **)recommends recnum:(int)recnum command:(int *)command canBack:(boolean)canBack canFwd:(boolean)canFwd;
- (int)doProductKey:(const char *)desc fmt:(const char *)fmt buf:(char *)buf buflen:(const int)buflen canBack:(boolean)canBack canFwd:(boolean)canFwd;
- (int)doProgress:(const char *)type component:(const char *)component percent:(int)percent item:(const char *)item canCancel:(boolean)canCancel;
- (void)doFinal:(const char *)msg;
@end // interface MojoSetupController
@implementation MojoSetupController
May 7, 2009
May 7, 2009
96
97
98
99
100
101
102
- (void)awakeFromNib
{
clickValue = CLICK_NONE;
canForward = false;
answerYNAN = MOJOGUI_NO;
} // awakeFromNib
103
104
105
106
107
108
109
110
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
printf("didfinishlaunching\n");
[NSApp stop:self]; // break out of NSApp::run()
} // applicationDidFinishLaunching
- (void)prepareWidgets:(const char*)winTitle
{
May 7, 2009
May 7, 2009
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#if 1
[BackButton setTitle:[NSString stringWithUTF8String:_("Back")]];
[NextButton setTitle:[NSString stringWithUTF8String:_("Next")]];
[CancelButton setTitle:[NSString stringWithUTF8String:_("Cancel")]];
#else
// !!! FIXME: there's probably a better way to do this.
// Set the correct localization for the buttons, then resize them so
// the new text fits perfectly. After that, we need to reposition
// them so they don't look scattered.
NSRect frameBack = [BackButton frame];
NSRect frameNext = [NextButton frame];
NSRect frameCancel = [CancelButton frame];
const float startX = frameCancel.origin.x + frameCancel.size.width;
const float spacing = (frameBack.origin.x + frameBack.size.width) - frameNext.origin.x;
125
126
127
[BackButton setTitle:[NSString stringWithUTF8String:_("Back")]];
[NextButton setTitle:[NSString stringWithUTF8String:_("Next")]];
[CancelButton setTitle:[NSString stringWithUTF8String:_("Cancel")]];
May 7, 2009
May 7, 2009
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
[BackButton sizeToFit];
[NextButton sizeToFit];
[CancelButton sizeToFit];
frameBack = [BackButton frame];
frameNext = [NextButton frame];
frameCancel = [CancelButton frame];
frameCancel.origin.x = startX - frameCancel.size.width;
frameNext.origin.x = (frameCancel.origin.x - frameNext.size.width) - spacing;
frameBack.origin.x = (frameNext.origin.x - frameBack.size.width) - spacing;
[CancelButton setFrame:frameCancel];
[CancelButton setNeedsDisplay:YES];
[NextButton setFrame:frameNext];
[NextButton setNeedsDisplay:YES];
[BackButton setFrame:frameBack];
[BackButton setNeedsDisplay:YES];
#endif
[ProgressBar setUsesThreadedAnimation:YES]; // we don't pump fast enough.
[ProgressBar startAnimation:self];
147
148
149
150
151
152
153
154
155
156
[MainWindow setTitle:[NSString stringWithUTF8String:winTitle]];
[MainWindow center];
[MainWindow makeKeyAndOrderFront:self];
} // prepareWidgets
- (void)unprepareWidgets
{
[MainWindow orderOut:self];
} // unprepareWidgets
May 7, 2009
May 7, 2009
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
- (void)fireCustomEvent:(CustomEvent)eventType data1:(NSInteger)data1 data2:(NSInteger)data2 atStart:(BOOL)atStart
{
NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:(short)eventType data1:data1 data2:data2];
[NSApp postEvent:event atStart:atStart];
[NSApp run]; // event handler _must_ call -[NSApp stop], or you block here forever.
} // fireCustomEvent
- (void)doCustomEvent:(NSEvent*)event
{
printf("custom event!\n");
switch ((CustomEvent) [event subtype])
{
case CUSTOMEVENT_RUNQUEUE:
break; // we just need the -[NSApp stop] call.
case CUSTOMEVENT_MSGBOX:
[self doMsgBox:(const char *)[event data1] text:(const char *)[event data2]];
break;
case CUSTOMEVENT_PROMPTYN:
[self doPromptYN:(const char *)[event data1] text:(const char *)[event data2]];
break;
case CUSTOMEVENT_PROMPTYNAN:
[self doPromptYNAN:(const char *)[event data1] text:(const char *)[event data2]];
break;
case CUSTOMEVENT_INSERTMEDIA:
[self doInsertMedia:(const char *)[event data1]];
break;
default:
assert(false && "Cocoa: Unexpected custom event");
return; // let it go without breaking the event loop.
} // switch
[NSApp stop:self]; // break the event loop.
} // doCustomEvent
- (void)doMsgBox:(const char *)title text:(const char *)text
{
NSString *titlestr = [NSString stringWithUTF8String:title];
NSString *textstr = [NSString stringWithUTF8String:text];
NSString *okstr = [NSString stringWithUTF8String:_("OK")];
NSRunInformationalAlertPanel(titlestr, textstr, okstr, nil, nil);
} // doMsgBox
- (void)doPromptYN:(const char *)title text:(const char *)text
{
NSString *titlestr = [NSString stringWithUTF8String:title];
NSString *textstr = [NSString stringWithUTF8String:text];
NSString *yesstr = [NSString stringWithUTF8String:_("Yes")];
NSString *nostr = [NSString stringWithUTF8String:_("No")];
const NSInteger rc = NSRunAlertPanel(titlestr, textstr, yesstr, nostr, nil);
answerYNAN = ((rc == NSAlertDefaultReturn) ? MOJOGUI_YES : MOJOGUI_NO);
} // doPromptYN
- (void)doPromptYNAN:(const char *)title text:(const char *)text
{
// !!! FIXME
[self doPromptYN:title text:text];
} // doPromptYN
- (void)doInsertMedia:(const char *)medianame
{
NSString *title = [NSString stringWithUTF8String:_("Media change")];
char *fmt = xstrdup(_("Please insert '%0'"));
char *_text = format(fmt, medianame);
NSString *text = [NSString stringWithUTF8String:_text];
free(_text);
free(fmt);
NSString *okstr = [NSString stringWithUTF8String:_("OK")];
NSString *cancelstr = [NSString stringWithUTF8String:_("Cancel")];
const NSInteger rc = NSRunAlertPanel(title, text, okstr, cancelstr, nil);
answerYNAN = ((rc == NSAlertDefaultReturn) ? MOJOGUI_YES : MOJOGUI_NO);
} // doInsertMedia
- (MojoGuiYNAN)getAnswerYNAN
{
return answerYNAN;
} // getAnswerYNAN
234
235
236
237
238
239
240
241
242
243
- (IBAction)backClicked:(NSButton *)sender
{
clickValue = CLICK_BACK;
[NSApp stop:self];
} // backClicked
- (IBAction)cancelClicked:(NSButton *)sender
{
char *title = xstrdup(_("Cancel installation"));
char *text = xstrdup(_("Are you sure you want to cancel installation?"));
May 7, 2009
May 7, 2009
244
[self doPromptYN:title text:text];
245
246
free(title);
free(text);
May 7, 2009
May 7, 2009
247
if (answerYNAN == MOJOGUI_YES)
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
{
clickValue = CLICK_CANCEL;
[NSApp stop:self];
} // if
} // cancelClicked
- (IBAction)nextClicked:(NSButton *)sender
{
clickValue = CLICK_NEXT;
[NSApp stop:self];
} // nextClicked
- (IBAction)browseClicked:(NSButton *)sender
{
// !!! FIXME: write me!
STUBBED("browseClicked");
} // nextClicked
May 7, 2009
May 7, 2009
266
- (int)doPage:(NSString *)pageId title:(const char *)_title canBack:(boolean)canBack canFwd:(boolean)canFwd canCancel:(boolean)canCancel canFwdAtStart:(boolean)canFwdAtStart shouldBlock:(BOOL)shouldBlock
267
268
269
270
271
272
273
274
{
[TitleLabel setStringValue:[NSString stringWithUTF8String:_title]];
clickValue = CLICK_NONE;
canForward = canFwd;
[BackButton setEnabled:canBack ? YES : NO];
[NextButton setEnabled:canFwdAtStart ? YES : NO];
[CancelButton setEnabled:canCancel ? YES : NO];
[TabView selectTabViewItemWithIdentifier:pageId];
May 7, 2009
May 7, 2009
275
276
277
278
279
280
281
if (shouldBlock == NO)
[self fireCustomEvent:CUSTOMEVENT_RUNQUEUE data1:0 data2:0 atStart:NO];
else
{
[NSApp run];
assert(clickValue < CLICK_NONE);
} // else
282
return (int) clickValue;
May 7, 2009
May 7, 2009
283
} // doPage
284
285
286
287
288
289
- (int)doReadme:(const char *)title text:(NSString *)text canBack:(boolean)canBack canFwd:(boolean)canFwd
{
NSRange range = {0, 1}; // reset scrolling to start of text.
[ReadmeText setString:text];
[ReadmeText scrollRangeToVisible:range];
May 7, 2009
May 7, 2009
290
return [self doPage:@"Readme" title:title canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:canFwd shouldBlock:YES];
291
292
293
294
295
} // doReadme
- (int)doOptions:(MojoGuiSetupOptions *)opts canBack:(boolean)canBack canFwd:(boolean)canFwd
{
// !!! FIXME: write me!
May 7, 2009
May 7, 2009
296
return [self doPage:@"Options" title:_("Options") canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:canFwd shouldBlock:YES];
297
298
299
300
301
302
} // doOptions
- (char *)doDestination:(const char **)recommends recnum:(int)recnum command:(int *)command canBack:(boolean)canBack canFwd:(boolean)canFwd
{
// !!! FIXME: write me!
const boolean fwdAtStart = ( (recnum > 0) && (*(recommends[0])) );
May 7, 2009
May 7, 2009
303
*command = [self doPage:@"Destination" title:_("Destination") canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:fwdAtStart shouldBlock:YES];
304
305
306
307
308
309
return xstrdup("/Applications");
} // doDestination
- (int)doProductKey:(const char *)desc fmt:(const char *)fmt buf:(char *)buf buflen:(const int)buflen canBack:(boolean)canBack canFwd:(boolean)canFwd
{
// !!! FIXME: write me!
May 7, 2009
May 7, 2009
310
return [self doPage:@"ProductKey" title:desc canBack:canBack canFwd:canFwd canCancel:true canFwdAtStart:canFwd shouldBlock:YES];
311
312
313
314
} // doProductKey
- (int)doProgress:(const char *)type component:(const char *)component percent:(int)percent item:(const char *)item canCancel:(boolean)canCancel
{
May 7, 2009
May 7, 2009
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
//static uint32 lastTicks = 0;
//const uint32 ticks = ticks();
//if ((ticks - lastTicks) > 50) // just not to spam this...
{
const BOOL indeterminate = (percent < 0) ? YES : NO;
[ProgressComponentLabel setStringValue:[NSString stringWithUTF8String:component]];
[ProgressItemLabel setStringValue:[NSString stringWithUTF8String:item]];
[ProgressBar setIndeterminate:indeterminate];
if (!indeterminate)
[ProgressBar setDoubleValue:(double)percent];
//lastTicks = ticks;
} // if
return [self doPage:@"Progress" title:type canBack:false canFwd:false canCancel:canCancel canFwdAtStart:false shouldBlock:NO];
330
331
332
333
334
335
} // doProgress
- (void)doFinal:(const char *)msg
{
[FinalText setStringValue:[NSString stringWithUTF8String:msg]];
[NextButton setTitle:[NSString stringWithUTF8String:_("Finish")]];
May 7, 2009
May 7, 2009
336
[self doPage:@"Final" title:_("Finish") canBack:false canFwd:true canCancel:false canFwdAtStart:true shouldBlock:YES];
337
338
339
} // doFinal
@end // implementation MojoSetupController
May 7, 2009
May 7, 2009
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
// Override [NSApplication sendEvent], so we can catch custom events.
@interface MojoSetupApplication : NSApplication
{
}
- (void)sendEvent:(NSEvent *)event;
@end // interface MojoSetupApplication
@implementation MojoSetupApplication
- (void)sendEvent:(NSEvent *)event
{
if ([event type] == NSApplicationDefined)
[((MojoSetupController *)[self delegate]) doCustomEvent:event];
[super sendEvent:event];
} // sendEvent
@end // implementation MojoSetupApplication
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
static uint8 MojoGui_cocoa_priority(boolean istty)
{
// obviously this is the thing you want on Mac OS X.
return MOJOGUI_PRIORITY_TRY_FIRST;
} // MojoGui_cocoa_priority
static boolean MojoGui_cocoa_init(void)
{
// This lets a stdio app become a GUI app. Otherwise, you won't get
// GUI events from the system and other things will fail to work.
// Putting the app in an application bundle does the same thing.
// TransformProcessType() is a 10.3+ API. SetFrontProcess() is 10.0+.
if (TransformProcessType != NULL) // check it as a weak symbol.
{
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
} // if
GAutoreleasePool = [[NSAutoreleasePool alloc] init];
// !!! FIXME: make sure we have access to the desktop...may be ssh'd in
// !!! FIXME: as another user that doesn't have the Finder loaded or
// !!! FIXME: something.
May 7, 2009
May 7, 2009
382
383
384
// For NSApp to be our subclass, instead of default NSApplication.
[MojoSetupApplication sharedApplication];
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
if ([NSBundle loadNibNamed:@"MojoSetup" owner:NSApp] == NO)
return false;
// Force NSApp initialization stuff. MojoSetupController is set, in the
// .nib, to be NSApp's delegate. Its applicationDidFinishLaunching calls
// [NSApp stop] to break event loop right away so we can continue.
[NSApp run];
return true; // always succeeds.
} // MojoGui_cocoa_init
static void MojoGui_cocoa_deinit(void)
{
[GAutoreleasePool release];
GAutoreleasePool = nil;
// !!! FIXME: destroy nib and NSApp?
} // MojoGui_cocoa_deinit
May 7, 2009
May 7, 2009
405
static void MojoGui_cocoa_msgbox(const char *title, const char *text)
406
{
May 7, 2009
May 7, 2009
407
[[NSApp delegate] fireCustomEvent:CUSTOMEVENT_MSGBOX data1:(NSInteger)title data2:(NSInteger)text atStart:YES];
408
409
410
} // MojoGui_cocoa_msgbox
May 7, 2009
May 7, 2009
411
static boolean MojoGui_cocoa_promptyn(const char *title, const char *text,
412
413
boolean defval)
{
May 7, 2009
May 7, 2009
414
415
416
417
[[NSApp delegate] fireCustomEvent:CUSTOMEVENT_PROMPTYN data1:(NSInteger)title data2:(NSInteger)text atStart:YES];
const MojoGuiYNAN ynan = [[NSApp delegate] getAnswerYNAN];
assert((ynan == MOJOGUI_YES) || (ynan == MOJOGUI_NO));
return (ynan == MOJOGUI_YES);
418
419
420
421
422
423
424
} // MojoGui_cocoa_promptyn
static MojoGuiYNAN MojoGui_cocoa_promptynan(const char *title,
const char *text,
boolean defval)
{
May 7, 2009
May 7, 2009
425
426
[[NSApp delegate] fireCustomEvent:CUSTOMEVENT_PROMPTYNAN data1:(NSInteger)title data2:(NSInteger)text atStart:YES];
return [[NSApp delegate] getAnswerYNAN];
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
} // MojoGui_cocoa_promptynan
static boolean MojoGui_cocoa_start(const char *title,
const MojoGuiSplash *splash)
{
printf("start\n");
// !!! FIXME: deal with (splash).
[[NSApp delegate] prepareWidgets:title];
return true;
} // MojoGui_cocoa_start
static void MojoGui_cocoa_stop(void)
{
printf("stop\n");
[[NSApp delegate] unprepareWidgets];
} // MojoGui_cocoa_stop
static int MojoGui_cocoa_readme(const char *name, const uint8 *data,
size_t len, boolean can_back,
boolean can_fwd)
{
printf("readme\n");
NSString *str = [[NSString alloc] initWithBytes:data length:len encoding:NSUTF8StringEncoding];
return [[NSApp delegate] doReadme:name text:str canBack:can_back canFwd:can_fwd];
} // MojoGui_cocoa_readme
static int MojoGui_cocoa_options(MojoGuiSetupOptions *opts,
boolean can_back, boolean can_fwd)
{
printf("options\n");
return [[NSApp delegate] doOptions:opts canBack:can_back canFwd:can_fwd];
} // MojoGui_cocoa_options
static char *MojoGui_cocoa_destination(const char **recommends, int recnum,
int *command, boolean can_back,
boolean can_fwd)
{
printf("destination\n");
return [[NSApp delegate] doDestination:recommends recnum:recnum command:command canBack:can_back canFwd:can_fwd];
} // MojoGui_cocoa_destination
static int MojoGui_cocoa_productkey(const char *desc, const char *fmt,
char *buf, const int buflen,
boolean can_back, boolean can_fwd)
{
printf("productkey\n");
return [[NSApp delegate] doProductKey:desc fmt:fmt buf:buf buflen:buflen canBack:can_back canFwd:can_fwd];
} // MojoGui_cocoa_productkey
static boolean MojoGui_cocoa_insertmedia(const char *medianame)
{
printf("insertmedia\n");
May 7, 2009
May 7, 2009
486
487
488
489
[[NSApp delegate] fireCustomEvent:CUSTOMEVENT_INSERTMEDIA data1:(NSInteger)medianame data2:0 atStart:YES];
const MojoGuiYNAN ynan = [[NSApp delegate] getAnswerYNAN];
assert((ynan == MOJOGUI_YES) || (ynan == MOJOGUI_NO));
return (ynan == MOJOGUI_YES);
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
} // MojoGui_cocoa_insertmedia
static void MojoGui_cocoa_progressitem(void)
{
printf("progressitem\n");
// no-op in this UI target.
} // MojoGui_cocoa_progressitem
static int MojoGui_cocoa_progress(const char *type, const char *component,
int percent, const char *item,
boolean can_cancel)
{
printf("progress\n");
return [[NSApp delegate] doProgress:type component:component percent:percent item:item canCancel:can_cancel];
} // MojoGui_cocoa_progress
static void MojoGui_cocoa_final(const char *msg)
{
printf("final\n");
[[NSApp delegate] doFinal:msg];
} // MojoGui_cocoa_final
// end of gui_cocoa.m ...