home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / MiscKit1.2.6 / Source / MiscInfoController.m < prev    next >
Encoding:
Text File  |  1994-05-28  |  4.5 KB  |  157 lines

  1. //
  2. //    MiscInfoController.m -- a class to handle the guts under an Info menu
  3. //        Written by Don Yacktman (c) 1994 by Don Yacktman.
  4. //                Version 1.0.  All rights reserved.
  5. //
  6. //        This notice may not be removed from this source code.
  7. //
  8. //    This object is included in the MiscKit by permission from the author
  9. //    and its use is governed by the MiscKit license, found in the file
  10. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  11. //    for a list of all applicable permissions and restrictions.
  12. //    
  13.  
  14. #import <misckit/misckit.h>
  15.  
  16. #define mailMessage [strings valueForStringKey:"MailMessage"]
  17. #define authorEmail [strings valueForStringKey:"AuthorEMail"]
  18. #define authorName [strings valueForStringKey:"AuthorName"]
  19. #define _clobber [strings valueForStringKey:"Clobber"]
  20. #define _warning [strings valueForStringKey:"Warning"]
  21. #define _abort [strings valueForStringKey:"Abort"]
  22. #define _OK [strings valueForStringKey:"OK"]
  23. #define _OKForever [strings valueForStringKey:"OKForever"]
  24.  
  25. @implementation MiscInfoController
  26.  
  27. - strings
  28. {
  29.     // attempt to get the string table if it isn't already set up.
  30.     // Try (1) .lproj directories or (2) app delegate.
  31.     if (!strings) {
  32.         // .lproj?
  33.     }
  34.     if (!strings) {
  35.         // NXApp?
  36.         if ([NXApp respondsTo:@selector(strings)])
  37.             strings = [NXApp strings];
  38.     }
  39.     if (!strings) {
  40.         // [NXApp delegate]?
  41.         if ([[NXApp delegate] respondsTo:@selector(strings)])
  42.             strings = [[NXApp delegate] strings];
  43.     }
  44.     return strings;
  45. }
  46.  
  47. - info
  48. {
  49.     if (!info) { // create the object if needed
  50.         info = [[MiscInfo alloc] init];
  51.         [info setController:self];
  52.     }
  53.     return info;
  54. }
  55.  
  56. - orderForm        // return the orderFormPanel, load it if needed.
  57. {
  58.     if (!orderForm) { // create the object if needed
  59.         orderForm = [[MiscOrderForm alloc] init];
  60.         [orderForm setController:self];
  61.     }
  62.     return orderForm;
  63. }
  64.  
  65. - registration        // return the registerPanel, load it if needed.
  66. {
  67.     if (!registration) { // create the object if needed
  68.         registration = [[MiscRegistration alloc] init];
  69.         [registration setController:self];
  70.     }
  71.     return registration;
  72. }
  73.  
  74. - info:sender
  75. { // forward the message on to the MiscInfo object.
  76.     [[self info] info:sender];
  77.     return self;
  78. }
  79.  
  80. - orderForm:sender
  81. { // forward the message on to the MiscInfo object.
  82.     [[self orderForm] orderForm:sender];
  83.     return self;
  84. }
  85.  
  86. - registration:sender
  87. { // forward the message on to the MiscInfo object.
  88.     [[self registration] registration:sender];
  89.     return self;
  90. }
  91.  
  92. - releaseNotes:sender    // make the README panel be up there.
  93. {
  94.     [[[NXHelpPanel new]
  95.             showFile:"ReleaseNotes.rtfd" atMarker:NULL]
  96.             makeKeyAndOrderFront:self];
  97.     return self;
  98. }
  99.  
  100. - license:sender    // make the license panel be up there.
  101. {
  102.     [[[NXHelpPanel new]
  103.             showFile:"License.rtfd" atMarker:NULL]
  104.             makeKeyAndOrderFront:self];
  105.     return self;
  106. }
  107.  
  108. // call() macro sends a message from the app's Speaker to Mail.app to
  109. // perform the various Mail.app functions.
  110. #define call(a,b) [s performRemoteMethod:a with:b length:strlen(b)+1]
  111. - suggestion:sender    // This is pretty much lifted from Opener.
  112. {
  113.     id body = [[MiscString alloc] init];
  114.     id subject = [[MiscString alloc] init];
  115.     id s = [NXApp appSpeaker];
  116.     int x = 1; int doit = NO;
  117.     id tmpstr = [MiscString newWithString:
  118.             NXGetDefaultValue([NXApp appName], "MiscMailClobber")];
  119.  
  120.     [self strings]; // make sure we have a string table
  121.     // Determine if we clobber, abort, or skip warning panel
  122.     if ([tmpstr emptyString]) doit = YES;
  123.     else if ([tmpstr cmp:"OK"]) doit = YES;
  124.     FREE_OBJECT(tmpstr);
  125.     if (doit) x = NXRunAlertPanel(_warning, _clobber, _OK, _OKForever, _abort);
  126.     if (x == 0) NXWriteDefault ([NXApp appName], "MiscMailClobber", "OK");
  127.     if (x == -1) return self; // abort
  128.  
  129.     // prepare the message to send
  130.     [subject setFromFormat:"Comments and suggestions for ``%s'' ",
  131.             [NXApp appName]];
  132.     [subject catStrings:[info versionString], " (",
  133.             [registration serialNumber], ")", NULL];
  134.     [body setFromFormat:mailMessage, authorName, [NXApp appName]];
  135.     [body catStrings:[NXApp userRealName], "\n", NULL];
  136.  
  137.     // launch mail, bring up a compose window if needed, and prepare
  138.     // the message for the user.  They decide whether or not to deliver
  139.     // it, and so on.
  140.     NXPortFromName("Mail", NULL); // make sure app is launched
  141.     [s setSendPort:NXPortFromName("MailSendDemo", NULL)];
  142.     call("setTo:", authorEmail); // will bring up a compose window if needed
  143.     call("setSubject:", [subject stringValue]);
  144.     call("setBody:", [body stringValue]);
  145.     FREE_OBJECT(subject);
  146.     FREE_OBJECT(body);
  147.     return self;
  148. }
  149.  
  150. - hideOrShowMenus:sender
  151. {
  152.     [[MiscExplodingMenu sharedInstance] explodeMenus:sender];
  153.     return self;
  154. }
  155.  
  156. @end
  157.